Created
February 15, 2016 14:15
-
-
Save zeptometer/f9b8c521c7483b1ae480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* PAPI wrappers | |
*/ | |
#define NUM_EVENTS 5 | |
int papi_events[] {PAPI_TOT_CYC, PAPI_TOT_INS, PAPI_L1_DCM, PAPI_L2_DCM, PAPI_L2_DCA}; | |
long long int papi_counters[NUM_EVENTS]; | |
void | |
start_papi_counter() | |
{ | |
const int status = PAPI_start_counters(papi_events, NUM_EVENTS); | |
if (status != PAPI_OK) | |
{ | |
fprintf(stderr, "Cannot start PAPI Counters (%d, %s)\n", status, PAPI_strerror(status)); | |
exit(EXIT_FAILURE); | |
} | |
} | |
void | |
stop_papi_counter() | |
{ | |
PAPI_stop_counters(papi_counters, NUM_EVENTS); | |
for (int i = 0; i < NUM_EVENTS; i++) { | |
char event_name[PAPI_MAX_STR_LEN]; | |
PAPI_event_code_to_name(papi_events[i], event_name); | |
printf("%12s : %llu\n", event_name, papi_counters[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment