23int main (
int argc,
char **argv)
26 int retval,cid,rapl_cid=-1,numcmp;
29 int i,code,enum_retval;
33 double elapsed_time,total_time;
39 fprintf(
stderr,
"PAPI_library_init failed\n");
45 for(cid=0; cid<numcmp; cid++) {
48 fprintf(
stderr,
"PAPI_get_component_info failed\n");
52 if (strstr(cmpinfo->
name,
"powercap")) {
54 printf(
"Found rapl component at cid %d\n", rapl_cid);
57 fprintf(
stderr,
"No rapl events found: %s\n",
67 fprintf(
stderr,
"No powercap component found\n");
76 while ( enum_retval ==
PAPI_OK ) {
80 printf(
"Error translating %#x\n",code);
92 printf(
"Error getting event info for %#x\n",code);
116 printf(
"Error! No RAPL events found!\n");
133 fprintf(
stderr,
"Error creating eventset!\n");
154 fprintf(
stderr,
"PAPI_start() failed\n");
165 fprintf(
stderr,
"PAPI_start() failed\n");
168 total_time=((double)(
after_time-start_time))/1.0e9;
174 if (strstr(
events[
i],
"ENERGY")) {
175 fprintf(
fff[
i],
"%.4f %.3f %s %.3f %s (* Average Power for %s *)\n",
177 ((
double)
values[
i]/1.0e6),
"J",
178 ((
double)
values[
i]/1.0e6)/elapsed_time,
"W",
181 else if (strstr(
events[
i],
"POWER")) {
182 fprintf(
fff[
i],
"%.4f %.3f %s (* %s *)\n",
184 ((
double)
values[
i]/1.0e6),
"W",
187 else if (strstr(
events[
i],
"TIME")) {
188 fprintf(
fff[
i],
"%.4f %.3f %s (* %s *)\n",
190 ((
double)
values[
i]/1.0e6),
"S",
194 fprintf(
fff[
i],
"%.4f %lld (* %s *)\n",
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI EventSet.
Enumerate PAPI preset or native events for a given component.
Convert a numeric hardware event code to a name.
get information about a specific software component
Get the event's name and description info.
Get real time counter value in nanoseconds.
initialize the PAPI library.
Get the number of components available on the system.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
char event_name[2][PAPI_MAX_STR_LEN]
static long long values[NUM_EVENTS]
Return codes and api definitions.
char events[MAX_EVENTS][BUFSIZ]
int data_type[MAX_EVENTS]
char filenames[MAX_EVENTS][BUFSIZ]
char units[MAX_EVENTS][BUFSIZ]
static long long after_time
static long long before_time
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
char units[PAPI_MIN_STR_LEN]