C Interface
#include <papi.h>
int PAPI_read_counters(long_long *values, int array_len);
int PAPI_accum_counters(long_long *values, int array_len);
Fortran Interface
#include fpapi.h
PAPIF_read_counters(C_LONG_LONG(*) values, C_INT array_len, C_INT check)
PAPIF_accum_counters(C_LONG_LONG(*) values, C_INT array_len, C_INT check)
int Events[2] = { PAPI_TOT_CYC, PAPI_TOT_INS };
long_long values[2];
int num_hwcntrs = 0;
if ((num_hwcntrs = PAPI_num_counters()) != PAPI_OK)
handle_error(1);
if (num_hwcntrs > 2)
num_hwcntrs = 2;
/* Start counting events */
if (PAPI_start_counters(Events, num_hwcntrs) != PAPI_OK)
handle_error(1);
your_slow_code();
/* Start counting events */
if (PAPI_read_counters(values, num_hwcntrs) != PAPI_OK)
handle_error(1);