Lothar
Lothar

Reputation: 13067

How can i access the Intel CPU Counter

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).

Upvotes: 8

Views: 9035

Answers (7)

Shailen
Shailen

Reputation: 8347

Check out the Intel PCM (Performance Counter Monitor) tool which does exactly what you want to do.

Link: https://software.intel.com/en-us/articles/intel-performance-counter-monitor-a-better-way-to-measure-cpu-utilization

Intel PCM provides a rich API that allows you to instrument your code. Furthermore, to date, PCM is the only tool to read uncore events too.

Upvotes: 5

High-thulhu
High-thulhu

Reputation: 3

This thread looks pretty old. But still, all the above mentioned counters are available at Intel PCM .These counters can be used as a Microsoft Perfmon plugin or a command prompt interface. The Intel PCM gives informations like L2 and L3 cache hit ratio, cache misses etc.

Upvotes: 0

ryancox0
ryancox0

Reputation: 41

This thread seems a little old but if you're still interested, I wrote a howto recently on this topic using nothing more than rdmsr and wrmsr in Linux. It only deals with the performance counters on an Intel uncore for Westmere, but the process I described might help you figure out what you need if you haven't already. I'm sure Windows has some equivalent program or function call to RDMSR and WRMSR. The problem is you need to be ring 0 (kernel mode) to read MSRs. I have no idea how to do that in Windows. I won't be able to help with any Windows questions but may be able to answer some MSR-related questions if you have any. I'm by no means an expert though.

Upvotes: 4

Fred Wang
Fred Wang

Reputation: 53

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.

Upvotes: 1

mfawzymkh
mfawzymkh

Reputation: 4108

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]

Upvotes: 0

Stephen Canon
Stephen Canon

Reputation: 106117

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).

Upvotes: 0

Gunther Piez
Gunther Piez

Reputation: 30419

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.

Upvotes: 0

Related Questions