PAPI_state.c File Reference

Include dependency graph for PAPI_state.c:

Go to the source code of this file.

Defines

#define ERROR_RETURN(retval)   { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }

Functions

int main ()
int printstate (int status)

Define Documentation

#define ERROR_RETURN ( retval   )     { fprintf(stderr, "Error %d %s:line %d: \n", retval,__FILE__,__LINE__); exit(retval); }

Definition at line 12 of file PAPI_state.c.


Function Documentation

int main (  ) 

Definition at line 15 of file PAPI_state.c.

00016 {
00017 
00018    int retval; 
00019    int status = 0;
00020    int EventSet = PAPI_NULL;
00021 
00022    /****************************************************************************
00023    *  This part initializes the library and compares the version number of the *
00024    * header file, to the version of the library, if these don't match then it  *
00025    * is likely that PAPI won't work correctly.If there is an error, retval     *
00026    * keeps track of the version number.                                        *
00027    ****************************************************************************/
00028 
00029    if((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT )
00030    {
00031       printf("Library initialization error! \n");
00032       exit(-1);
00033    }
00034 
00035    /*Creating the Eventset */
00036    if((retval = PAPI_create_eventset(&EventSet)) != PAPI_OK)
00037       ERROR_RETURN(retval);
00038 
00039    /* Add Total Instructions Executed to our EventSet */
00040    if ((retval=PAPI_add_event(EventSet, PAPI_TOT_INS)) != PAPI_OK)
00041       ERROR_RETURN(retval);
00042 
00043    if ((retval=PAPI_state(EventSet, &status)) != PAPI_OK)
00044       ERROR_RETURN(retval);
00045 
00046    printstate(status);
00047 
00048    /* Start counting */
00049    if ((retval=PAPI_start(EventSet)) != PAPI_OK)
00050       ERROR_RETURN(retval);
00051 
00052    if (PAPI_state(EventSet, &status) != PAPI_OK)
00053       ERROR_RETURN(retval);
00054      
00055    printstate(status);       
00056  
00057    /* free the resources used by PAPI */
00058    PAPI_shutdown();
00059 
00060    exit(0);
00061 }

Here is the call graph for this function:

int printstate ( int  status  ) 

Definition at line 63 of file PAPI_state.c.

00064 {
00065    if(status & PAPI_STOPPED)
00066       printf("Eventset is currently stopped or inactive \n");
00067    if(status & PAPI_RUNNING)
00068       printf("Eventset is currently running \n");
00069    if(status & PAPI_PAUSED)
00070       printf("Eventset is currently Paused \n");
00071    if(status & PAPI_NOT_INIT) 
00072       printf(" Eventset defined but not initialized \n");
00073    if(status & PAPI_OVERFLOWING)
00074       printf(" Eventset has overflowing enabled \n");
00075    if(status & PAPI_PROFILING)
00076       printf(" Eventset has profiling enabled \n"); 
00077    if(status & PAPI_MULTIPLEXING)
00078       printf(" Eventset has multiplexing enabled \n"); 
00079    return 0;
00080 }

Here is the caller graph for this function:


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1