[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

measuring cache misses for a C program

Posted on 2005-05-02
11
Medium Priority
?
497 Views
Last Modified: 2013-11-15


sir
       can u specificy how to measure the cache misses  for a C program
0
Comment
Question by:pad_anu
9 Comments
 
LVL 10

Expert Comment

by:makerp
ID: 13915722
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
 
LVL 3

Expert Comment

by:joju
ID: 13915860
0
 
LVL 22

Accepted Solution

by:
grg99 earned 252 total points
ID: 13916785
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 22

Expert Comment

by:NovaDenizen
ID: 13917441
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
 
LVL 22

Expert Comment

by:NovaDenizen
ID: 13917449
Forgot the link:  http://valgrind.org/
0
 
LVL 22

Expert Comment

by:grg99
ID: 13918642
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
 
LVL 22

Assisted Solution

by:NovaDenizen
NovaDenizen earned 248 total points
ID: 13922052
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
 
LVL 22

Expert Comment

by:grg99
ID: 13922978
They're documented in Appendix A of:

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


Really a whole lot of stuff.


0
 

Author Comment

by:pad_anu
ID: 13933244
can I use VTune performance analyser tool to measure hardware performance counter
for C programs
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question