I am running a small matrix multiplication program in gem5 simulation environment and want to measure execution time of the program. The program is in Fortran and I use cpu_time before and after the matrix multiplication routine to get the time. But is there any other better way to measure time in the gem5 environment?
3 Answers
The standard way of measuring stats for a given binary using gem5 in Full System mode is through providing an rcS script using the --script parameter:
./build/ARM/gem5.fast ... your_options... --script=./script.rcS
Your script should contain m5ops to reset and dump stats as required. An example script.rcS:
m5 resetstats
/bin/yourbinary
m5 dumpstats
Then from the stats.txt you can take execution time (sim_seconds) or whatever stat that you require. If you're using the Syscall Emulation mode you can directly check the stats.txt without the need for an rcS script.

- 759
- 3
- 17
-
Thanks for your response. I am using Syscall Emulation mode. I will check out stats.txt and will let you know. – Tania Nov 18 '15 at 02:46
-
Got it. I will use sim_seconds now. Thanks a lot. – Tania Nov 18 '15 at 02:53
You can also add resetstats / dumpstats magic assembly instructions directly inside your benchmarks as shown at: How to count the number of CPU clock cycles between the start and end of a benchmark in gem5? E.g. in aarch64:
/* resetstats */
__asm__ __volatile__ ("mov x0, #0; mov x1, #0; .inst 0XFF000110 | (0x40 << 16);" : : : "x0", "x1")
/* dumpstats */
__asm__ __volatile__ ("mov x0, #0; mov x1, #0; .inst 0xFF000110 | (0x41 << 16);" : : : "x0", "x1")
You then likely want to look at the system.cpu.numCycles
which shows how many CPU ticks passed.

- 3,693
- 1
- 18
- 44
You can of course look into different stat files depending on your build but I think the easiest way is to flag time before your simulation command:
time ./build/ARM/gem5.fast ... your_options... --script=./script.rcS ...
-
This measures the time it takes for the simulator to run, not the time for the simulated binary... – yaman Sep 29 '16 at 19:46