Is it possible to have/use more than one EventSet? In my case, I have to monitor different events but I need to start and stop them at different times (start and stop events independently from the start and stop of other events). The idea I was thinking about is to have more than one EventSet, but it doesn't seem to work properly. Even when I have declared and initialized 2 EventSets (iEventSet1, iEventSet2), at the start(iEventSet1) point, also the events of iEventSet2 are started..., receiving in that case an error, when starting the counters of iEventSet2.
- Code: Select all
long long value1, value2;
int iEventSet1=PAPI_NULL, iEventSet2=PAPI_NULL;
int retval;
retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT)
{
PAPI_perror (retval, NULL, 0);
return -1;
}
retval = PAPI_create_eventset(&iEventSet1);
if (retval != PAPI_OK)
{
printf ("Error creating EventSet1\n");
return -1;
}
retval = PAPI_create_eventset(&iEventSet2);
if (retval != PAPI_OK)
{
printf ("Error creating EventSet2\n");
return -1;
}
retval = PAPI_add_named_event(iEventSet1, "PAPI_TOT_INS");
if (retval != PAPI_OK)
{
printf ("Error adding PAPI_TOT_INS\n");
return -1;
}
printf ("Eventsets: %d %d\n", iEventSet1, iEventSet2);
retval = PAPI_add_named_event(iEventSet2, "PAPI_FP_INS");
if (retval != PAPI_OK)
{
printf ("Error adding PAPI_FP_INS\n");
return -1;
}
retval = PAPI_start(iEventSet1);
if (retval != PAPI_OK)
{
printf ("Error starting iEventSet1\n");
return -1;
}
retval = PAPI_start(iEventSet2);
if (retval != PAPI_OK)
{
printf ("Error starting iEventSet2 %d\n", retval);
return -1;
}
retval = PAPI_stop(iEventSet1, &value1);
if (retval != PAPI_OK)
{
printf ("Error stopping iEventSet1\n");
return -1;
}
retval = PAPI_stop(iEventSet2, &value2);
if (retval != PAPI_OK)
{
printf ("Error stopping iEventSet2\n");
return -1;
}
printf ("Value1: %ld Value2: %ld\n", value1, value2);
PAPI_shutdown();
}
The resulting output is:
- Code: Select all
EventSets: 0 1
Error starting iEventSet2 -10
Thanks in advance.
Best regards,