Skip to content

Instantly share code, notes, and snippets.

@wrathematics
Created September 21, 2017 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wrathematics/0834c16ead3d4b3668858bfb744ae8d3 to your computer and use it in GitHub Desktop.
Save wrathematics/0834c16ead3d4b3668858bfb744ae8d3 to your computer and use it in GitHub Desktop.
#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