int retval, i, EventSet = PAPI_NULL, max_to_add = 6, j = 0;
long_long *values;
PAPI_event_info_t pset;
/* Initialize the library */
retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT)
handle_error(1);
if (PAPI_multiplex_init() != PAPI_OK)
handle_error(1);
if (PAPI_create_eventset(&EventSet) != PAPI_OK)
handle_error(1);
if (PAPI_get_multiplex(EventSet) != 0)
handle_error(1);
if (PAPI_set_multiplex(EventSet) != PAPI_OK)
handle_error(1);
if (PAPI_get_multiplex(EventSet) == 0)
handle_error(1);
for (i = 0; i < PAPI_MAX_PRESET_EVENTS; i++) {
retval = PAPI_get_event_info(i | PRESET_MASK, &pset);
if (retval != PAPI_OK)
test_fail(__FILE__, __LINE__, "PAPI_get_event_info", retval);
if ((pset.count) && (pset.event_code != PAPI_TOT_CYC)) {
if (!TESTS_QUIET)
printf("Adding %s0, pset.symbol);
retval = PAPI_add_event(EventSet, pset.event_code);
if ((retval != PAPI_OK) && (retval != PAPI_ECNFLCT))
test_fail(__FILE__, __LINE__, "PAPI_add_event", retval);
if (!TESTS_QUIET) {
if (retval == PAPI_OK)
printf("Added %s0, pset.symbol);
else
printf("Could not add %s0, pset.symbol);
}
if (retval == PAPI_OK) {
if (++j >= max_to_add)
break;
}
}
}
values = (long_long *)malloc(max_to_add*sizeof(long_long));
if (values == NULL)
handle_error(1);
if (PAPI_start(EventSet) != PAPI_OK)
handle_error(1);