measuring cache misses for a C program



sir
       can u specificy how to measure the cache misses  for a C program
pad_anuAsked:
Who is Participating?
 
grg99Connect With a Mentor Commented:
The Pentium chips have a large set of built-in counters that can be directed to count all kinds of very low-level events, such as cache misses.   They're hard to access, but there are many helper functions available:

If you're doing this on LInux, pls see:

http://www.eg.bucknell.edu/~bsprunt/emon/brink_abyss/brink_abyss.shtm


For Windows:

http://www.microsoft.com/resources/documentation/windowsnt/4/workstation/reskit/en-us/03tools.mspx

0
 
makerpCommented:
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
0
 
jojuCommented:
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
NovaDenizenCommented:
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.
0
 
NovaDenizenCommented:
Forgot the link:  http://valgrind.org/
0
 
grg99Commented:
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.



0
 
NovaDenizenConnect With a Mentor Commented:
This page describes how valgrind's "cachegrind" subsystem performs cache analysis:  http://valgrind.org/docs/manual/cg_main.html#cg-top
extra-detailed information here:  http://valgrind.org/docs/manual/cg_techdocs.html

grg99,
How do you get to the actual hardware counters?
0
 
grg99Commented:
They're documented in Appendix A of:

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


Really a whole lot of stuff.


0
 
pad_anuAuthor Commented:
can I use VTune performance analyser tool to measure hardware performance counter
for C programs
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.