3

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?

Tania
  • 418
  • 3
  • 20

3 Answers3

5

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.

yaman
  • 759
  • 3
  • 17
0

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.

Ciro Santilli
  • 3,693
  • 1
  • 18
  • 44
-1

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 ...
pacholik
  • 8,607
  • 9
  • 43
  • 55
m2sgem5
  • 46
  • 6
  • 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