event_chooser.c File Reference

Include dependency graph for event_chooser.c:

Go to the source code of this file.

Functions

static char * is_derived (PAPI_event_info_t *info)
static int add_remove_event (int EventSet, int evt)
static int show_event_info (int evt)
static int native (int cidx)
static int preset (void)
int main (int argc, char **argv)

Variables

int EventSet = PAPI_NULL
int retval

Function Documentation

static int add_remove_event ( int  EventSet,
int  evt 
) [static]

Definition at line 44 of file event_chooser.c.

00045 {
00046     int retval;
00047 
00048     if ( ( retval = PAPI_add_event( EventSet, evt ) ) != PAPI_OK ) {
00049        //printf( "Error adding event.\n" );
00050     } else {
00051        if ( ( retval = PAPI_remove_event( EventSet, evt ) ) != PAPI_OK ) {
00052       printf( "Error removing event.\n" );
00053        }
00054     }
00055     return retval;
00056 }

Here is the call graph for this function:

Here is the caller graph for this function:

static char* is_derived ( PAPI_event_info_t info  )  [static]

Definition at line 31 of file event_chooser.c.

00032 {
00033     if ( strlen( info->derived ) == 0 )
00034         return ( "No" );
00035     else if ( strcmp( info->derived, "NOT_DERIVED" ) == 0 )
00036         return ( "No" );
00037     else if ( strcmp( info->derived, "DERIVED_CMPD" ) == 0 )
00038         return ( "No" );
00039     else
00040         return ( "Yes" );
00041 }

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 189 of file event_chooser.c.

00190 {
00191     int i;
00192     int pevent,cevent;
00193     int cidx;
00194 
00195     const PAPI_hw_info_t *hwinfo = NULL;
00196 
00197     if ( argc < 3 ) {
00198        goto use_exit;
00199     }
00200 
00201     /* Set TESTS_QUIET variable */
00202     tests_quiet( argc, argv );  
00203 
00204     /* Init PAPI library */
00205     retval = PAPI_library_init( PAPI_VER_CURRENT );
00206     if ( retval != PAPI_VER_CURRENT ) {
00207        test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00208     }
00209 
00210     retval = PAPI_set_debug( PAPI_VERB_ECONT );
00211     if ( retval != PAPI_OK ) {
00212        test_fail( __FILE__, __LINE__, "PAPI_set_debug", retval );
00213     }
00214 
00215     retval = papi_print_header( "Event Chooser: Available events "
00216                 "which can be added with given events.\n",
00217                         &hwinfo );
00218     if ( retval != PAPI_OK ) {
00219        test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
00220     }
00221 
00222     retval = PAPI_create_eventset( &EventSet );
00223     if ( retval != PAPI_OK ) {
00224        fprintf( stderr, "PAPI_create_eventset error\n" );
00225        exit( 1 );
00226     }
00227 
00228     retval = PAPI_event_name_to_code( argv[2], &cevent );
00229     if ( retval != PAPI_OK ) {
00230        fprintf( stderr, "Event %s can't be found\n", argv[2] );
00231        exit( 1 );
00232     }
00233     cidx = PAPI_get_event_component(cevent);
00234 
00235     for( i = 2; i < argc; i++ ) {
00236        retval = PAPI_event_name_to_code( argv[i], &pevent );
00237        if ( retval != PAPI_OK ) {
00238       fprintf( stderr, "Event %s can't be found\n", argv[i] );
00239       exit( 1 );
00240        }
00241        retval = PAPI_add_event( EventSet, pevent );
00242        if ( retval != PAPI_OK ) {
00243       fprintf( stderr, "Event %s can't be counted with others %d\n",
00244            argv[i], retval );
00245       exit( 1 );
00246        }
00247     }
00248 
00249     if ( !strcmp( "NATIVE", argv[1] ) ) {
00250        native( cidx );
00251     }
00252     else if ( !strcmp( "PRESET", argv[1] ) ) {
00253        preset(  );
00254     }
00255     else {
00256        goto use_exit;
00257     }
00258     exit( 0 );
00259   
00260 use_exit:
00261     fprintf( stderr,
00262         "Usage: papi_event_chooser NATIVE|PRESET evt1 evt2 ... \n" );
00263     exit( 1 );
00264 }

Here is the call graph for this function:

static int native ( int  cidx  )  [static]

Definition at line 81 of file event_chooser.c.

