C Interface
#include <papi.h>
int PAPI_perror(int code, char *destination, int length);
char *PAPI_strerror(int code);
Fortran Interface
#include fpapi.h
PAPIF_perror(C_INT code, C_STRING destination, C_INT check)
int EventSet = PAPI_NULL;
int native = 0x0;
char error_str[PAPI_MAX_STR_LEN];
if ((retval = PAPI_create_eventset(&EventSet)) != PAPI_OK)
{
fprintf(stderr, "PAPI error %d: %s\n",retval,PAPI_strerror(retval));
exit(1);
}
/* Add Total Instructions Executed to our EventSet */
if ((retval = PAPI_add_event(EventSet, PAPI_TOT_INS)) != PAPI_OK)
{
PAPI_perror(retval,error_str,PAPI_MAX_STR_LEN);
fprintf(stderr,"PAPI_error %d: %s\n",retval,error_str);
exit(1);
}
/* Start counting */
if ((retval = PAPI_start(EventSet)) != PAPI_OK)
handle_error(retval);