I am trying to do a fairly straightforward and simple measurement using PAPI. There is a function that I want to profile and I use the high-level API to start and end the region that I want to profile, but after my program ends no output file is generated and I get the error “PAPI-HL Warning: Cannot generate output due to not matching regions.”
This is the code I am using to profile
void handle_error (int retval)
{
printf("PAPI error %d: %s\n", retval, PAPI_strerror(retval));
exit(1);
}
int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
{
// ...
int retval = PAPI_hl_region_begin("computation");
if ( retval != PAPI_OK )
handle_error(retval);
/* Do some computation here */
int ret = __epoll_wait(epfd, events, maxevents, timeout);
retval = PAPI_hl_region_end("computation");
if ( retval != PAPI_OK )
handle_error(retval);
// ...
}
The epoll_wait function gets called multiple times. I don’t know if it’s an issue when using PAPI to call PAPI_hl_region_begin(“computation”) and PAPI_hl_region_end(“computation”) multiple times. I thought that might be an issue because when I add an exit(0) call immediately after PAPI_hl_region_end the output is generated properly. How can I use the PAPI API to have multiple regions (each used to profile a different function), where each function may be called multiple times?