int EventCode, EventSet = PAPI_NULL;
int Events[4], number = 4;
/* Create an EventSet */
if (PAPI_create_eventset(&EventSet) != PAPI_OK)
handle_error(1);
/* Convert an event name to an event code */
if (PAPI_event_name_to_code("PAPI_TOT_INS",&EventCode) != PAPI_OK)
handle_error(1);
/* Query if Total Instructions Executed exists */
if (PAPI_query_event(EventCode) != PAPI_OK)
handle_error(1);
/* Add Total Instructions Executed to our EventSet */
if (PAPI_add_event(EventSet, EventCode) != PAPI_OK)
handle_error(1);
/* Convert a second event name to an event code */
if (PAPI_event_name_to_code("PAPI_L1_LDM",&EventCode) != PAPI_OK)
handle_error(1);
/* Query if L1 Load Misses exists */
if (PAPI_query_event(EventCode) != PAPI_OK)
handle_error(1);
/* Add L1 Load Misses to our EventSet */
if (PAPI_add_event(EventSet, EventCode) != PAPI_OK)
handle_error(1);
/* List the events in our EventSet */
number = 4;
if(PAPI_list_events(EventSet, Events, &number);
handle_error(1);
if(number != 2)
handle_error(1);