riscv-software-src / riscv-isa-sim

Spike, a RISC-V ISA Simulator
Other
2.38k stars 839 forks source link

issue in counting numbers of instructions #1686

Closed Sanoj-S-Vijendra closed 3 months ago

Sanoj-S-Vijendra commented 4 months ago

So, I have to count the number of instruction executed in the region of interest of my cpp code using this spike simulator. I have defined the region of interest as :


static inline __attribute__((always_inline)) void Start_ROI()
{
   __asm__ volatile("srai zero, zero, 0");
}

my required code

static inline __attribute__((always_inline)) void End_ROI()
{
   __asm__ volatile("srai zero, zero, 1");
}

How to do this?

jerryz123 commented 3 months ago

There's many examples of code sequences which do this. For instance, the benchmarks in https://github.com/riscv-software-src/riscv-tests