【问题标题】:What is the best way to measure time in gem5 simulation environment在gem5模拟环境中测量时间的最佳方法是什么
【发布时间】:2019-06-11 16:08:35
【问题描述】:

我正在 gem5 模拟环境中运行一个小型矩阵乘法程序,并想测量程序的执行时间。该程序在 Fortran 中,我在矩阵乘法例程之前和之后使用 cpu_time 来获取时间。但是在 gem5 环境中还有其他更好的方法来测量时间吗?

【问题讨论】:

    标签: gem5


    【解决方案1】:

    在完整系统模式下使用 gem5 测量给定二进制文件的标准方法是通过使用 --script 参数提供 rcS 脚本:

    ./build/ARM/gem5.fast ... your_options... --script=./script.rcS
    

    您的脚本应包含 m5ops 以根据需要重置和转储统计信息。一个示例 script.rcS:

    m5 resetstats
    /bin/yourbinary
    m5 dumpstats
    

    然后,您可以从 stats.txt 获取执行时间 (sim_seconds) 或您需要的任何统计信息。如果您使用的是 Syscall Emulation 模式,您可以直接检查 stats.txt 而无需 rcS 脚本。

    【讨论】:

    • 感谢您的回复。我正在使用系统调用仿真模式。我会查看 stats.txt 并通知您。
    • 知道了。我现在将使用 sim_seconds。非常感谢。
    【解决方案2】:

    您还可以直接在基准测试中添加 resetstats / dumpstats 魔术汇编指令,如下所示:How to count the number of CPU clock cycles between the start and end of a benchmark in gem5? E.g.在 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")
    

    然后您可能想查看system.cpu.numCycles,它显示了经过的 CPU 滴答数。

    【讨论】:

      【解决方案3】:

      您当然可以根据您的构建查看不同的统计文件,但我认为最简单的方法是在您的模拟命令之前标记时间:

      time ./build/ARM/gem5.fast ... your_options... --script=./script.rcS ...
      

      【讨论】:

      • 这衡量的是模拟器运行所需的时间,而不是模拟二进制文件的时间...
      猜你喜欢
      • 1970-01-01
      • 2019-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-20
      • 1970-01-01
      • 1970-01-01
      • 2020-03-03
      相关资源
      最近更新 更多