Simple Cache Profiling API

Is there a way to access hardware counters (Intel) for each core programmatically ? (i.e. no perf , perfmon or valgrind , and I have to add "simple", so there is no PAPI , for example), I would like to know (for each core) how many L1-LLC cache hits / misses it (= specific program running on this kernel). This is for Linux 3.2.0-32, C and using GCC.

+6
source share
1 answer

Performance counters in the processor cannot be read from the "user" code, so for this you need some kind of kernel module. Once you have this, it’s not very difficult, there are several MSRs.

Perhaps you can also use / dev / cpu / core -number / msr to read values ​​without a kernel module.

To describe all the details of how you do this is too much to answer (unless I copy the entire section of the Intel programmer's guide (Vol3), which, I think, is not quite what we want here ...)

+1
source

All Articles