Link to home
Start Free TrialLog in
Avatar of pad_anu
pad_anu

asked on

measuring cache misses for a C program



sir
       can u specificy how to measure the cache misses  for a C program
Avatar of Paul Maker
Paul Maker
Flag of United Kingdom of Great Britain and Northern Ireland image

if you mean hardware cache misses that occur when memory items are not in the CPU cache then no - the C run-time provides no such platform specific feature. There may be a low level API for this but i should imagaine it will be CPU specific and only accessible from assembler.

if you mean from within your own data structures then you can code some hit counters quite easily and then report on them before your application exits.

-P
Avatar of joju
joju

ASKER CERTIFIED SOLUTION
Avatar of grg99
grg99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The valgrind program does exactly what you're looking for.  It simulates execution of your binary program, including the behavior of your instruction and data caches, and can produce a summary report for all the memory accesses made by the program.
Forgot the link:  http://valgrind.org/
I'm not quite sure how valgrind can do all this, as there are sooo many different cache strategies in use, some secret.

Also valgrind isnt going to be able to simulate cache losses due the OS and interrupts taking up code and data cache space.

I'd suggest  if you need really accurate results stick with the hardware counters.



SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
They're documented in Appendix A of:

ftp://download.intel.com/design/Pentium4/manuals/25366815.pdf


Really a whole lot of stuff.


Avatar of pad_anu

ASKER

can I use VTune performance analyser tool to measure hardware performance counter
for C programs