PAPI_perror.c File Reference

Include dependency graph for PAPI_perror.c:

Go to the source code of this file.

Functions

int main ()

Function Documentation

int main (  ) 

Definition at line 16 of file PAPI_perror.c.

00017 {
00018 
00019    int retval;
00020    int EventSet = PAPI_NULL;
00021    char error_str[PAPI_MAX_STR_LEN];
00022         
00023    /****************************************************************************
00024    *  This part initializes the library and compares the version number of the *
00025    * header file, to the version of the library, if these don't match then it  *
00026    * is likely that PAPI won't work correctly.If there is an error, retval     *
00027    * keeps track of the version number.                                        *
00028    ****************************************************************************/
00029 
00030    if((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT )
00031    {
00032       exit(1);
00033    }
00034   
00035    if ((retval = PAPI_create_eventset(&EventSet)) != PAPI_OK)
00036    {
00037       fprintf(stderr, "PAPI error %d: %s\n",retval,PAPI_strerror(retval));
00038       exit(1);
00039    }     
00040 
00041    /* Add Total Instructions Executed to our EventSet */
00042 
00043    if ((retval = PAPI_add_event(EventSet, PAPI_TOT_INS)) != PAPI_OK)
00044    {
00045       PAPI_perror( "PAPI_add_event" );
00046       exit(1);
00047    }
00048 
00049    /* Start counting */
00050 
00051    if ((retval = PAPI_start(EventSet)) != PAPI_OK)
00052    {
00053       PAPI_perror( "PAPI_start" );
00054       exit(1);
00055    }
00056 
00057   /* We are trying to start the  counter which has already been started, 
00058      and this will give an error which will be passed to PAPI_perror via 
00059      retval and the function will then display the error string on the 
00060      screen.
00061    */ 
00062 
00063    if ((retval = PAPI_start(EventSet)) != PAPI_OK)
00064    {
00065       PAPI_perror( "PAPI_start" );
00066    }
00067 
00068    /* The function PAPI_strerror returns the corresponding error string 
00069       from the error code */ 
00070    if ((retval = PAPI_start(EventSet)) != PAPI_OK)
00071    {
00072       printf("%s\n",PAPI_strerror(retval));
00073    }
00074 
00075    /* finish using PAPI and free all related resources 
00076      (this is optional, you don't have to use it 
00077    */
00078    PAPI_shutdown (); 
00079 
00080    exit(0);
00081 }

Here is the call graph for this function:


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1