Simulating SPEC2017 on GEM5
Brief Note on Simulating SPEC2017 on GEM5
This is a brief note on how to simulate SPEC2017 on gem5. SPEC2017 has complicated compile scripts. The basic workflow is to compile it, do a fake run to get the arguments for the binary, and finally simulate it in gem5. This is by no means the official instructions or guaranteed to work on your machine. You can also follow the instructions on the official website of SPEC2017.
Compile SPEC2017
First go to the folder of SPEC2017, and set up the environment. This gives you many useful commands to navigate through the SPEC2017, compile and run it.
> source shrc
Here we use lbm_s
as an example. For other workloads it should be similar. Now let’s go to where lbm_s
is:
> go lbm_s
The first thing is to do fake run. This will let the building system set up all the folder, inputs and so on. You can also do a full run, which will take much longer time to finish, but it’s a good way to verify that you SPEC2017 works on your native machine.
# Remove existing build
> rm -r build
> runcpu --fake --config gcc-linux-x86 lbm_s
This should create build
and run
folder. Now let’s compile the program:
> cd build/build_base_mytest-m64.0000
> specmake
This should compile and gives a lbm_s
binary in the folder.
Simulate it in GEM5
First we need to get arguments to run the binary. Go the the run
directory.
> go lbm_s
> cd run/run_base_refspeed_mytest-m64.0000
> specinvoke -n
../run_base_refspeed_mytest-m64.0000/lbm_s_base.mytest-m64 2000 reference.dat 0 0 200_200_260_ldc.of > lbm.out 2>> lbm.err
This gives us the command line arguments to run lbm_s
:
2000 reference.dat 0 0 200_200_260_ldc.of
Now simulate it in gem5. This command will start to simulate lbm_s
using AtomicSimpleCPU
. You can also specify other CPU types and add cache, and there
are detailed instructions here.
> /where/gem5/is/build/X86/gem5.opt \
> /where/gem5/is/configs/example/se.py \
> --cmd=../../build/build_base_mytest-m64.0000/lbm_s \
> --options="2000 reference.dat 0 0 200_200_260_ldc.of" \
> --mem-size=8GB
As an example to simulate using O3 cpu:
> /where/gem5/is/build/X86/gem5.opt \
> /where/gem5/is/configs/example/se.py \
> --cmd=../../build/build_base_mytest-m64.0000/lbm_s \
> --options="2000 reference.dat 0 0 200_200_260_ldc.of" \
> --mem-size=8GB \
> --cpu-type=DerivO3CPU \
> --caches --l2cache \
> --l1d_size=32kB --l1i_size=32kB --l2_size=512kB
Finally, here is how you can fast forward using AtomicSimpleCPU
for 1 million instructions and then switch to DerivO3CPU
:
> /where/gem5/is/build/X86/gem5.opt \
> /where/gem5/is/configs/example/se.py \
> --cmd=../../build/build_base_mytest-m64.0000/lbm_s \
> --options="2000 reference.dat 0 0 200_200_260_ldc.of" \
> --mem-size=8GB \
> --cpu-type=DerivO3CPU \
> --caches --l2cache \
> --l1d_size=32kB --l1i_size=32kB --l2_size=512kB \
> --fast-forward=1000000