Go to the source code of this file.
Define Documentation
Function Documentation
Definition at line 23 of file multiplex.c.
{
int i;
double a = 0.5;
double b = 6.2;
for (i=0; i < n; i++)
c += a * b;
return;
}
| int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 35 of file multiplex.c.
{
int retval, i, EventSet = PAPI_NULL, j = 0;
long long *values;
PAPI_event_info_t pset;
int events[MAX_TO_ADD], number;
retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT)
{
printf("Library initialization error! \n");
exit(1);
}
retval = PAPI_multiplex_init();
if (retval != PAPI_OK)
ERROR_RETURN(retval);
retval = PAPI_create_eventset(&EventSet);
if (retval != PAPI_OK)
ERROR_RETURN(retval);
retval = PAPI_set_multiplex(EventSet);
if (retval != PAPI_OK)
ERROR_RETURN(retval);
for (i = 0; i < PAPI_MAX_PRESET_EVENTS; i++)
{
retval = PAPI_get_event_info(i | PAPI_PRESET_MASK, &pset);
if (retval != PAPI_OK)
ERROR_RETURN(retval);
if ((pset.count) && (pset.event_code != PAPI_TOT_CYC))
{
printf("Adding %s\n", pset.symbol);
retval = PAPI_add_event(EventSet, pset.event_code);
if ((retval != PAPI_OK) && (retval != PAPI_ECNFLCT))
ERROR_RETURN(retval);
if (retval == PAPI_OK)
printf("Added %s\n", pset.symbol);
else
printf("Could not add %s due to resource limitation.\n",
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)
{
printf("Not enough memory available. \n");
exit(1);
}
if ((retval=PAPI_start(EventSet)) != PAPI_OK)
ERROR_RETURN(retval);
do_flops(NUM_ITERS);
retval = PAPI_stop(EventSet, values);
if (retval != PAPI_OK)
ERROR_RETURN(retval);
number=MAX_TO_ADD;
if ( (retval = PAPI_list_events(EventSet, events, &number)) != PAPI_OK)
ERROR_RETURN(retval);
for (i = 0; i < MAX_TO_ADD; i++)
{
retval = PAPI_get_event_info(events[i], &pset);
if (retval != PAPI_OK)
ERROR_RETURN(retval);
printf("Event name: %s value: %lld \n", pset.symbol, values[i]);
}
retval = PAPI_cleanup_eventset(EventSet);
if (retval != PAPI_OK)
ERROR_RETURN(retval);
retval = PAPI_destroy_eventset(&EventSet);
if (retval != PAPI_OK)
ERROR_RETURN(retval);
PAPI_shutdown();
return (0);
}
Variable Documentation