00082 {
00083     int i, j, k;
00084     int retval, added;
00085     PAPI_event_info_t info;
00086 
00087     j = 0;
00088 
00089     /* For platform independence, always ASK FOR the first event */
00090     /* Don't just assume it'll be the first numeric value */
00091     i = 0 | PAPI_NATIVE_MASK;
00092     retval=PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cidx );
00093     if (retval==PAPI_ENOEVNT) {
00094        printf("Cannot find first event in component %d\n",cidx);
00095     }
00096 
00097     do {
00098        k = i;
00099 
00100        if ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cidx) == PAPI_OK ) {
00101       if ( ( added = add_remove_event( EventSet, k ) ) == PAPI_OK ) {
00102          show_event_info( i );
00103          do {
00104         retval = PAPI_get_event_info( k, &info );
00105         if ( retval == PAPI_OK ) {
00106            printf( "    %#-10x%s  |%s|\n", info.event_code,
00107                strchr( info.symbol, ':' ),
00108                strchr( info.long_descr, ':' ) + 1 );
00109         }
00110          } while ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cidx ) ==
00111                               PAPI_OK );
00112          j++;
00113       }
00114        } else {
00115       if ( ( added = add_remove_event( EventSet, i ) ) == PAPI_OK ) {
00116          show_event_info( i );
00117          j++;
00118       }
00119        }
00120     
00121        if ( added == PAPI_OK ) {
00122       /* modifier = PAPI_NTV_ENUM_GROUPS returns event codes with a
00123          groups id for each group in which this
00124          native event lives, in bits 16 - 23 of event code
00125          terminating with PAPI_ENOEVNT at the end of the list.
00126        */
00127       k = i;
00128       if ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_GROUPS, cidx ) == PAPI_OK ) {
00129          printf( "Groups: " );
00130          do {
00131         printf( "%4d", ( ( k & PAPI_NTV_GROUP_AND_MASK ) >>
00132                       PAPI_NTV_GROUP_SHIFT ) - 1 );
00133          } while ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_GROUPS, cidx ) ==
00134                               PAPI_OK );
00135          printf( "\n" );
00136       }
00137       
00138       printf( "---------------------------------------------"
00139           "----------------------------\n" );
00140        }
00141     } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cidx ) == PAPI_OK );
00142 
00143     printf( "------------------------------------------"
00144         "-------------------------------\n" );
00145     printf( "Total events reported: %d\n", j );
00146     test_pass( __FILE__, NULL, 0 );
00147     exit( 1 );
00148 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int preset ( void   )  [static]

Definition at line 151 of file event_chooser.c.

00152 {
00153     int i, j = 0;
00154     int retval;
00155     PAPI_event_info_t info;
00156 
00157     printf( "    Name        Code    " );
00158     printf( "Deriv Description (Note)\n" );
00159 
00160     /* For consistency, always ASK FOR the first event */
00161     i = 0 | PAPI_PRESET_MASK;
00162     PAPI_enum_event( &i, PAPI_ENUM_FIRST );
00163 
00164     do {
00165         retval = PAPI_add_event( EventSet, i );
00166         if ( retval == PAPI_OK ) {
00167             if ( PAPI_get_event_info( i, &info ) == PAPI_OK ) {
00168                 printf( "%-13s%#x  %-5s%s",
00169                         info.symbol,
00170                         info.event_code, is_derived( &info ), info.long_descr );
00171                 if ( info.note[0] )
00172                     printf( " (%s)", info.note );
00173                 printf( "\n" );
00174             }
00175             if ( ( retval = PAPI_remove_event( EventSet, i ) ) != PAPI_OK )
00176                 printf( "Error in PAPI_remove_event\n" );
00177             j++;
00178         }
00179     } while ( PAPI_enum_event( &i, PAPI_PRESET_ENUM_AVAIL ) == PAPI_OK );
00180 
00181     printf
00182         ( "-------------------------------------------------------------------------\n" );
00183     printf( "Total events reported: %d\n", j );
00184     test_pass( __FILE__, NULL, 0 );
00185     exit( 1 );
00186 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int show_event_info ( int  evt  )  [static]

Definition at line 59 of file event_chooser.c.

00060 {
00061     int k;
00062     int retval;
00063     PAPI_event_info_t info;
00064 
00065     if ( ( retval = PAPI_get_event_info( evt, &info ) ) == PAPI_OK ) {
00066        printf( "%s\t%#x\n |%s|\n",
00067            info.symbol, info.event_code, info.long_descr );
00068 
00069        for( k = 0; k < ( int ) info.count; k++ ) {
00070       if ( strlen( info.name[k] ) ) {
00071          printf( " |Register Value[%d]: %#-10x  %s|\n", 
00072                      k, info.code[k], info.name[k] );
00073       }
00074        }
00075     }
00076     return retval;
00077 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int EventSet = PAPI_NULL

Definition at line 27 of file event_chooser.c.

int retval

Definition at line 28 of file event_chooser.c.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1