Created
September 21, 2017 13:28
-
-
Save wrathematics/c6b374f3c466621c170cc4451f8c34c2 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
#include <stdio.h> | |
#include <papi.h> | |
#include <stdlib.h> | |
#define NUM_EVENTS 2 | |
int main(int argc, char **argv) | |
{ | |
int a = atoi(argv[1]); | |
int b = atoi(argv[2]); | |
int events[NUM_EVENTS] = {PAPI_L1_DCM, PAPI_L2_DCM}; | |
long long values[NUM_EVENTS]; | |
PAPI_library_init(PAPI_VER_CURRENT); | |
PAPI_start_counters(events, NUM_EVENTS); | |
printf("%d+%d=%d\n", a, b, a+b); | |
PAPI_read_counters(values, NUM_EVENTS); | |
PAPI_stop_counters(values, NUM_EVENTS); | |
for (int i=0; i<NUM_EVENTS; i++) | |
printf("L%d Cache Misses: %lld\n", i+1, values[i]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment