Skip to content

Commit

Permalink
Pass instrumentation dir on the iterations runner command line.
Browse files Browse the repository at this point in the history
(for only C and Python runners for now).
  • Loading branch information
vext01 committed Feb 1, 2018
1 parent b1b98a3 commit da9cbed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
9 changes: 6 additions & 3 deletions iterations_runners/iterations_runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,13 @@ main(int argc, char **argv)
uint64_t **krun_cycle_counts = NULL, **krun_aperf_counts = NULL;
uint64_t **krun_mperf_counts = NULL;

if (argc != 6) {
if (argc < 5) {
printf("usage: iterations_runner_c "
"<benchmark> <# of iterations> <benchmark param> <debug flag> "
"<instrument flag>\n");
"<benchmark> <# of iterations> <benchmark param> <debug flag>\n"
"[instrumentation dir] [key] [key pexec index]\n");
printf("Arguments in [] are supplied for instrumentation mode only.\n"
"If an 'instrumentation dir' is supplied, then instrumentation\n"
"mode is assumed.");
exit(EXIT_FAILURE);
}

Expand Down
17 changes: 8 additions & 9 deletions iterations_runners/iterations_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
Executes a benchmark many times within a single process.
usage: iterations_runner.py <benchmark> <# of iterations> <benchmark param>
<debug flag> <instrument flag> [key] [key pexec index]
<debug flag> [instrumentation dir] [key] [key pexec index]
Arguments in [] are only passed under instrumentation mode.
Arguments in [] are supplied for instrumentation mode only. If an
"instrumentaion dir" is supplied, then instrumentation mode is assumed.
"""

import cffi, sys, imp, os
Expand Down Expand Up @@ -79,25 +80,23 @@ def usage():
# main
if __name__ == "__main__":
num_args = len(sys.argv)
if num_args < 6:
if num_args < 5:
usage()

benchmark, iters, param, debug, instrument = sys.argv[1:6]
iters, param, debug, instrument = \
int(iters), int(param), int(debug) == 1, int(instrument) == 1
benchmark, iters, param, debug = sys.argv[1:5]
iters, param, debug = int(iters), int(param), int(debug) == 1
instrument = num_args > 5

if instrument:
# The new instrumentation switches are unused here, as the PyPy
# instrumentation code uses the legacy instrumentation framework. We
# still check the right number of args is passed.
if num_args != 8:
usage()
import pypyjit # instrumentation not supported on CPython yet anyway
elif num_args > 6:
usage()

if instrument:
import pypyjit # instrumentation not supported on CPython yet anyway

assert benchmark.endswith(".py")
bench_mod_name = os.path.basename(benchmark[:-3])
bench_mod = imp.load_source(bench_mod_name, benchmark)
Expand Down
7 changes: 2 additions & 5 deletions krun/vm_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,15 @@ def _run_exec(self, args, heap_lim_k, stack_lim_k, key, key_pexec_idx,
else:
args.append("0")

# Tack on the instrumentation flag
# All runners accept this flag, even if instrumentation is not
# implemented for the VM in question.
# Tack on the instrumentation arguments, if required.
if self.instrument:
args.append("1")
args.append(util.get_instr_json_dir(self.config))
# we will redirect stderr to this handle
stderr_file = open(INST_STDERR_FILE, "w")
# Append flags only present in instrumentation mode.
args.extend([key, str(key_pexec_idx)])

else:
args.append("0")
stderr_file = subprocess.PIPE

if self.dry_run:
Expand Down

0 comments on commit da9cbed

Please sign in to comment.