From 13e840df9e64581836f3fdd99cb81f20eeea3f1b Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Tue, 13 Mar 2018 13:06:33 +0000 Subject: [PATCH] gem5: namespace checkpoints by arch Also refactor common gem5 x86 and arm command parts --- README.adoc | 27 ++++++++++++++++++--------- run | 38 ++++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/README.adoc b/README.adoc index b620b04..653f5cf 100644 --- a/README.adoc +++ b/README.adoc @@ -1791,7 +1791,7 @@ These commands output the approximate number of CPU cycles it took Dhrystone to It works like this: -* the first commond boots linux with the default simplified `AtomicSimpleCPU`, and generates a <> after the kernel boots and before running the benchmark +* the first command boots linux with the default simplified `AtomicSimpleCPU`, and generates a <> after the kernel boots and before running the benchmark * the second command restores the checkpoint with the more detailed `HPI` CPU model, and runs the benchmark. We don't boot with it because that is much slower. ARM employees have just been modifying benchmarking code with instrumentation directly: https://github.com/arm-university/arm-gem5-rsk/blob/aa3b51b175a0f3b6e75c9c856092ae0c8f2a7cdc/parsec_patches/xcompile-patch.diff#L230 @@ -2267,10 +2267,10 @@ Analogous to QEMU's <>, but better since it can be started from inside Documentation: http://gem5.org/Checkpoints .... -./rung -a arm -g +./run -a arm -g .... -In guest, wait for the boot to end and run: +In the guest, wait for the boot to end and run: .... m5 checkpoint @@ -2279,7 +2279,7 @@ m5 checkpoint To restore the checkpoint, kill the VM and run: .... -./rung -a arm -g -- -r 1 +./run -a arm -g -- -r 1 .... Let's create a second checkpoint to see how it works, in guest: @@ -2303,11 +2303,6 @@ cat f contains the `date`. The file `f` wouldn't exist had we used the first checkpoint with `-r 1`. -Internals: - -* the checkpoints are stored under `m5out/cpt.*` -* `m5` is a guest utility present inside the gem5 tree which we cross-compiled and installed into the guest - If you automate things with <> as in: .... @@ -2322,6 +2317,20 @@ Then there is no need to pass the kernel command line again to gem5 for replay: since boot has already happened, and the parameters are already in the RAM of the snapshot. +Our scripts "namespace" with the checkpoint by architecture with `--checkpoint-dir`, so if you make two checkpoints: + +* one in x86 +* the other in arm + +Then you would still restore both of them with `-- -r 1`. + +This makes it easier to remember which checkpoint is which, especially since there appears to be no runtime way to set the checkpoint names. + +Internals: + +* the checkpoints are stored under `m5out/cpts/$arch/cpt.$todo_whatisthis` +* `m5` is a guest utility present inside the gem5 tree which we cross-compiled and installed into the guest + ==== gem5 restore checkpoint with a different CPU gem5 can switch to a different CPU model when restoring a checkpoint. diff --git a/run b/run index 1227215..2290f7c 100755 --- a/run +++ b/run @@ -74,35 +74,37 @@ out_dir="${root_dir}/buildroot/output.${arch_dir}~" if "$gem5"; then build_dir="${out_dir}/build/gem5-1.0" gem5_dir="${build_dir}/gem5" + if [ "$arch" = x86_64 ]; then + gem5_arch=X86 + else + gem5_arch=ARM + fi + gem5_cpt_dir="./m5out/cpts/${arch}" + mkdir -p "$gem5_cpt_dir" + gem5_common="\ +M5_PATH='${build_dir}/system' \ +$debug_vm \ +'${gem5_dir}/build/${gem5_arch}/gem5.opt' \ +${gem5opts} \ +'${gem5_dir}/configs/example/fs.py' \ +--checkpoint-dir='${gem5_cpt_dir}' \ +--disk-image='${out_dir}/images/rootfs.ext2' \ +--kernel='${out_dir}/build/linux-custom/vmlinux' \ +--num-cpus='${cpus}' \ +" if [ "$arch" = x86_64 ]; then if "$kvm"; then extra_flags="$extra_flags --cpu-type=X86KvmCPU" fi - cmd="\ -M5_PATH='${build_dir}/system' \ -$debug_vm \ -'${gem5_dir}/build/X86/gem5.opt' \ -${gem5opts} \ -'${gem5_dir}/configs/example/fs.py' \ + cmd="${gem5_common} \ --command-line='earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/hda $extra_append' \ ---disk-image='${out_dir}/images/rootfs.ext2' \ ---kernel='${out_dir}/build/linux-custom/vmlinux' \ ---num-cpus=${cpus} \ $extra_flags \ " elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then - cmd="\ -M5_PATH='${build_dir}/system' \ -$debug_vm \ -'${gem5_dir}/build/ARM/gem5.opt' \ -${gem5opts} \ -'${gem5_dir}/configs/example/fs.py' \ + cmd="${gem5_common} \ --command-line='earlyprintk=pl011,0x1c090000 console=ttyAMA0 lpj=19988480 rw loglevel=8 mem=512MB root=/dev/sda $extra_append' \ ---disk-image='${out_dir}/images/rootfs.ext2' \ --dtb-file='${gem5_dir}/system/arm/dt/$([ "$arch" = arm ] && echo "armv7_gem5_v1_${cpus}cpu" || echo "armv8_gem5_v1_${cpus}cpu").dtb' \ ---kernel='${out_dir}/build/linux-custom/vmlinux' \ --machine-type=VExpress_GEM5_V1 \ ---num-cpus='${cpus}' \ $extra_flags \ " fi