[Ptools-perfapi] Initial Values for PAPI_enum_event?

Doug Pase Doug.Pase at emc.com
Wed Oct 19 12:18:02 EDT 2011


I've been attempting to use the routine PAPI_get_event_info, coding from the example at http://icl.cs.utk.edu/projects/papi/wiki/PAPIC:PAPI_enum_event.3, which is the man page for that routine. The code fragment is incomplete, of course, and specifically it leaves out how to generate the initial value for the first argument (EventCode). I have discovered through experimentation that if I use an initial event code of 0x80000000 everything works just fine.

1) What am I supposed to use to get the first valid event on the list? Searching through every integer from zero through 0xFFFFFFFF seems rather inefficient. Since I'm looking for native events, just "knowing" that 0x8000000 is good also seems like a problem.

2) How do I get a list of NATIVE events? It looks like what I'm getting is a bunch of predefined events rather than the list of native events. At least, every event in the output looks like something out of the PAPI Preset Event Definitions list (http://icl.cs.utk.edu/projects/papi/wiki/PAPIC:Preset_Event_Definitions).

Thanks,

-- Doug

PS., the code looks like this:

#include <stdio.h>
#include <stdlib.h>

#include <papi.h>

#define ARRAY_SIZE      10000
#define DEFAULT_EVENT   PAPI_TOT_INS

int
main(int ac, char*av[])
{
    char errstring[PAPI_MAX_STR_LEN];

    /* This initializes the library and checks the version number of the
    * header file, to the version of the library, if these don't match
    * then it is likely that PAPI won't work correctly.
    */
    int retval;
    if ((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) {
        /* This call loads up what the error means into errstring
        * if retval == PAPI_ESYS then it might be beneficial
        * to call perror as well to see what system call failed
        */
        PAPI_perror(retval, errstring, PAPI_MAX_STR_LEN);
        fprintf(stderr, "Error: %s\n", errstring);
        exit(-1);
    }

    /* Create space for the EventSet */
    int EventSet=PAPI_NULL;
    if ((retval=PAPI_create_eventset( &EventSet )) != PAPI_OK) {
        PAPI_perror(retval, errstring, PAPI_MAX_STR_LEN);
        fprintf(stderr, "Error: %s\n", errstring);
        exit(-1);
    }

    unsigned int i;
    printf("Name\t\t\t       Code\t   Description\n");
    for (i=0x80000000; i < 0xFFFFFFFF; ) {
        PAPI_event_info_t info;
        if (PAPI_get_event_info(i, &info) == PAPI_OK) {
            printf("%-30s 0x%-10x\t%s\n", info.symbol, info.event_code, info.long_descr);
        }
        if (PAPI_enum_event(&i, PAPI_ENUM_ALL) != PAPI_OK) break;
    }

    /* Remove PAPI instrumentation, this is necessary on platforms
    * that need to release shared memory segments and is always
    * good practice.
    */
    PAPI_shutdown();
    exit(0);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.eecs.utk.edu/pipermail/ptools-perfapi/attachments/20111019/6a0a8ac6/attachment.html 


More information about the Ptools-perfapi mailing list