Commit 3804d0ec authored by Manuel Mohr's avatar Manuel Mohr
Browse files

Rework compatibility flag handling and cross-compilation.

Separate flags into architecture-dependent, compiler-dependent and other
flags and only set them when really needed.  Also fix various
inconsistent or wrong flags.
parent 32665c0f
...@@ -9,13 +9,14 @@ from datetime import datetime ...@@ -9,13 +9,14 @@ from datetime import datetime
SCRIPT_VERSION="0.1" SCRIPT_VERSION="0.1"
AUTHOR="Andreas Zwinkau <zwinkau@kit.edu>" AUTHOR="Andreas Zwinkau <zwinkau@kit.edu>"
(KERNEL,HOSTNAME,KERNEL_VERSION,VERSION,ARCH,PROCESSOR) = platform.uname() (KERNEL,HOSTNAME,KERNEL_VERSION,VERSION,HOST_ARCH,PROCESSOR) = platform.uname()
LINUX_NAME, LINUX_VERSION, LINUX_CODENAME = platform.dist() LINUX_NAME, LINUX_VERSION, LINUX_CODENAME = platform.dist()
BITSIZE = { BITSIZE = {
"i686": 32, "i686": 32,
"x86_64": 64, "x86_64": 64,
"sparc" : 32,
"sparc64": 64, "sparc64": 64,
}.get(ARCH, "unspecified for "+ARCH) }.get(HOST_ARCH, "unspecified for "+HOST_ARCH)
# assert spec dir # assert spec dir
for subdir in "benchspec config bin result".split(): for subdir in "benchspec config bin result".split():
...@@ -57,6 +58,8 @@ parser.add_option("-i", "--iterations", metavar="ITR", default=3, ...@@ -57,6 +58,8 @@ parser.add_option("-i", "--iterations", metavar="ITR", default=3,
parser.add_option("--time-limit", metavar="TIMELIMIT", default=0, parser.add_option("--time-limit", metavar="TIMELIMIT", default=0,
help="Set cpu time limit for each program run to TIMELIMIT seconds.") help="Set cpu time limit for each program run to TIMELIMIT seconds.")
parser.add_option("--target-architecture", metavar="TARGET_ARCH", default=HOST_ARCH,
help="Set target architecture, default=" + HOST_ARCH)
parser.add_option("--c-compiler", metavar="CC", default="gcc", parser.add_option("--c-compiler", metavar="CC", default="gcc",
help="Use CC to build benchmark programs, default=gcc") help="Use CC to build benchmark programs, default=gcc")
parser.add_option("--fortran-compiler", metavar="FC", default="gfortran", parser.add_option("--fortran-compiler", metavar="FC", default="gfortran",
...@@ -73,24 +76,6 @@ parser.add_option("--fortran-compiler-args", metavar="FFLAGS", default="", ...@@ -73,24 +76,6 @@ parser.add_option("--fortran-compiler-args", metavar="FFLAGS", default="",
parser.add_option("--cpp-compiler-args", metavar="CFLAGS", default="-march=native", parser.add_option("--cpp-compiler-args", metavar="CFLAGS", default="-march=native",
help="Append CFLAGS to build benchmark programs for C++ compiler, default march=native") help="Append CFLAGS to build benchmark programs for C++ compiler, default march=native")
# http://www.spec.org/cpu2006/Docs/config.html
_CONFIG_HEAD = """\
#### Automatically generated by spec.py script ####
output_format = csv,html,raw,screen,config
ignore_errors = yes
test_sponsor = IPD Snelting
tester_name = IPD Snelting
company_name = Karlsruhe Institute of Technology KIT
prepared_by = spec.py script
## just assuming:
hw_fpu = Integrated
sw_state = Multi-user
"""
class SigKill(Exception): class SigKill(Exception):
def __init__(self, retcode, name): def __init__(self, retcode, name):
self.retcode = retcode self.retcode = retcode
...@@ -167,115 +152,52 @@ def get_compiler_version(compiler): ...@@ -167,115 +152,52 @@ def get_compiler_version(compiler):
except OSError: except OSError:
return "No compiler '%s' found." % compiler return "No compiler '%s' found." % compiler
PORTABILITY_FLAGS = dict() # Target architecture-dependent flags
TARGET_ARCH_FLAGS = dict()
PORTABILITY_FLAGS[("SPEC CPU2000", "Ubuntu", 32)] = """\
176.gcc=default=default=default: i686_flags = dict()
CPORTABILITY = -std=gnu89 -fno-strict-aliasing i686_flags["186.crafty"] = "-DLINUX_i386"
notes003 = CPORTABILITY 176.gcc: -std=gnu89 -fno-strict-aliasing i686_flags["253.perlbmk"] = "-DSPEC_CPU2000_LINUX_I386"
186.crafty=default=default=default: i686_flags["400.perlbench"] = "-DSPEC_CPU_LINUX_IA32"
CPORTABILITY = -DLINUX_i386 i686_flags["403.gcc"] = "-DSPEC_CPU_LINUX_IA32"
notes004 = CPORTABILITY 186.crafty: -DLINUX_i386 TARGET_ARCH_FLAGS["i686"] = i686_flags
252.eon=default=default=default:
CXXPORTABILITY = -DHAS_ERRLIST sparc_flags = dict()
notes005 = CXXPORTABILITY 252.eon: -DHAS_ERRLIST sparc_flags["176.gcc"] = "-DHOST_WORDS_BIG_ENDIAN"
253.perlbmk=default=default=default: sparc_flags["186.crafty"] = "-DLINUX_SPARC"
CPORTABILITY = -DSPEC_CPU2000_NEED_BOOL -DSPEC_CPU2000_LINUX_I386 sparc_flags["253.perlbmk"] = "-DSPEC_CPU2000_LINUX_SPARC"
notes006 = CPORTABILITY 253.perlbmk: -DSPEC_CPU2000_NEED_BOOL -DSPEC_CPU2000_LINUX_I386 TARGET_ARCH_FLAGS["sparc"] = sparc_flags
254.gap=default=default=default:
CPORTABILITY = -DSYS_HAS_SIGNAL_PROTO -DSYS_HAS_MALLOC_PROTO -DSYS_HAS_CALLOC_PROTO -DSYS_IS_USG -DSYS_HAS_IOCTL_PROTO -DSYS_HAS_TIME_PROTO
notes007 = CPORTABILITY 254.gap: -DSYS_HAS_SIGNAL_PROTO -DSYS_HAS_MALLOC_PROTO -DSYS_HAS_CALLOC_PROTO -DSYS_IS_USG -DSYS_HAS_IOCTL_PROTO -DSYS_HAS_TIME_PROTO # Compiler-dependent flags
255.vortex=default=default=default: COMPILER_FLAGS = dict()
CPORTABILITY = -fno-strict-aliasing cparser_flags = dict()
notes008 = CPORTABILITY 255.vortex: -fno-strict-aliasing cparser_flags["176.gcc"] = "-std=gnu89"
187.facerec=default=default=default: cparser_flags["403.gcc"] = "-std=gnu89 -fno-if-conversion"
EXTRA_FFLAGS= -I../src COMPILER_FLAGS["cparser"] = cparser_flags
"""
PORTABILITY_FLAGS[("SPEC CPU2000", "Ubuntu", 64)] = PORTABILITY_FLAGS[("SPEC CPU2000", "Ubuntu", 32)] # Compatibility/SPEC-specific flags, always needed
PORTABILITY_FLAGS[("SPEC CPU2000", "debian", 32)] = PORTABILITY_FLAGS[("SPEC CPU2000", "Ubuntu", 32)] compat_flags = dict()
PORTABILITY_FLAGS[("SPEC CPU2000", "debian", 64)] = PORTABILITY_FLAGS[("SPEC CPU2000", "Ubuntu", 32)] compat_flags["176.gcc"] = "-fno-strict-aliasing"
compat_flags["252.eon"] = "-DHAS_ERRLIST"
PORTABILITY_FLAGS[("SPEC OMP2001", "Ubuntu", 32)] = """\ compat_flags["253.perlbmk"] = "-DSPEC_CPU2000_NEED_BOOL"
310.wupwise_m=default=default=default: compat_flags["254.gap"] = "-DSYS_HAS_SIGNAL_PROTO -DSYS_HAS_MALLOC_PROTO -DSYS_HAS_CALLOC_PROTO -DSYS_IS_USG -DSYS_HAS_IOCTL_PROTO -DSYS_HAS_TIME_PROTO"
FPORTABILITY=-ffixed-form compat_flags["255.vortex"] = "-fno-strict-aliasing"
312.swim_m=default=default=default: compat_flags["462.libquantum"] = "-DSPEC_CPU_LINUX"
FPORTABILITY=-ffixed-form compat_flags["481.wrf"] = "-DSPEC_CPU_CASE_FLAG -DSPEC_CPU_LINUX"
314.mgrid_m=default=default=default: compat_flags["483.xalancbmk"] = "-DSPEC_CPU_LINUX"
FPORTABILITY=-ffixed-form # Fortran stuff
# no lastprivate error on i44pc50, needs extra download compat_flags["187.facerec"] = "-I../src"
srcalt = intel compat_flags["310.wupwise_m"] = "ffixed-form"
316.applu_m=default=default=default: compat_flags["312.swim_m"] = "-ffixed-form"
FPORTABILITY=-ffixed-form compat_flags["314.mgrid_m"] = "-ffixed-form"
318.galgel_m=default=default=default: compat_flags["316.applu_m"] = "-ffixed-form"
# fix infinite loop on i44pc49, needs extra download compat_flags["318.galgel_m"] = "-ffixed-form -ffixed-line-length-80"
srcalt = dlamch compat_flags["324.apsi_m"] = "-ffixed-form"
FPORTABILITY=-ffixed-form -ffixed-line-length-80 compat_flags["326.gafort_m"] = "-qsuffix=f=f90"
324.apsi_m=default=default=default: compat_flags["328.fma3d_m"] = "-qsuffix=f=f90"
FPORTABILITY=-ffixed-form COMPATIBILITY_FLAGS = compat_flags
326.gafort_m=default=default=default:
FPORTABILITY=-qsuffix=f=f90
328.fma3d_m=default=default=default:
FPORTABILITY=-qsuffix=f=f90
"""
PORTABILITY_FLAGS[("SPEC OMP2001", "debian", 64)] = """\
310.wupwise_m=default=default=default:
FPORTABILITY=-ffixed-form
312.swim_m=default=default=default:
FPORTABILITY=-ffixed-form
314.mgrid_m=default=default=default:
FPORTABILITY=-ffixed-form
# no lastprivate error on i41s1, needs extra download
# http://www.spec.org/omp2001/src.alt.m/ompm2001-mgrid-20071113.tar.gz
srcalt = intel
316.applu_m=default=default=default:
FPORTABILITY=-ffixed-form
318.galgel_m=default=default=default:
FPORTABILITY=-ffixed-form -ffixed-line-length-80
324.apsi_m=default=default=default:
FPORTABILITY=-ffixed-form
326.gafort_m=default=default=default:
FPORTABILITY=-qsuffix=f=f90
328.fma3d_m=default=default=default:
FPORTABILITY=-qsuffix=f=f90
"""
PORTABILITY_FLAGS[("SPEC CPU2006", "Ubuntu", 32)] = """\
400.perlbench=default=default=default:
CPORTABILITY= -DSPEC_CPU_LINUX_IA32
403.gcc=default=default=default:
CPORTABILITY= -DSPEC_CPU_LINUX_IA32 -fno-if-conversion -std=gnu89
462.libquantum=default=default=default:
CPORTABILITY= -DSPEC_CPU_LINUX
483.xalancbmk=default=default=default:
CXXPORTABILITY= -DSPEC_CPU_LINUX
481.wrf=default=default=default:
CPORTABILITY = -DSPEC_CPU_CASE_FLAG -DSPEC_CPU_LINUX
"""
PORTABILITY_FLAGS[("SPEC CPU2006", "Ubuntu", 64)] = """\
default=base=default=default:
PORTABILITY = -DSPEC_CPU_LP64
400.perlbench=default=default=default:
CPORTABILITY = -DSPEC_CPU_LINUX_X64
462.libquantum=default=default=default:
CPORTABILITY= -DSPEC_CPU_LINUX
483.xalancbmk=default=default=default:
CXXPORTABILITY= -DSPEC_CPU_LINUX
481.wrf=default=default=default:
CPORTABILITY = -DSPEC_CPU_CASE_FLAG -DSPEC_CPU_LINUX
"""
def get_portability():
"""Get necessary portability flags"""
contents = ["\n\n#### Portability Flags ####"]
for (suite,os,bitsize),text in PORTABILITY_FLAGS.items():
if suite != SPEC_SUITE: continue
if os != LINUX_NAME: continue
if bitsize != BITSIZE: continue
contents.append(text)
return "\n".join(contents)
BENCHMARK_PROPERTIES = [ BENCHMARK_PROPERTIES = [
("SPEC CPU2000", "CINT", "164.gzip", "c"), ("SPEC CPU2000", "CINT", "164.gzip", "c"),
...@@ -381,7 +303,63 @@ def filter_progs(options,args): ...@@ -381,7 +303,63 @@ def filter_progs(options,args):
continue continue
yield prog yield prog
def generate_spec_config(options): # http://www.spec.org/cpu2006/Docs/config.html
_CONFIG_HEAD = """\
#### Automatically generated by spec.py script ####
output_format = csv,html,raw,screen,config
ignore_errors = yes
test_sponsor = IPD Snelting
tester_name = IPD Snelting
company_name = Karlsruhe Institute of Technology KIT
prepared_by = spec.py script
## just assuming:
hw_fpu = Integrated
sw_state = Multi-user
"""
def get_portability(options, prog, lang):
if lang == "c":
port = "CPORTABILITY"
compiler = os.path.basename(options.c_compiler)
elif lang == "cpp":
port = "CXXPORTABILITY"
compiler = os.path.basename(options.cpp_compiler)
# Currently no real handling of multi-language benchmarks
elif "fortran" in lang:
port = "FPORTABILITY"
compiler = os.path.basename(options.fortran_compiler)
else:
print "Unknown benchmark language: ", lang
exit(1)
target_arch = options.target_architecture
compat_flags = COMPATIBILITY_FLAGS.get(prog, "")
if not TARGET_ARCH_FLAGS.has_key(target_arch):
print "No architecture-dependent flags defined for architecture '%s'" % target_arch
exit(1)
target_flags = TARGET_ARCH_FLAGS[target_arch].get(prog, "")
compiler_flags = ""
for comp in COMPILER_FLAGS:
if comp in compiler: # Also allow stuff like sparc-leon-linux-gnu-gcc or cparser-test
compiler_flags = COMPILER_FLAGS[comp].get(prog, "")
break
flags = ' '.join(filter(None, [compat_flags, target_flags, compiler_flags]))
if flags == '':
return None
return "%s = %s" % (port, flags)
def check_options(options):
# Convenience: always compile to 32-bit x86 code with cparser
target_x86 = options.target_architecture == "i686" or options.target_architecture == "x86_64"
is_cparser = "cparser" in options.c_compiler
if HOST_ARCH == "x86_64" and is_cparser and target_x86 and not ("-m32" in options.c_compiler_args):
options.target_architecture = "i686"
def generate_spec_config(options, progs):
"""Generate a config file for SPEC""" """Generate a config file for SPEC"""
contents = [_CONFIG_HEAD] contents = [_CONFIG_HEAD]
cpuinfo = get_cpu_info() cpuinfo = get_cpu_info()
...@@ -436,18 +414,37 @@ def generate_spec_config(options): ...@@ -436,18 +414,37 @@ def generate_spec_config(options):
contents.append("notes_comp_003 CXXOPTIMIZE = %s" % options.cpp_compiler_args) contents.append("notes_comp_003 CXXOPTIMIZE = %s" % options.cpp_compiler_args)
contents.append("FOPTIMIZE = %s" % options.fortran_compiler_args) contents.append("FOPTIMIZE = %s" % options.fortran_compiler_args)
contents.append("notes_comp_004 FOPTIMIZE = %s" % options.fortran_compiler_args) contents.append("notes_comp_004 FOPTIMIZE = %s" % options.fortran_compiler_args)
contents.append(get_portability()) if HOST_ARCH == "x86_64" and options.target_architecture == "i686":
contents.append("EXTRA_CFLAGS = -m32")
contents.append("EXTRA_LDFLAGS = -m32")
# Enforce big-endian for SPARC
if options.target_architecture == "sparc":
contents.append("\nendian = 4321")
notes = 0
contents.append("\n\n#### Portability flags ####")
for (suite, subset, prog, lang) in BENCHMARK_PROPERTIES:
if prog in progs:
port = get_portability(options, prog, lang)
if port is not None:
contents.append(prog + "=default=default=default:")
contents.append(port)
contents.append("notes%03d = %s: %s" % (notes, prog, port))
notes = notes + 1
return "\n".join(contents) return "\n".join(contents)
if __name__ == "__main__": if __name__ == "__main__":
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
conf = generate_spec_config(options) check_options(options)
progs = [prog for prog in filter_progs(options, args)]
conf = generate_spec_config(options, progs)
fh = open("config/generated.cfg", 'w') fh = open("config/generated.cfg", 'w')
fh.write(conf) fh.write(conf)
fh.close() fh.close()
if options.config_only: if options.config_only:
exit(0) exit(0)
progs = " ".join(filter_progs(options,args)) strprogs = " ".join(progs)
cmd = "env bash -l -c 'source shrc && runspec %s -c generated'" % progs cmd = "env bash -l -c 'source shrc && runspec %s -c generated'" % strprogs
exit(os.system(cmd)) exit(os.system(cmd))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment