gem5: namespace checkpoints by arch

Also refactor common gem5 x86 and arm command parts
This commit is contained in:
Ciro Santilli
2018-03-13 13:06:33 +00:00
parent 29c3362015
commit 13e840df9e
2 changed files with 38 additions and 27 deletions

View File

@@ -1791,7 +1791,7 @@ These commands output the approximate number of CPU cycles it took Dhrystone to
It works like this: It works like this:
* the first commond boots linux with the default simplified `AtomicSimpleCPU`, and generates a <<gem5-checkpoint,checkpoint>> after the kernel boots and before running the benchmark * the first command boots linux with the default simplified `AtomicSimpleCPU`, and generates a <<gem5-checkpoint,checkpoint>> 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. * 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 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 <<snapshot>>, but better since it can be started from inside
Documentation: http://gem5.org/Checkpoints 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 m5 checkpoint
@@ -2279,7 +2279,7 @@ m5 checkpoint
To restore the checkpoint, kill the VM and run: 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: 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`. 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 <<kernel-command-line-parameters>> as in: If you automate things with <<kernel-command-line-parameters>> 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. 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 restore checkpoint with a different CPU
gem5 can switch to a different CPU model when restoring a checkpoint. gem5 can switch to a different CPU model when restoring a checkpoint.

38
run
View File

@@ -74,35 +74,37 @@ out_dir="${root_dir}/buildroot/output.${arch_dir}~"
if "$gem5"; then if "$gem5"; then
build_dir="${out_dir}/build/gem5-1.0" build_dir="${out_dir}/build/gem5-1.0"
gem5_dir="${build_dir}/gem5" 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 [ "$arch" = x86_64 ]; then
if "$kvm"; then if "$kvm"; then
extra_flags="$extra_flags --cpu-type=X86KvmCPU" extra_flags="$extra_flags --cpu-type=X86KvmCPU"
fi fi
cmd="\ cmd="${gem5_common} \
M5_PATH='${build_dir}/system' \
$debug_vm \
'${gem5_dir}/build/X86/gem5.opt' \
${gem5opts} \
'${gem5_dir}/configs/example/fs.py' \
--command-line='earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/hda $extra_append' \ --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 \ $extra_flags \
" "
elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then
cmd="\ cmd="${gem5_common} \
M5_PATH='${build_dir}/system' \
$debug_vm \
'${gem5_dir}/build/ARM/gem5.opt' \
${gem5opts} \
'${gem5_dir}/configs/example/fs.py' \
--command-line='earlyprintk=pl011,0x1c090000 console=ttyAMA0 lpj=19988480 rw loglevel=8 mem=512MB root=/dev/sda $extra_append' \ --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' \ --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 \ --machine-type=VExpress_GEM5_V1 \
--num-cpus='${cpus}' \
$extra_flags \ $extra_flags \
" "
fi fi