I have a program which uses perf_event.h to calculate the IPC of a specific running process. I read the INSTRUCTIONS counter and the CPU_CYCLES counter to do so.
My question is about the value returned by the INSTRUCTIONS counter. Does it contain the floating-point operations? If not, how can I get this value?
Note: I'm talking about perf_event.h but, yes, I'm also talking about
perf
and the counters I mentioned are the ones you can find with the commandperf list
.
On Intel architectures (I guess it's the same for others), yes it contains floating-point instructions . If you look at
arch/x86/kernel/cpu/perf_event_intel.c
in kernel code. You will see that theinstructions
event is mapped to0x00c0
:The Intel Software Developer Manual Chapter 19.1 says that this event counts
Instruction retired
, that is all instructions completed that were "proven" as indeed needed by flow (Modern processors execute much more instructions that the program flow needs. This is called "speculative execution", see here)