API for system-wide IPC profiling

Open discussion of PAPI.

API for system-wide IPC profiling

Postby thnbp24 » Tue Oct 21, 2014 12:21 am

Hi,

I would like to collect system-wide IPC. (The aggregate IPC across all CPUs).
But the provided high-level API does not seem to have this feature.
The functionality would be similar to perf "-a" options.
Since I need to read the counters within my code, I am trying to use PAPI to do that.
PAPI_set_granularity seems to be relevant. But I cannot find any examples.
Could anyone provide me some pointers?
Thanks!
thnbp24
 
Posts: 2
Joined: Mon Oct 20, 2014 11:45 pm

Re: API for system-wide IPC profiling

Postby jagode00 » Tue Oct 28, 2014 5:05 pm

You can find an example on how to use PAPI_set_granularity here:
http://icl.cs.utk.edu/projects/papi/wik ... nularity.3


To collect system-wide IPC, you should be able to do something like the following:

#include <stdio.h>
#include <stdlib.h>
#include "papi.h"

int main(void) {
int ret = 0;
int set = PAPI_NULL;

long long value;

ret = PAPI_library_init(PAPI_VER_CURRENT);
if (PAPI_VER_CURRENT != ret) {
fprintf(stderr,"PAPI library version mismatch.\n");
exit(1);
}

ret = PAPI_set_granularity(PAPI_GRN_SYS);
if (PAPI_OK != ret) {
fprintf(stderr,"PAPI_set_granularity\n");
exit(1);
}
ret = PAPI_create_eventset(&set);
if (PAPI_OK != ret) {
fprintf(stderr,"PAPI_create_eventset.\n");
exit(1);
}
....

}


I haven't tested it myself. Let us know if this works for you.
Heike
jagode00
 
Posts: 41
Joined: Tue Aug 25, 2009 2:12 pm

Re: API for system-wide IPC profiling

Postby thnbp24 » Thu Oct 30, 2014 2:57 pm

Hi Heike,

Thank you for your response.
I found the example but the problem is that it does not support PAPI_GRN_SYS on my platform.
In fact, for the PAPI version that I use (5.3.2), only the PAPI_GRN_THR granularity available across all platforms.
It is the only parameter in ".available_granularities = PAPI_GRN_THR".
Therefore, I failed to set granularity other than PAPI_GRN_THR.
I wonder why this is the case?
My CPU is Intel(R) Core(TM) i7-4820K CPU @ 3.70GHz
Thanks in advance.
thnbp24
 
Posts: 2
Joined: Mon Oct 20, 2014 11:45 pm

Re: API for system-wide IPC profiling

Postby jagode00 » Tue Nov 04, 2014 2:35 pm

I've tested it myself and also confirmed with Vince Weaver:
The PAPI / perf_event component does not support PAPI_GRN_SYS.

Here is a snippet from another PAPI email discussion from last year:
perf_event doesn't really support this directly either. For example,
the "perf stat -a" (measure on all CPUs) command actually opens the
same eventset on all cpus [so on a 4-cpu system it calls
sys_perf_event_open() 4 times, once on each CPU] and then aggregates the
results at the end.

Bottom line, if you want the total IPC across the whole system you need to add the events per core and then need to add them up yourself.

Vince also included a test to the perf_event component that checks for different granularities:
src/components/perf_event/tests/perf_event_system_wide.c

Here is the output on our IvyBridge:
$: src/components/perf_event/tests>./perf_event_system_wide

Trying PAPI_TOT_CYC with different domains:
PAPI_DOM_USER: 181262504
PAPI_DOM_USER|PAPI_DOM_KERNEL: 181209376
PAPI_DOM_ALL: 186029295

Trying different granularities:
PAPI_GRN_THR: 181992579
PAPI_GRN_PROC: Unable to set PAPI_GRN_PROC
PAPI_GRN_SYS: Error trying to add PAPI_TOT_CYC
PAPI_GRN_SYS_CPU: Unable to set PAPI_GRN_SYS_CPU

PAPI_GRN_SYS plus CPU attach:
GRN_SYS, DOM_USER, CPU 0 attach: perf_event_system_wide.c SKIPPED
Line # 499
Invalid permissions for this test; trying to CPU_ATTACH; need to run as root.
jagode00
 
Posts: 41
Joined: Tue Aug 25, 2009 2:12 pm


Return to General discussion (read-only)

Who is online

Users browsing this forum: No registered users and 3 guests

cron