views:

440

answers:

5

Is there any small tool that gives me access to the data gathered by the Intel CPU Counters (like L1/L2 cache misses, branch prediction failures ... you know there are hunderts of them on modern Core2 CPU's).

It must work on Windows (while being able to use it with Solaris, FreeBSD, Linux, MacOSX would of course be nice).

A: 

My first though was to look up the What every programmer should know about memory article series to see if there were any references to source code used (to see if I could find any examples) although I did not see any right away. Nevertheless I assume you will find those articles interesting in any case.

hlovdal
Thanks yes i browsed this paper this morning. Nice and informative but nothing in it about the CPU support.
Lothar
+1  A: 

You didn't write of your are looking for a application or for a library.

For Windows there is Intel VTune. But this not exactly an small tool. For linux I have used oprofile, which works without kernel patches.

drhirsch
I'm looking for a library because i want to write an instrumenting profiler that records INSTRUCTION_RETIRED events instead of milliseonds. Yes and maybe some other things, so you can see it as a small VTune like tool i want to write myself.
Lothar
I don't think there is a library. The Performance Monitor Register are accessed via rdmsr and wrmsr instructions.For a start you may look at the "Intel 64 and IA-32 Architectures Software Developers Manual" (google for the latest version) Volume 3B, Chapter 18.11ff. There is exactly described what you do need to access the Performance Counters.
drhirsch
A: 

On OS X, Shark lets you get data from the PMCs. I'm not sure what's available on Windows other than Intel's tools (VTune, as mentioned by drhirsch).

Stephen Canon
A: 

Try this http://icl.cs.utk.edu/papi/ It is a full library that allows you to read any CPU counters data, works both on Windows and Linux [and other OS]

mfawzymkh
A: 

PAPI is a very promising lead, however, I believe they discontinued support for Windows (and therefore .NET C#) quite a few years ago.

On the windows front, Visual Studio 2010 Premium comes with performance explorer. If you run any project or binary in instrumentation mode, you can get access to hardware events such as instructions retired.

The results can be somewhat mixed and inconsistent depending external factors, but it integrates with Visual Studio nicely and you get detailed counts (avg, maximum, total) on a per method/module level.

Intel V-tune performance analyzer also exposes these natively. I haven't played with this tool yet but it might be a more flexible API than what Visual Studio 2010 exposes.

Fred Wang
Thanks but i'm in the business to develop and sell IDE's myself. So this obviously does not help me.
Lothar