avail.c File Reference

Include dependency graph for avail.c:

Go to the source code of this file.

Functions

static char * is_derived (PAPI_event_info_t *info)
static void print_help (char **argv)
static int parse_unit_masks (PAPI_event_info_t *info)
static int checkCounter (int eventcode)
int main (int argc, char **argv)

Variables

int TESTS_QUIET

Function Documentation

static int checkCounter ( int  eventcode  )  [static]

Definition at line 231 of file avail.c.

00232 {
00233     int EventSet = PAPI_NULL;
00234     if (PAPI_create_eventset(&EventSet) != PAPI_OK)
00235         return 0;
00236     if (PAPI_add_event (EventSet, eventcode) != PAPI_OK)
00237         return 0;
00238     if (PAPI_cleanup_eventset (EventSet) != PAPI_OK)
00239         return 0;
00240     if (PAPI_destroy_eventset (&EventSet) != PAPI_OK)
00241         return 0;
00242     return 1;
00243 }

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 171 of file avail.c.

00172 {
00173     if ( strlen( info->derived ) == 0 )
00174         return ( "No" );
00175     else if ( strcmp( info->derived, "NOT_DERIVED" ) == 0 )
00176         return ( "No" );
00177     else if ( strcmp( info->derived, "DERIVED_CMPD" ) == 0 )
00178         return ( "No" );
00179     else
00180         return ( "Yes" );
00181 }

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 246 of file avail.c.

