component.c File Reference

Include dependency graph for component.c:

Go to the source code of this file.

Data Structures

struct  command_flags_t

Defines

#define EVT_LINE   80

Functions

static void print_help (char **argv)
static void parse_args (int argc, char **argv, command_flags_t *f)
int main (int argc, char **argv)

Define Documentation

#define EVT_LINE   80

Definition at line 27 of file component.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 73 of file component.c.

00074 {
00075     int i;
00076     int retval;
00077     const PAPI_hw_info_t *hwinfo = NULL;
00078     const PAPI_component_info_t* cmpinfo;
00079     command_flags_t flags;
00080     int numcmp, cid;
00081 
00082     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00083 
00084     /* Initialize before parsing the input arguments */
00085     retval = PAPI_library_init( PAPI_VER_CURRENT );
00086     if ( retval != PAPI_VER_CURRENT )
00087         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00088 
00089     parse_args( argc, argv, &flags );
00090 
00091     if ( !TESTS_QUIET ) {
00092         retval = PAPI_set_debug( PAPI_VERB_ECONT );
00093         if ( retval != PAPI_OK )
00094             test_fail( __FILE__, __LINE__, "PAPI_set_debug", retval );
00095     }
00096 
00097     retval =
00098         papi_print_header
00099         ( "Available components and hardware information.\n", &hwinfo );
00100     if ( retval != PAPI_OK )
00101         test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
00102 
00103 
00104     /* Compiled-in Components */
00105     numcmp = PAPI_num_components(  );
00106 
00107     printf("Compiled-in components:\n");
00108     for ( cid = 0; cid < numcmp; cid++ ) {
00109       cmpinfo = PAPI_get_component_info( cid );
00110 
00111       printf( "Name:   %-23s %s\n", cmpinfo->name ,cmpinfo->description);
00112 
00113       if (cmpinfo->disabled) {
00114         printf("   \\-> Disabled: %s\n",cmpinfo->disabled_reason);
00115       }
00116 
00117       if ( flags.details ) {
00118         printf( "Version:\t\t\t%s\n", cmpinfo->version );
00119         printf( "Number of native events:\t%d\n", cmpinfo->num_native_events);
00120         printf( "Number of preset events:\t%d\n", cmpinfo->num_preset_events); 
00121         printf("\n");
00122       }
00123     }
00124 
00125     printf("\nActive components:\n");
00126     numcmp = PAPI_num_components(  );
00127 
00128     for ( cid = 0; cid < numcmp; cid++ ) {
00129       cmpinfo = PAPI_get_component_info( cid );
00130       if (cmpinfo->disabled) continue;
00131 
00132       printf( "Name:   %-23s %s\n", cmpinfo->name ,cmpinfo->description);
00133       printf( "        %-23s Native: %d, Preset: %d, Counters: %d\n",
00134           " ", cmpinfo->num_native_events, cmpinfo->num_preset_events, cmpinfo->num_cntrs);
00135       printf( "        %-23s PMU's supported: ", " ");
00136       int line_len = 49;
00137       for (i=0 ; i<PAPI_PMU_MAX ; i++) {
00138           if (cmpinfo->pmu_names[i] == NULL) continue;
00139 
00140           if (line_len + strlen(cmpinfo->pmu_names[i]) > 130) {
00141               printf("\n        %-23s                  ", " ");
00142               line_len = 49;
00143           } else {
00144               line_len += strlen(cmpinfo->pmu_names[i]);
00145           }
00146           // if it is not the first entry on a line, separate the names
00147           if ((i != 0) && (line_len > 50)) {
00148               printf(", ");
00149           }
00150           printf("%s", cmpinfo->pmu_names[i]);
00151       }
00152       printf("\n\n");
00153 
00154       if ( flags.details ) {
00155         printf( "Version:\t\t\t%s\n", cmpinfo->version );
00156         printf( "Number of native events:\t%d\n", cmpinfo->num_native_events);
00157         printf( "Number of preset events:\t%d\n", cmpinfo->num_preset_events); 
00158         printf("\n");
00159       }
00160     }
00161 
00162 
00163     printf
00164       ( "\n--------------------------------------------------------------------------------\n" );
00165     test_pass( __FILE__, NULL, 0 );
00166     exit( 0 );
00167 }

Here is the call graph for this function:

static void parse_args ( int  argc,
char **  argv,
command_flags_t f 
) [static]

Definition at line 49 of file component.c.

00050 {
00051     int i;
00052 
00053     /* Look for all currently defined commands */
00054     memset( f, 0, sizeof ( command_flags_t ) );
00055     for ( i = 1; i < argc; i++ ) {
00056         if ( !strcmp( argv[i], "-d" ) ) {
00057             f->details = 1;
00058         } else if ( !strcmp( argv[i], "-h" ) || !strcmp( argv[i], "--help" ) )
00059             f->help = 1;
00060         else
00061             printf( "%s is not supported\n", argv[i] );
00062     }
00063 
00064     /* if help requested, print and bail */
00065     if ( f->help ) {
00066         print_help( argv );
00067         exit( 1 );
00068     }
00069 
00070 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 38 of file component.c.

00039 {
00040     printf( "This is the PAPI component avail program.\n" );
00041     printf( "It provides availability of installed PAPI components.\n" );
00042     printf( "Usage: %s [options]\n", argv[0] );
00043     printf( "Options:\n\n" );
00044     printf( "  --help, -h    print this help message\n" );
00045     printf( "  -d            print detailed information on each component\n" );
00046 }

Here is the caller graph for this function:


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1