Commit caa83330 authored by Matthias Braun's avatar Matthias Braun
Browse files

switch to argparse slightly change compiler options/submit handling

parent e39ee5fe
#!/usr/bin/env python
import os
import platform
import optparse # TODO argparse from python 2.7 on
import argparse
import subprocess
import resource
import socket
......@@ -38,45 +38,49 @@ def identify_suite():
exit(-1)
SPEC_SUITE = identify_suite()
parser = optparse.OptionParser(version=SCRIPT_VERSION, usage="Usage: %prog [options] [programs]")
parser.add_option("--config-only", action="store_true", default=False,
parser = argparse.ArgumentParser(prog=sys.argv[0], version=SCRIPT_VERSION, usage="Usage: %prog [options] [programs]")
parser.add_argument("--config-only", action="store_true", default=False,
help="Just generate config file, but do not build or run")
parser.add_option("--build-only", action="store_true", default=False,
parser.add_argument("--build-only", action="store_true", default=False,
help="Just generate config file and build benchmark programs, but do not run")
parser.add_option("--no-cpp", action="store_true", default=False,
parser.add_argument("--no-cpp", action="store_true", default=False,
help="Exclude benchmark programs using C++")
parser.add_option("--no-fortran", action="store_true", default=False,
parser.add_argument("--no-fortran", action="store_true", default=False,
help="Exclude benchmark programs using Fortran")
parser.add_option("--no-floating-point", action="store_true", default=False,
parser.add_argument("--no-floating-point", action="store_true", default=False,
help="Exclude CFP subset containing floating point-heavy benchmark programs")
parser.add_option("--no-integer", action="store_true", default=False,
parser.add_argument("--no-integer", action="store_true", default=False,
help="Exclude CINT subset containing integer-heavy benchmark programs")
parser.add_option("--no-medium", action="store_true", default=False,
parser.add_argument("--no-medium", action="store_true", default=False,
help="Exclude OMPM programs")
parser.add_option("--no-large", action="store_true", default=False,
parser.add_argument("--no-large", action="store_true", default=False,
help="Exclude OMPL programs")
parser.add_option("-i", "--iterations", metavar="ITR", default=3,
parser.add_argument("-i", "--iterations", metavar="ITR", default=3,
help="Evaluate ITR iterations per program, default=3")
parser.add_option("--time-limit", metavar="TIMELIMIT", default=0,
parser.add_argument("--time-limit", metavar="TIMELIMIT", default=0,
help="Set cpu time limit for each program run to TIMELIMIT seconds.")
parser.add_argument("--submit", metavar="SUBMIT", default=[], action="append",
help="Start compiled programs with SUBMIT")
parser.add_option("--target-architecture", metavar="TARGET_ARCH", default=HOST_ARCH,
parser.add_argument("--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_argument("--c-compiler", metavar="CC", default="gcc",
help="Use CC to build benchmark programs, default=gcc")
parser.add_option("--fortran-compiler", metavar="FC", default="gfortran",
parser.add_argument("--fortran-compiler", metavar="FC", default="gfortran",
help="Use FC to build benchmark programs, default=gfortran")
parser.add_option("--cpp-compiler", metavar="CXX", default="g++",
parser.add_argument("--cpp-compiler", metavar="CXX", default="g++",
help="Use CXX to build benchmark programs, default=g++")
parser.add_option("--compiler-args", metavar="FLAGS", default="-O3",
parser.add_argument("--compiler-args", metavar="FLAGS", default=["-O3"], action="append",
help="Append FLAGS to build benchmark programs for all compilers, default=-O3")
parser.add_option("--c-compiler-args", metavar="CFLAGS", default="-march=native",
parser.add_argument("--c-compiler-args", metavar="CFLAGS", default=[], action="append",
help="Append CFLAGS to build benchmark programs for C compiler, default march=native")
parser.add_option("--fortran-compiler-args", metavar="FFLAGS", default="",
parser.add_argument("--fortran-compiler-args", metavar="FFLAGS", default=[], action="append",
help="Append FFLAGS to build benchmark programs for Fortran compiler, default empty")
parser.add_option("--cpp-compiler-args", metavar="CFLAGS", default="-march=native",
help="Append CFLAGS to build benchmark programs for C++ compiler, default march=native")
parser.add_argument("--cpp-compiler-args", metavar="CPPFLAGS", default=[], action="append",
help="Append CPPFLAGS to build benchmark programs for C++ compiler, default march=native")
parser.add_argument(dest="benchmarks", metavar="BENCHMARK", nargs="*",
help="only run benchmark BENCHMARK")
class SigKill(Exception):
def __init__(self, retcode, name):
......@@ -362,6 +366,10 @@ def check_options(options):
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"
if options.c_compiler_args == []:
options.c_compiler_args = ["-march=native"]
if options.cpp_compiler_args == []:
options.cpp_compiler_args = ["-march=native"]
def generate_spec_config(options, progs):
"""Generate a config file for SPEC"""
......@@ -402,23 +410,30 @@ def generate_spec_config(options, progs):
contents.append("hw_memory = %s" % meminfo["MemTotal"])
contents.append("hw_pcache = %s" % cpuinfo.get("cache size", "?"))
contents.append("")
submit = ""
time_limit = int(options.time_limit)
if time_limit != 0:
submit = "ulimit -t %d ; " % (time_limit,)
if options.submit != []:
submit += " ".join(options.submit) + " "
if submit != "":
submit += "$command"
contents.append("use_submit_for_speed = 1")
contents.append("submit =ulimit -t %d ; $command" % time_limit)
contents.append("submit = %s" % submit)
contents.append("")
contents.append("CC = %s" % options.c_compiler)
contents.append("CXX = %s" % options.cpp_compiler)
contents.append("FC = %s" % options.fortran_compiler)
contents.append("")
contents.append("OPTIMIZE = %s" % options.compiler_args)
contents.append("notes_comp_001 OPTIMIZE = %s" % options.compiler_args)
contents.append("COPTIMIZE = %s" % options.c_compiler_args)
contents.append("notes_comp_002 COPTIMIZE = %s" % options.c_compiler_args)
contents.append("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("notes_comp_004 FOPTIMIZE = %s" % options.fortran_compiler_args)
contents.append("OPTIMIZE = %s" % " ".join(options.compiler_args))
contents.append("notes_comp_001 OPTIMIZE = %s" % " ".join(options.compiler_args))
contents.append("COPTIMIZE = %s" % " ".join(options.c_compiler_args))
contents.append("notes_comp_002 COPTIMIZE = %s" % " ".join(options.c_compiler_args))
contents.append("CXXOPTIMIZE = %s" % " ".join(options.cpp_compiler_args))
contents.append("notes_comp_003 CXXOPTIMIZE = %s" % " ".join(options.cpp_compiler_args))
contents.append("FOPTIMIZE = %s" % " ".join(options.fortran_compiler_args))
contents.append("notes_comp_004 FOPTIMIZE = %s" % " ".join(options.fortran_compiler_args))
if HOST_ARCH == "x86_64" and options.target_architecture == "i686":
contents.append("EXTRA_CFLAGS = -m32")
contents.append("EXTRA_LDFLAGS = -m32")
......@@ -444,9 +459,9 @@ def generate_spec_config(options, progs):
return "\n".join(contents)
if __name__ == "__main__":
(options, args) = parser.parse_args()
options = parser.parse_args()
check_options(options)
progs = [prog for prog in filter_progs(options, args)]
progs = [prog for prog in filter_progs(options, options.benchmarks)]
conf = generate_spec_config(options, progs)
if options.config_only:
sys.stdout.write(conf)
......
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