|
PAPI
5.0.1.0
|
00001 /* This file decodes the preset events into a csv format file */ 00040 #include "papi_test.h" 00041 extern int TESTS_QUIET; /* Declared in test_utils.c */ 00042 00043 static void 00044 print_help( void ) 00045 { 00046 printf( "This is the PAPI decode utility program.\n" ); 00047 printf( "It decodes PAPI preset events into csv formatted text.\n" ); 00048 printf( "By default all presets are decoded.\n" ); 00049 printf( "The text goes to stdout, but can be piped to a file.\n" ); 00050 printf( "Such a file can be edited in a text editor or spreadsheet.\n" ); 00051 printf( "It can also be parsed by PAPI_encode_events.\n" ); 00052 printf( "Usage:\n\n" ); 00053 printf( " decode [options]\n\n" ); 00054 printf( "Options:\n\n" ); 00055 printf( " -a decode only available PAPI preset events\n" ); 00056 printf( " -h print this help message\n" ); 00057 printf( "\n" ); 00058 } 00059 00060 int 00061 main( int argc, char **argv ) 00062 { 00063 int i, j; 00064 int retval; 00065 int print_avail_only = 0; 00066 PAPI_event_info_t info; 00067 00068 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */ 00069 for ( i = 0; i < argc; i++ ) 00070 if ( argv[i] ) { 00071 if ( strstr( argv[i], "-a" ) ) 00072 print_avail_only = PAPI_PRESET_ENUM_AVAIL; 00073 if ( strstr( argv[i], "-h" ) ) { 00074 print_help( ); 00075 exit( 1 ); 00076 } 00077 } 00078 00079 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00080 if ( retval != PAPI_VER_CURRENT ) 00081 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval ); 00082 00083 if ( !TESTS_QUIET ) { 00084 retval = PAPI_set_debug( PAPI_VERB_ECONT ); 00085 if ( retval != PAPI_OK ) 00086 test_fail( __FILE__, __LINE__, "PAPI_set_debug", retval ); 00087 } 00088 00089 i = PAPI_PRESET_MASK; 00090 printf 00091 ( "name,derived,postfix,short_descr,long_descr,note,[native,...]\n\n" ); 00092 00093 do { 00094 if ( PAPI_get_event_info( i, &info ) == PAPI_OK ) { 00095 printf( "%s,%s,%s,", info.symbol, info.derived, info.postfix ); 00096 if ( info.short_descr[0] ) { 00097 printf( "\"%s\",", info.short_descr ); 00098 } else { 00099 printf( "," ); 00100 } 00101 if ( info.long_descr[0] ) { 00102 printf( "\"%s\",", info.long_descr ); 00103 } else { 00104 printf( "," ); 00105 } 00106 if ( info.note[0] ) 00107 printf( "\"%s\"", info.note ); 00108 00109 for ( j = 0; j < ( int ) info.count; j++ ) 00110 printf( ",%s", info.name[j] ); 00111 printf( "\n" ); 00112 } 00113 } while ( PAPI_enum_event( &i, print_avail_only ) == PAPI_OK ); 00114 exit( 1 ); 00115 }