Created
September 21, 2017 11:36
-
-
Save wrathematics/0834c16ead3d4b3668858bfb744ae8d3 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> | |
#define NUM_EVENTS 2 | |
int main() | |
{ | |
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("1+1=%d\n", 1+1); | |
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, values[i]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment