I need help! how to use PAPI to read performance counters?

Open discussion of PAPI.

I need help! how to use PAPI to read performance counters?

Postby kakagou » Fri Sep 18, 2009 7:41 am

i want to use PAPI to read CORE2 CPU performance counters, when the cpu is runing programs
i want to read the counters one time each second,i write program to read the counters, but i doesn't work
the basic structure of the program is following:

main()
{
...
while(1){
PAPI_start(eventset);//start counters
sleep(1);
PAPI_stop(eventset, values)//read counters
}
}

i find that if the program go to sleep, the value of the counter will not increase. why ?
kakagou
 
Posts: 3
Joined: Fri Sep 18, 2009 7:30 am

Re: I need help! how to use PAPI to read performance counters?

Postby cjashfor » Sat Sep 19, 2009 2:59 am

kakagou wrote:i find that if the program go to sleep, the value of the counter will not increase. why ?


PAPI keeps track of events counts on a per-thread basis. If the thread is sleeping, no (or very few) counts will be attributed to that thread.

If you want to see counts, give the processor something to do, like 10 million loops where you are multiplying two floating point numbers together and summing the result.
cjashfor
 
Posts: 6
Joined: Wed Aug 26, 2009 2:25 am

Re: I need help! how to use PAPI to read performance counters?

Postby kakagou » Sun Sep 20, 2009 4:47 am

thank you!

now I am going to write a program to read counter values periodically, for example one time per second,
the program is used to get the counter values of bechmarks
Since PAPI is based on per-thread, how I get the values of the bechmark ?
kakagou
 
Posts: 3
Joined: Fri Sep 18, 2009 7:30 am

Re: I need help! how to use PAPI to read performance counters?

Postby cjashfor » Tue Sep 22, 2009 3:57 pm

kakagou wrote:thank you!

now I am going to write a program to read counter values periodically, for example one time per second,
the program is used to get the counter values of bechmarks
Since PAPI is based on per-thread, how I get the values of the bechmark ?


So you are going to monitor the benchmark using a separate thread (or process) ?

If so, you will need to use the PAPI_attach() call. I don't have much experience using it, though, so I'd just refer you to the documentation on PAPI_attach().
cjashfor
 
Posts: 6
Joined: Wed Aug 26, 2009 2:25 am

Re: I need help! how to use PAPI to read performance counters?

Postby yuzhibin » Sun Nov 15, 2009 2:17 am

Hi
I also want to do the same thing. Ouptut the performance counters every seconds when a benchmark is running.
I use fork and exec to call the benchmark on the command line. in code, i use PAPI_attach to attach an event set to the called process. It can work correctly as long as the called process terminated normally. However, i always get 0 values if i want to output the counters every second or kill the called process.

Best regards,
Zhibin :roll:
yuzhibin
 
Posts: 4
Joined: Sun Nov 15, 2009 1:56 am


Return to General discussion

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

cron