Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

Can't use PCM

korso
Beginner
2,525 Views
Hello,
I'm trying to use Intel Performance Counter Monitor to measure L2 and L3 cache hit ratio in a custom code. I'm trying to follow the example snippet in website, but I obtain the following error when I try to initialize processor counters:
[bash]Probando Intel PCM Num (logical) cores: 4 Num sockets: 1 Threads per core: 1 Core PMU (perfmon) version: 3 Number of core PMU generic (programmable) counters: 4 Width of generic (programmable) counters: 48 bits Number of core PMU fixed counters: 3 Width of fixed counters: 48 bits Nominal core frequency: 2799999993 Hz LLEGA a crear instancia WARNING: Core 1 IA32_PERFEVTSEL0_ADDR are not zeroed 1114660 mpedrero@huracan:~/Dropbox/uma/padding/IPC$ [/bash]
And my code:
[bash]#include "cpucounters.h" #include #define F 10000 #define C 10000 using namespace std; int main(){ cout<<"Probando Intel PCM\n"<program() != PCM::Success) return -1; cout<<"Llega a programar contadores"<; for(int i=0;i = 1.0; } } // End of custom code SystemCounterState after_sstate = getSystemCounterState(); cout << "RESULTADOS:"<
The problematic line is:
[bash]if (m->program() != PCM::Success) return -1; [/bash]
The rest of executables provided in PCM download (like pcm.x, pcm-sensor.x work seamlessy)
Any advice? It's almost copied to this page code:
Thanks in advance!
PD: I can't find any documentation for PCM. It's available anywhere?
PD2: My system is a i7 860 with Ubuntu 10.04 x86_64
0 Kudos
28 Replies
Bingyi_C_
Beginner
644 Views

Also, because I would like to get the cache miss rate from PCM for each Query in the MonetDB system. There are two ways for me to do it. The first way is to insert the following code:

PCM *m = PCM::getInstance();
m->program (PCM::DEFAULT_EVENTS, NULL);
SystemCounterState before_sstate = getSystemCounterState();

To the monetdb System. However, since the monetdb is in c not c++. So I have to change the source code in PCM a lot...So I decide to get an executable file and call the executable file in my python script. So I add some functions in the cpucounters.h file and make sure I can get the value of a few counters each time and I plan to use them to calculate the cache miss/hit rate. The executable is generated from the following c file:

#include "/local/homes/bingyiloc/IntelPerformanceCounterMonitorV2.5.1/cpucounters.h"

using namespace std;
int

main(){
PCM *m = PCM::getInstance();
m->program (PCM::DEFAULT_EVENTS, NULL);
SystemCounterState before_sstate = getSystemCounterState();
cout << "get L2Miss"<<getL2Miss(before_sstate)<<endl;
cout << "get L2Re"<<getL2Ref(before_sstate)<<endl;
cout << "get L3Miss"<<getL3Miss(before_sstate)<<endl;
cout << "get L3UnsharedHit"<<getL3UnsharedHit(before_sstate)<<endl;
cout << "get L2HitM"<<getL2HitM(before_sstate)<<endl;
cout << "get L2Hit"<<getL2Hit(before_sstate)<<endl;
m->cleanup();

}

I would like to get the value of the parameter and then calculate it the same way in the getL2CacheMiss and etc function. Is that reasonable? Or everytime new the instance PCM is not a good way to calculate?

0 Kudos
Bingyi_C_
Beginner
644 Views

Thanks Patrick. I did the check it before it is normal. When I check it now, I always get the error code 2. It doesn't go way even when I reboot the machine.

0 Kudos
Patrick_F_Intel1
Employee
644 Views

That would be a good start.

It is possible that something else is running which is using the PMU registers.

Pat

0 Kudos
Rolf_Andersson
Beginner
644 Views

have a look at:

http://software.intel.com/en-us/forums/topic/404048

Roman suggests that this is a feature and I think he refers to the fact someone may indeed be using PMU regs. If you know you are alone on the machine you can always try to run: "pcm.x "sleep 1" which will tell you that the PMU is busy and ask you if you want to reset. Answer "y" and then re-run your program. I also suggest that you also add an error printout and exit if the "m->program ()" call returns an error.

Rolf

0 Kudos
Bingyi_C_
Beginner
644 Views

Thank you guys for the help. I solved the problem for the L2&L3 hit ratio. I have another question. Does PCM provide support to get the L1 cache hit/miss ratio? I googled and didn't get very much information. From the cpucounter.h and cpucounter.cpp file, I didn't see any performance counter for L1 cache hit/miss. Thanks again!

0 Kudos
Anikaushik
Beginner
644 Views

Hi,

I was able to run a couple of examples of using the PCM library in my custom code. However, there is a concern that I hope can be addressed: my understanding of using the PCM library inside a custom c/c++ code is to evaluate the custom code's measurements such as L2 cache misses, bytes read/written to MC and so on. Is this correct? The reason why I am asking is because I have a piece of code that does 2 calls to getSystemCounterState() and in between these calls, there is no code. When I measure statistics such getBytesReadFromMC(), I get a non-zero value when I expect a zero value because there is no activity happening between these calls to measure. What does the non-zero value indicate?

Thanks,

0 Kudos
Bernard
Valued Contributor I
644 Views

Maybe between those two calls your thread was swapped out and another thread was scheduled to run.

0 Kudos
Roman_D_Intel
Employee
644 Views

Anikaushik,

the memory controller counters are shared by many cores in the system. These cores are issuing memory operations while your thread is not doing anything. Also PCM API calls (like getSystemCounterState) are performing some small number of memory operations themselves (a measurement overhead).

Thanks,

Roman

0 Kudos
Reply