all_native_events.c File Reference

Include dependency graph for all_native_events.c:

Go to the source code of this file.

Functions

static int check_event (int event_code, char *name)
int main (int argc, char **argv)

Variables

int TESTS_QUIET
unsigned char PENTIUM4

Function Documentation

static int check_event ( int  event_code,
char *  name 
) [static]

Definition at line 21 of file all_native_events.c.

00022 {
00023     int retval;
00024     long long values;
00025     int EventSet = PAPI_NULL;
00026 
00027    /* Is there an issue with older machines? */
00028    /* Disable for now, add back once we can reproduce */
00029 //  if ( PENTIUM4 ) {
00030 //      if ( strcmp( name, "REPLAY_EVENT:BR_MSP" ) == 0 ) {
00031 //          return 1;
00032 //      }
00033 //  }
00034 
00035     retval = PAPI_create_eventset( &EventSet );
00036     if ( retval != PAPI_OK )
00037        test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
00038    
00039     retval = PAPI_add_event( EventSet, event_code );
00040     if ( retval != PAPI_OK ) {
00041       printf( "Error adding %s %d\n", name, retval );
00042         return 0;
00043     } else {
00044       //        printf( "Added %s successfully ", name );
00045     }
00046 
00047     retval = PAPI_start( EventSet );
00048     if ( retval != PAPI_OK ) {
00049         PAPI_perror( "PAPI_start" );
00050     } else {
00051         retval = PAPI_stop( EventSet, &values );
00052         if ( retval != PAPI_OK ) {
00053             PAPI_perror( "PAPI_stop" );
00054             return 0;
00055         } else {
00056             printf( "Added and Stopped %s successfully.\n", name );
00057         }
00058     }
00059 
00060 
00061     retval=PAPI_cleanup_eventset( EventSet );
00062     if (retval != PAPI_OK ) {
00063       test_warn( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval);
00064     }
00065     retval=PAPI_destroy_eventset( &EventSet );
00066     if (retval != PAPI_OK ) {
00067       test_warn( __FILE__, __LINE__, "PAPI_destroy_eventset", retval);
00068     }
00069     return ( 1 );
00070 }

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 73 of file all_native_events.c.

00074 {
00075     
00076     int i, k, add_count = 0, err_count = 0, unc_count = 0, offcore_count = 0;
00077     int retval;
00078     PAPI_event_info_t info, info1;
00079     const PAPI_hw_info_t *hwinfo = NULL;
00080     const PAPI_component_info_t* cmpinfo;
00081     char *Intel_i7;
00082     int event_code;
00083     int numcmp, cid;
00084 
00085     /* Set TESTS_QUIET variable */
00086     tests_quiet( argc, argv );
00087 
00088     /* Init PAPI library */
00089     retval = PAPI_library_init( PAPI_VER_CURRENT );
00090     if ( retval != PAPI_VER_CURRENT ) {
00091        test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00092     }
00093 
00094     retval = papi_print_header( "Test case ALL_NATIVE_EVENTS: Available "
00095                 "native events and hardware "
00096                 "information.\n",
00097                 &hwinfo );
00098     if ( retval != PAPI_OK ) {
00099        test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
00100     }
00101 
00102     numcmp = PAPI_num_components(  );
00103 
00104     /* we need a little exception processing if it's a Core i7 */
00105     /* Unfortunately, this test never succeeds... */
00106     Intel_i7 = strstr( hwinfo->model_string, "Intel Core i7" );
00107 
00108     /* Loop through all components */
00109     for( cid = 0; cid < numcmp; cid++ ) {
00110 
00111 
00112        cmpinfo = PAPI_get_component_info( cid );
00113 
00114         if (cmpinfo  == NULL)
00115         {
00116            test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );
00117         }
00118 
00119         if (cmpinfo->disabled)
00120         {
00121           printf( "Name:   %-23s %s\n", cmpinfo->name ,cmpinfo->description);
00122           printf("   \\-> Disabled: %s\n",cmpinfo->disabled_reason);
00123           continue;
00124         }
00125 
00126 
00127 
00128        /* For platform independence, always ASK FOR the first event */
00129        /* Don't just assume it'll be the first numeric value */
00130        i = 0 | PAPI_NATIVE_MASK;
00131        retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cid );
00132 
00133        do {
00134           retval = PAPI_get_event_info( i, &info );
00135 
00136       /* Skip OFFCORE and UNCORE events  */
00137       /* Adding them will fail currently */
00138       if ( Intel_i7 || ( hwinfo->vendor == PAPI_VENDOR_INTEL ) ) {
00139           if ( !strncmp( info.symbol, "UNC_", 4 )         ||
00140               (strstr( info.symbol, "::UNC_") != NULL) )  {
00141              unc_count++;
00142              continue;
00143           }
00144           if ( !strncmp( info.symbol, "OFFCORE_RESPONSE_0", 18 ) ||
00145                !strncmp( info.symbol, "OFFCORE_RESPONSE_1", 18 ) ||
00146                !strncmp( info.symbol, "OFFCORE_RESPONSE", 16 )) {
00147              offcore_count++;
00148              continue;
00149           }
00150       }
00151 
00152       /* Enumerate all umasks */
00153       k = i;
00154       if ( PAPI_enum_cmp_event(&k, PAPI_NTV_ENUM_UMASKS, cid )==PAPI_OK ) {
00155          do {
00156         retval = PAPI_get_event_info( k, &info1 );
00157         event_code = ( int ) info1.event_code;
00158         if ( check_event( event_code, info1.symbol ) ) {
00159            add_count++;
00160         }
00161         else {
00162            err_count++;
00163         }
00164          } while ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cid ) == PAPI_OK );
00165       } else {
00166         /* Event didn't have any umasks */
00167         event_code = ( int ) info.event_code;
00168         if ( check_event( event_code, info.symbol ) ) {
00169            add_count++;
00170         }
00171         else {
00172            err_count++;
00173         }
00174       }
00175       
00176        } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cid ) == PAPI_OK );
00177 
00178     }
00179     printf( "\n\nSuccessfully found and added %d events "
00180             "(in %d eventsets).\n",
00181         add_count , add_count);
00182 
00183     if ( err_count ) {
00184        printf( "Failed to add %d events.\n", err_count );
00185     }
00186 
00187     if (( unc_count ) || (offcore_count)) {
00188        char warning[BUFSIZ];
00189        sprintf(warning,"%d Uncore and %d Offcore events were ignored",
00190            unc_count,offcore_count);
00191        test_warn( __FILE__, __LINE__, warning, 1 );
00192     }
00193 
00194     if ( add_count > 0 ) {
00195        test_pass( __FILE__, NULL, 0 );
00196     }
00197     else {
00198        test_fail( __FILE__, __LINE__, "No events added", 1 );
00199     }
00200 
00201     exit( 1 );
00202 }

Here is the call graph for this function:


Variable Documentation

unsigned char PENTIUM4

Definition at line 11 of file test_utils.c.


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1