scripts: runners: Renamed a bunch of flags
Mainly to make space for some planned bench flags, while also preferring "step" over "period" (for consistency), and "runfreq" over "freq" (to differentiate from "simfreq" in the future). In runners: - -s/--step -> --step - --trace-period -> --trace-step - --trace-freq -> --trace-runfreq In scripts: - --record -> -e/--record - --perf-period -> --perf-step - --perf-freq -> --perf-runfreq - --include -> -i/--include --- One thing that makes this work is the new sys.argv regex trick, where we try to predict what mode the script will run in by prematching known mode-switch flags before handing things off to argparse. Note: - Hiding flags from argparse risks confusing help-text, so we include all flags if we see -h/--help in sys.argv. This doesn't work for the help-text printed if argparse errors, but we can only do so much. Maybe argparse only showing relevant flags for the given mode is ok? - We use -[^-]*[hf].* for shortform flags, which should also match multiple shortform flags in a single arg (-fhfhfh). - This requires the conflict_handler='ignore' hack to work, but these scripts already needed it anyways.
This commit is contained in:
+42
-37
@@ -792,11 +792,11 @@ def find_runner(runner, id=None, main=True, **args):
|
||||
# run under perf?
|
||||
if args.get('perf'):
|
||||
cmd[:0] = args['perf_script'] + list(filter(None, [
|
||||
'--record',
|
||||
'--perf-freq=%s' % args['perf_freq']
|
||||
if args.get('perf_freq') else None,
|
||||
'--perf-period=%s' % args['perf_period']
|
||||
if args.get('perf_period') else None,
|
||||
'-e',
|
||||
'--perf-step=%s' % args['perf_step']
|
||||
if args.get('perf_step') else None,
|
||||
'--perf-runfreq=%s' % args['perf_runfreq']
|
||||
if args.get('perf_runfreq') else None,
|
||||
'--perf-events=%s' % args['perf_events']
|
||||
if args.get('perf_events') else None,
|
||||
'--perf-path=%s' % args['perf_path']
|
||||
@@ -822,10 +822,10 @@ def find_runner(runner, id=None, main=True, **args):
|
||||
cmd.append('-t%s' % args['trace'])
|
||||
if args.get('trace_backtrace'):
|
||||
cmd.append('--trace-backtrace')
|
||||
if args.get('trace_period'):
|
||||
cmd.append('--trace-period=%s' % args['trace_period'])
|
||||
if args.get('trace_freq'):
|
||||
cmd.append('--trace-freq=%s' % args['trace_freq'])
|
||||
if args.get('trace_step'):
|
||||
cmd.append('--trace-step=%s' % args['trace_step'])
|
||||
if args.get('trace_runfreq'):
|
||||
cmd.append('--trace-runfreq=%s' % args['trace_runfreq'])
|
||||
if args.get('read_sleep'):
|
||||
cmd.append('--read-sleep=%s' % args['read_sleep'])
|
||||
if args.get('prog_sleep'):
|
||||
@@ -1305,9 +1305,9 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args):
|
||||
while start < total_perms:
|
||||
runner_ = find_runner(runner, main=main, **args)
|
||||
if args.get('isolate') or args.get('valgrind'):
|
||||
runner_.append('-s%s,%s,%s' % (start, start+step, step))
|
||||
runner_.append('--step=%s,%s,%s' % (start, start+step, step))
|
||||
elif start != 0 or step != 1:
|
||||
runner_.append('-s%s,,%s' % (start, step))
|
||||
runner_.append('--step=%s,,%s' % (start, step))
|
||||
|
||||
runner_.extend(bench_ids)
|
||||
|
||||
@@ -1649,6 +1649,7 @@ def main(**args):
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
import sys
|
||||
import re
|
||||
argparse.ArgumentParser._handle_conflict_ignore = lambda *_: None
|
||||
argparse._ArgumentGroup._handle_conflict_ignore = lambda *_: None
|
||||
parser = argparse.ArgumentParser(
|
||||
@@ -1743,10 +1744,10 @@ if __name__ == "__main__":
|
||||
action='store_true',
|
||||
help="Include a backtrace with every trace statement.")
|
||||
bench_parser.add_argument(
|
||||
'--trace-period',
|
||||
help="Sample trace output at this period in cycles.")
|
||||
'--trace-step',
|
||||
help="Sample trace output every n steps.")
|
||||
bench_parser.add_argument(
|
||||
'--trace-freq',
|
||||
'--trace-runfreq',
|
||||
help="Sample trace output at this frequency in hz.")
|
||||
bench_parser.add_argument(
|
||||
'-O', '--stdout',
|
||||
@@ -1847,13 +1848,13 @@ if __name__ == "__main__":
|
||||
help="Run under Linux's perf to sample performance counters, "
|
||||
"writing samples to this file.")
|
||||
bench_parser.add_argument(
|
||||
'--perf-freq',
|
||||
'--perf-step',
|
||||
help="perf sampling step. This is passed directly to the perf "
|
||||
"script.")
|
||||
bench_parser.add_argument(
|
||||
'--perf-runfreq',
|
||||
help="perf sampling frequency. This is passed directly to the "
|
||||
"perf script.")
|
||||
bench_parser.add_argument(
|
||||
'--perf-period',
|
||||
help="perf sampling period. This is passed directly to the perf "
|
||||
"script.")
|
||||
bench_parser.add_argument(
|
||||
'--perf-events',
|
||||
help="perf events to record. This is passed directly to the perf "
|
||||
@@ -1880,27 +1881,31 @@ if __name__ == "__main__":
|
||||
'-c', '--compile',
|
||||
action='store_true',
|
||||
help="Compile a bench suite or source file.")
|
||||
comp_parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Output file.")
|
||||
comp_parser.add_argument(
|
||||
'-s', '--source',
|
||||
help="Source file to compile, possibly injecting internal benches.")
|
||||
comp_parser.add_argument(
|
||||
'--include',
|
||||
help="Inject these header files into every compiled bench file. "
|
||||
"Defaults to %r." % HEADER_PATHS)
|
||||
comp_parser.add_argument(
|
||||
'--no-internal',
|
||||
action='store_true',
|
||||
help="Don't build internal benches.")
|
||||
comp_parser.add_argument(
|
||||
'--no-litmus',
|
||||
action='store_true',
|
||||
help="Don't build litmus benches.")
|
||||
if any(re.fullmatch('-[^-]*[hc].*|--help|--compile', a) for a in sys.argv):
|
||||
comp_parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Output file.")
|
||||
comp_parser.add_argument(
|
||||
'-s', '--source',
|
||||
help="Source file to compile, possibly injecting internal "
|
||||
"benches.")
|
||||
comp_parser.add_argument(
|
||||
'-i', '--include',
|
||||
action='append',
|
||||
help="Inject these header files into every compiled bench "
|
||||
"file. Defaults to %r." % HEADER_PATHS)
|
||||
comp_parser.add_argument(
|
||||
'--no-internal',
|
||||
action='store_true',
|
||||
help="Don't build internal benches.")
|
||||
comp_parser.add_argument(
|
||||
'--no-litmus',
|
||||
action='store_true',
|
||||
help="Don't build litmus benches.")
|
||||
|
||||
# do the thing
|
||||
args = parser.parse_intermixed_args()
|
||||
# bench_paths/bench_ids overlap, so need to do some munging
|
||||
args.bench_paths = args.bench_ids
|
||||
sys.exit(main(**{k: v
|
||||
for k, v in vars(args).items()
|
||||
|
||||
Reference in New Issue
Block a user