00247 {
00248    int args, i, j, k;
00249    int retval;
00250    unsigned int filter = 0;
00251    int print_event_info = 0;
00252    char *name = NULL;
00253    int print_avail_only = PAPI_ENUM_EVENTS;
00254    int print_tabular = 1;
00255    PAPI_event_info_t info;
00256    const PAPI_hw_info_t *hwinfo = NULL;
00257    int tot_count = 0;
00258    int avail_count = 0;
00259    int deriv_count = 0;
00260    int check_counter = 0;
00261    int event_code;
00262 
00263    PAPI_event_info_t n_info;
00264 
00265    /* Set TESTS_QUIET variable */
00266 
00267    tests_quiet( argc, argv );   
00268 
00269    /* Parse command line arguments */
00270 
00271    for( args = 1; args < argc; args++ ) {
00272       if ( strstr( argv[args], "-e" ) ) {
00273      print_event_info = 1;
00274      name = argv[args + 1];
00275      if ( ( name == NULL ) || ( strlen( name ) == 0 ) ) {
00276         print_help( argv );
00277         exit( 1 );
00278      }
00279       }
00280       else if ( strstr( argv[args], "-c" ) || strstr (argv[args], "--check") )
00281       {
00282      print_avail_only = PAPI_PRESET_ENUM_AVAIL;
00283          check_counter = 1;
00284       }
00285       else if ( strstr( argv[args], "-a" ))
00286      print_avail_only = PAPI_PRESET_ENUM_AVAIL;
00287       else if ( strstr( argv[args], "-d" ) )
00288      print_tabular = 0;
00289       else if ( strstr( argv[args], "-h" ) ) {
00290      print_help( argv );
00291      exit( 1 );
00292       } else if ( strstr( argv[args], "--br" ) )
00293      filter |= PAPI_PRESET_BIT_BR;
00294       else if ( strstr( argv[args], "--cache" ) )
00295      filter |= PAPI_PRESET_BIT_CACH;
00296       else if ( strstr( argv[args], "--cnd" ) )
00297      filter |= PAPI_PRESET_BIT_CND;
00298       else if ( strstr( argv[args], "--fp" ) )
00299      filter |= PAPI_PRESET_BIT_FP;
00300       else if ( strstr( argv[args], "--ins" ) )
00301      filter |= PAPI_PRESET_BIT_INS;
00302       else if ( strstr( argv[args], "--idl" ) )
00303      filter |= PAPI_PRESET_BIT_IDL;
00304       else if ( strstr( argv[args], "--l1" ) )
00305      filter |= PAPI_PRESET_BIT_L1;
00306       else if ( strstr( argv[args], "--l2" ) )
00307      filter |= PAPI_PRESET_BIT_L2;
00308       else if ( strstr( argv[args], "--l3" ) )
00309      filter |= PAPI_PRESET_BIT_L3;
00310       else if ( strstr( argv[args], "--mem" ) )
00311      filter |= PAPI_PRESET_BIT_BR;
00312       else if ( strstr( argv[args], "--msc" ) )
00313      filter |= PAPI_PRESET_BIT_MSC;
00314       else if ( strstr( argv[args], "--tlb" ) )
00315      filter |= PAPI_PRESET_BIT_TLB;
00316    }
00317 
00318    if ( filter == 0 ) {
00319       filter = ( unsigned int ) ( -1 );
00320    }
00321 
00322    /* Init PAPI */
00323 
00324    retval = PAPI_library_init( PAPI_VER_CURRENT );
00325    if ( retval != PAPI_VER_CURRENT ) {
00326       test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00327    }
00328 
00329    if ( !TESTS_QUIET ) {
00330       retval = PAPI_set_debug( PAPI_VERB_ECONT );
00331       if ( retval != PAPI_OK ) {
00332      test_fail( __FILE__, __LINE__, "PAPI_set_debug", retval );
00333       }
00334 
00335       retval=papi_print_header("Available PAPI preset and user defined events plus hardware information.\n",
00336                    &hwinfo );
00337       if ( retval != PAPI_OK ) {
00338      test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
00339       }
00340 
00341       /* Code for info on just one event */
00342 
00343       if ( print_event_info ) {
00344 
00345      if ( PAPI_event_name_to_code( name, &event_code ) == PAPI_OK ) {
00346         if ( PAPI_get_event_info( event_code, &info ) == PAPI_OK ) {
00347 
00348            if ( event_code & PAPI_PRESET_MASK ) {
00349           printf( "%-30s%s\n%-30s%#-10x\n%-30s%d\n",
00350               "Event name:", info.symbol, "Event Code:",
00351               info.event_code, "Number of Native Events:",
00352               info.count );
00353           printf( "%-29s|%s|\n%-29s|%s|\n%-29s|%s|\n",
00354               "Short Description:", info.short_descr,
00355               "Long Description:", info.long_descr,
00356               "Developer's Notes:", info.note );
00357           printf( "%-29s|%s|\n%-29s|%s|\n", "Derived Type:",
00358               info.derived, "Postfix Processing String:",
00359               info.postfix );
00360 
00361           for( j = 0; j < ( int ) info.count; j++ ) {
00362              printf( " Native Code[%d]: %#x |%s|\n", j,
00363                  info.code[j], info.name[j] );
00364              PAPI_get_event_info( (int) info.code[j], &n_info );
00365              printf(" Number of Register Values: %d\n", n_info.count );
00366              for( k = 0; k < ( int ) n_info.count; k++ ) {
00367             printf( " Register[%2d]: %#08x |%s|\n", k,
00368                 n_info.code[k], n_info.name[k] );
00369              }
00370              printf( " Native Event Description: |%s|\n\n",
00371                  n_info.long_descr );
00372           }
00373            } else {  /* must be a native event code */
00374           printf( "%-30s%s\n%-30s%#-10x\n%-30s%d\n",
00375               "Event name:", info.symbol, "Event Code:",
00376               info.event_code, "Number of Register Values:",
00377               info.count );
00378           printf( "%-29s|%s|\n", "Description:", info.long_descr );
00379           for ( k = 0; k < ( int ) info.count; k++ ) {
00380               printf( " Register[%2d]: %#08x |%s|\n", k,
00381                   info.code[k], info.name[k] );
00382           }
00383 
00384           /* if unit masks exist but none are specified, process all */
00385           if ( !strchr( name, ':' ) ) {
00386              if ( 1 ) {
00387             if ( PAPI_enum_event( &event_code, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK ) {
00388                printf( "\nUnit Masks:\n" );
00389                do {
00390                   retval = PAPI_get_event_info(event_code, &info );
00391                   if ( retval == PAPI_OK ) {
00392                  if ( parse_unit_masks( &info ) ) {
00393                     printf( "%-29s|%s|%s|\n",
00394                         " Mask Info:", info.symbol,
00395                         info.long_descr );
00396                     for ( k = 0; k < ( int ) info.count;k++ ) {
00397                     printf( "  Register[%2d]:  %#08x  |%s|\n",
00398                         k, info.code[k], info.name[k] );
00399                     }
00400                  }
00401                   }
00402                } while ( PAPI_enum_event( &event_code,
00403                       PAPI_NTV_ENUM_UMASKS ) == PAPI_OK );
00404             }
00405              }
00406           }
00407            }
00408         }
00409      } else {
00410         printf( "Sorry, an event by the name '%s' could not be found.\n"
00411                     " Is it typed correctly?\n\n", name );
00412      }
00413       } else {
00414 
00415      /* Print *ALL* Events */
00416 
00417   for (i=0 ; i<2 ; i++) {
00418     // set the event code to fetch preset events the first time through loop and user events the second time through the loop
00419     if (i== 0) {
00420         event_code = 0 | PAPI_PRESET_MASK;
00421     } else {
00422         event_code = 0 | PAPI_UE_MASK;
00423     }
00424 
00425     /* For consistency, always ASK FOR the first event, if there is not one then nothing to process */
00426     if (PAPI_enum_event( &event_code, PAPI_ENUM_FIRST ) != PAPI_OK) {
00427          continue;
00428     }
00429 
00430     // print heading to show which kind of events follow
00431     if (i== 0) {
00432         printf( "================================================================================\n" );
00433         printf( "  PAPI Preset Events\n" );
00434         printf( "================================================================================\n" );
00435     } else {
00436         printf( "\n");       // put a blank line after the presets before strarting the user events
00437         printf( "================================================================================\n" );
00438         printf( "  User Defined Events\n" );
00439         printf( "================================================================================\n" );
00440     }
00441 
00442      if ( print_tabular ) {
00443         printf( "    Name        Code    " );
00444         if ( !print_avail_only ) {
00445            printf( "Avail " );
00446         }
00447         printf( "Deriv Description (Note)\n" );
00448      } else {
00449         printf( "%-13s%-11s%-8s%-16s\n |Long Description|\n"
00450                     " |Developer's Notes|\n |Derived|\n |PostFix|\n"
00451                     " Native Code[n]: <hex> |name|\n",
00452             "Symbol", "Event Code", "Count", "|Short Description|" );
00453      }
00454      do {
00455         if ( PAPI_get_event_info( event_code, &info ) == PAPI_OK ) {
00456            if ( print_tabular ) {
00457           // if this is a user defined event or its a preset and matches the preset event filters, display its information
00458           if ( (i==1) || (filter & info.event_type)) {
00459              if ( print_avail_only ) {
00460                 if ( info.count ) {
00461                    if ( (check_counter && checkCounter (event_code)) || !check_counter)
00462                    {
00463                       printf( "%-13s%#x  %-5s%s",
00464                          info.symbol,
00465                          info.event_code,
00466                          is_derived( &info ), info.long_descr );
00467                    }
00468             }
00469                 if ( info.note[0] ) {
00470                printf( " (%s)", info.note );
00471             }
00472             printf( "\n" );
00473              } else {
00474             printf( "%-13s%#x  %-6s%-4s %s",
00475                 info.symbol,
00476                 info.event_code,
00477                 ( info.count ? "Yes" : "No" ),
00478                 is_derived( &info ), info.long_descr );
00479             if ( info.note[0] ) {
00480                printf( " (%s)", info.note );
00481             }
00482             printf( "\n" );
00483              }
00484              tot_count++;
00485              if ( info.count ) {
00486                 if ((check_counter && checkCounter (event_code)) || !check_counter )
00487                   avail_count++;
00488              }
00489              if ( !strcmp( is_derived( &info ), "Yes" ) ) {
00490             deriv_count++;
00491              }
00492           }
00493            } else {
00494           if ( ( print_avail_only && info.count ) ||
00495                ( print_avail_only == 0 ) )
00496           {
00497              if ((check_counter && checkCounter (event_code)) || !check_counter)
00498              {
00499                printf( "%s\t%#x\t%d\t|%s|\n |%s|\n"
00500                  " |%s|\n |%s|\n |%s|\n",
00501                  info.symbol, info.event_code, info.count,
00502                  info.short_descr, info.long_descr, info.note,
00503                  info.derived, info.postfix );
00504                for ( j = 0; j < ( int ) info.count; j++ ) {
00505                   printf( " Native Code[%d]: %#x |%s|\n", j,
00506                   info.code[j], info.name[j] );
00507                }
00508              }
00509           }
00510           tot_count++;
00511           if ( info.count ) {
00512              if ((check_counter && checkCounter (event_code)) || !check_counter )
00513                 avail_count++;
00514           }
00515           if ( !strcmp( is_derived( &info ), "Yes" ) ) {
00516              deriv_count++;
00517           }
00518            }
00519         }
00520      } while (PAPI_enum_event( &event_code, print_avail_only ) == PAPI_OK);
00521   }
00522       }
00523       printf( "--------------------------------------------------------------------------------\n" );
00524       if ( !print_event_info ) {
00525      if ( print_avail_only ) {
00526         printf( "Of %d available events, %d ", avail_count, deriv_count );
00527      } else {
00528         printf( "Of %d possible events, %d are available, of which %d ",
00529             tot_count, avail_count, deriv_count );
00530      }
00531      if ( deriv_count == 1 ) {
00532         printf( "is derived.\n\n" );
00533      } else {
00534         printf( "are derived.\n\n" );
00535      }
00536       }
00537    }
00538    test_pass( __FILE__, NULL, 0 );
00539    exit( 1 );
00540    
00541 }

Here is the call graph for this function:

static int parse_unit_masks ( PAPI_event_info_t info  )  [static]

Definition at line 213 of file avail.c.

00214 {
00215     char *pmask;
00216 
00217     if ( ( pmask = strchr( info->symbol, ':' ) ) == NULL ) {
00218         return ( 0 );
00219     }
00220     memmove( info->symbol, pmask, ( strlen( pmask ) + 1 ) * sizeof ( char ) );
00221     pmask = strchr( info->long_descr, ':' );
00222     if ( pmask == NULL )
00223         info->long_descr[0] = 0;
00224     else
00225         memmove( info->long_descr, pmask + sizeof ( char ),
00226                  ( strlen( pmask ) + 1 ) * sizeof ( char ) );
00227     return ( 1 );
00228 }

Here is the caller graph for this function:

static void print_help ( char **  argv  )  [static]

Definition at line 184 of file avail.c.

00185 {
00186     printf( "Usage: %s [options]\n", argv[0] );
00187     printf( "Options:\n\n" );
00188     printf( "General command options:\n" );
00189     printf( "\t-a, --avail      Display only available PAPI preset and user defined events\n" );
00190     printf( "\t-c, --check      Display only available PAPI preset and user defined events after an availability check\n" );
00191     printf( "\t-d, --detail     Display detailed information about events\n" );
00192     printf( "\t-e EVENTNAME     Display detail information about specified event\n" );
00193     printf( "\t-h, --help       Print this help message\n" );
00194     printf( "\nEvent filtering options:\n" );
00195     printf( "\t--br             Display branch related PAPI preset events\n" );
00196     printf( "\t--cache          Display cache related PAPI preset events\n" );
00197     printf( "\t--cnd            Display conditional PAPI preset events\n" );
00198     printf( "\t--fp             Display Floating Point related PAPI preset events\n" );
00199     printf( "\t--ins            Display instruction related PAPI preset events\n" );
00200     printf( "\t--idl            Display Stalled or Idle PAPI preset events\n" );
00201     printf( "\t--l1             Display level 1 cache related PAPI preset events\n" );
00202     printf( "\t--l2             Display level 2 cache related PAPI preset events\n" );
00203     printf( "\t--l3             Display level 3 cache related PAPI preset events\n" );
00204     printf( "\t--mem            Display memory related PAPI preset events\n" );
00205     printf( "\t--msc            Display miscellaneous PAPI preset events\n" );
00206     printf( "\t--tlb            Display Translation Lookaside Buffer PAPI preset events\n" );
00207     printf( "\n" );
00208     printf( "This program provides information about PAPI preset and user defined events.\n" );
00209     printf( "PAPI preset event filters can be combined in a logical OR.\n" );
00210 }

Here is the caller graph for this function:


Variable Documentation

Definition at line 11 of file test_utils.c.


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1