Skip to content

Instantly share code, notes, and snippets.

@goyalankit
Created November 11, 2014 23:35
Show Gist options
  • Save goyalankit/35915da583c84927f403 to your computer and use it in GitHub Desktop.
Save goyalankit/35915da583c84927f403 to your computer and use it in GitHub Desktop.
#include <papi.h>
#include <stdio.h>
main()
{
int EventCode, retval;
char EventCodeStr[PAPI_MAX_STR_LEN];
/* Initialize the library */
retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT) {
fprintf(stderr, "PAPI library init error!\n");
exit(1);
}
EventCode = 0 | PAPI_NATIVE_MASK;
do {
/* Translate the integer code to a string */
if (PAPI_event_code_to_name(EventCode, EventCodeStr) == PAPI_OK)
/* Print all the native events for this platform */
printf("Name: %s\nCode: %x\n", EventCodeStr, EventCode);
} while (PAPI_enum_event(&EventCode, 0) == PAPI_OK);
int ECode = 0 | PAPI_NATIVE_MASK;
PAPI_event_name_to_code("BR_INST_EXEC.TAKEN_INDIRECT_NEAR_RETURN", &ECode);
printf("Name: %s\nCode: %x\n", "BR_INST_EXEC.TAKEN_INDIRECT_NEAR_RETURN", ECode);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment