From 6d17b2ef843fa508b0438dfc5cdcb65628e2b8e2 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sun, 9 Sep 2018 13:03:49 +0100 Subject: [PATCH] readfile moved into run dir to allow multiple parallel runs Set with --gem5-readefile helper --- README.adoc | 21 ++++++++++----------- common.py | 4 ++-- run | 9 ++++++++- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/README.adoc b/README.adoc index a1ab3a4..cfb1eec 100644 --- a/README.adoc +++ b/README.adoc @@ -7088,10 +7088,13 @@ time \ gem5 full system: .... -printf 'm5 exit' > data/readfile -./run --arch arm --gem5 --eval-busybox '/gem5.sh' -printf 'dhrystone 100000' > data/readfile -time ./run --arch arm --gem5-restore 1 --gem5 +time \ + ./run \ + --arch arm \ + --eval-busybox '/gem5.sh' \ + --gem5 + --gem5-readfile 'dhrystone 100000' \ +; .... QEMU user mode: @@ -7645,25 +7648,21 @@ restore='-l 1 -- --cpu-type=HPI --restore-with-cpu=HPI --caches --l2cache --l1d_ # Generate a checkpoint after Linux boots, using the faster and less detailed CPU. # The boot takes a while, be patient young Padawan. -printf '' > data/readfile eval "$cmd" # Restore the most recent checkpoint taken with the more detailed and slower HPI CPU, # and run the benchmark with parameter 1.000. We skip the boot completely, saving time! -printf 'dhrystone 1000' > data/readfile -eval "${cmd} ${restore}" +eval "${cmd} --gem5-readfile 'dhrystone 1000' ${restore}" ./gem5-stat -a "$arch" # Now run again with another parameter 10.000. # This one should take more cycles! -printf 'dhrystone 10000' > data/readfile -eval "${cmd} ${restore}" +eval "${cmd} --gem5-readfile 'dhrystone 10000' ${restore}" ./gem5-stat -a "$arch" # Get an interactive shell at the end of the restore # if you need to debug something more interactively. -printf 'sh' > data/readfile -eval "${cmd} ${restore}" +eval "${cmd} --gem5-readfile 'sh' ${restore}" .... The `gem5-stats` commands output the approximate number of CPU cycles it took Dhrystone to run. diff --git a/common.py b/common.py index 911f485..7419599 100644 --- a/common.py +++ b/common.py @@ -20,7 +20,6 @@ root_dir = os.path.dirname(os.path.abspath(__file__)) data_dir = os.path.join(root_dir, 'data') p9_dir = os.path.join(data_dir, '9p') gem5_non_default_src_root_dir = os.path.join(data_dir, 'gem5') -gem5_readfile_file = os.path.join(data_dir, 'readfile') out_dir = os.path.join(root_dir, 'out') bench_boot = os.path.join(out_dir, 'bench-boot.txt') common_dir = os.path.join(out_dir, 'common') @@ -346,6 +345,7 @@ def setup(parser, **extra_args): this.m5out_dir = os.path.join(this.gem5_run_dir, 'm5out') this.stats_file = os.path.join(this.m5out_dir, 'stats.txt') this.trace_txt_file = os.path.join(this.m5out_dir, 'trace.txt') + this.gem5_readfile = os.path.join(this.gem5_run_dir, 'readfile') this.gem5_termout_file = os.path.join(this.gem5_run_dir, 'termout.txt') this.qemu_run_dir = os.path.join(this.out_arch_dir, 'qemu', str(args.run_id)) this.qemu_trace_basename = 'trace.bin' @@ -370,7 +370,7 @@ def setup(parser, **extra_args): this.executable = this.qemu_executable this.run_dir = this.qemu_run_dir this.termout_file = this.qemu_termout_file - this.gem5_config_dir = os.path.join(this.gem5_src_dir, 'config') + this.gem5_config_dir = os.path.join(this.gem5_src_dir, 'configs') this.gem5_se_file = os.path.join(this.gem5_config_dir, 'example', 'se.py') this.gem5_fs_file = os.path.join(this.gem5_config_dir, 'example', 'fs.py') this.run_cmd_file = os.path.join(this.run_dir, 'run.sh') diff --git a/run b/run index c5574a1..a0492f4 100755 --- a/run +++ b/run @@ -16,6 +16,7 @@ defaults = { 'extra_emulator_args': [], 'gem5_biglittle': False, 'gem5_exe_args': '', + 'gem5_readfile': '', 'gem5_restore': None, 'graphic': False, 'initramfs': False, @@ -94,6 +95,8 @@ def main(args, extra_args=None): trace_type = args.trace if args.gem5: + with open(common.gem5_readfile, 'w') as readfile: + readfile.write(args.gem5_readfile) memory = '{}B'.format(args.memory) gem5_exe_args = shlex.split(args.gem5_exe_args) if do_trace: @@ -135,7 +138,7 @@ def main(args, extra_args=None): '--kernel', common.vmlinux, '--mem-size', memory, '--num-cpus', str(args.cpus), - '--script', common.gem5_readfile_file, + '--script', common.gem5_readfile, ] if args.arch == 'x86_64': if args.kvm: @@ -350,6 +353,10 @@ gem.op5 --debug-flags=Exec fs.py --cpu-type=HPI --caches '--gem5-biglittle', default=defaults['gem5_biglittle'], action='store_true', help='Use fs_bigLITTLE.py instead of fs.py' ) + parser.add_argument( + '--gem5-readfile', default=defaults['gem5_readfile'], + help='Set the contents of m5 readfile to this string.' + ) init_group.add_argument( '-I', '--initramfs', default=defaults['initramfs'], action='store_true', help='Use initramfs instead of a root filesystem'