From da9cbeddab4db8b17cf433b2d06100cfba54961d Mon Sep 17 00:00:00 2001 From: Edd Barrett Date: Thu, 1 Feb 2018 15:06:41 +0000 Subject: [PATCH] Pass instrumentation dir on the iterations runner command line. (for only C and Python runners for now). --- iterations_runners/iterations_runner.c | 9 ++++++--- iterations_runners/iterations_runner.py | 17 ++++++++--------- krun/vm_defs.py | 7 ++----- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/iterations_runners/iterations_runner.c b/iterations_runners/iterations_runner.c index ae5e7b2..9c2bd95 100644 --- a/iterations_runners/iterations_runner.c +++ b/iterations_runners/iterations_runner.c @@ -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 " - " <# of iterations> " - "\n"); + " <# of iterations> \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); } diff --git a/iterations_runners/iterations_runner.py b/iterations_runners/iterations_runner.py index 3cf2808..8260656 100644 --- a/iterations_runners/iterations_runner.py +++ b/iterations_runners/iterations_runner.py @@ -41,9 +41,10 @@ Executes a benchmark many times within a single process. usage: iterations_runner.py <# of iterations> - [key] [key pexec index] + [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 @@ -79,12 +80,12 @@ 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 @@ -92,12 +93,10 @@ def usage(): # 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) diff --git a/krun/vm_defs.py b/krun/vm_defs.py index 5591a99..20a86e1 100644 --- a/krun/vm_defs.py +++ b/krun/vm_defs.py @@ -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: