native.c File Reference

Include dependency graph for native.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Variables

static int EventSet = PAPI_NULL
int TESTS_QUIET

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 110 of file native.c.

00111 {
00112     int i, retval, native;
00113     const PAPI_hw_info_t *hwinfo;
00114     long long values[8];
00115 
00116     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00117 
00118     if ( ( retval =
00119            PAPI_library_init( PAPI_VER_CURRENT ) ) != PAPI_VER_CURRENT )
00120         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00121 
00122     if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
00123         test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
00124 
00125     if ( ( hwinfo = PAPI_get_hardware_info(  ) ) == NULL )
00126         test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", PAPI_EMISC );
00127 
00128     printf( "Architecture %s, %d\n", hwinfo->model_string, hwinfo->model );
00129 
00130 #if ((defined(linux) && (defined(__i386__) || (defined __x86_64__))) )
00131     if ( !strncmp( hwinfo->model_string, "Intel Pentium 4", 15 ) ) {
00132         native_name = p4_native_name;
00133     } else if ( !strncmp( hwinfo->model_string, "AMD K7", 6 ) ) {
00134         native_name = k7_native_name;
00135     } else if ( !strncmp( hwinfo->model_string, "AMD K8", 6 ) ) {
00136         native_name = k8_native_name;
00137     } else if ( !strncmp( hwinfo->model_string, "Intel Core", 17 ) ||
00138                 !strncmp( hwinfo->model_string, "Intel Core 2", 17 ) ) {
00139         native_name = core_native_name;
00140     }
00141 #endif
00142 
00143     for ( i = 0; native_name[i] != NULL; i++ ) {
00144         retval = PAPI_event_name_to_code( native_name[i], &native );
00145         if ( retval != PAPI_OK )
00146             test_fail( __FILE__, __LINE__, "PAPI_event_name_to_code", retval );
00147         printf( "Adding %s\n", native_name[i] );
00148         if ( ( retval = PAPI_add_event( EventSet, native ) ) != PAPI_OK )
00149             test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
00150     }
00151 
00152     if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
00153         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00154 
00155     do_both( 1000 );
00156 
00157     if ( ( retval = PAPI_stop( EventSet, values ) ) != PAPI_OK )
00158         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00159 
00160     if ( !TESTS_QUIET ) {
00161         for ( i = 0; native_name[i] != NULL; i++ ) {
00162             fprintf( stderr, "%-40s: ", native_name[i] );
00163             fprintf( stderr, LLDFMT, values[i] );
00164             fprintf( stderr, "\n" );
00165         }
00166     }
00167 
00168     retval = PAPI_cleanup_eventset( EventSet );
00169     if ( retval != PAPI_OK )
00170         test_fail( __FILE__, __LINE__, "PAPI_cleanup", retval );
00171     retval = PAPI_destroy_eventset( &EventSet );
00172     if ( retval != PAPI_OK )
00173         test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
00174 
00175     test_pass( __FILE__, NULL, 0 );
00176     exit( 0 );
00177 }

Here is the call graph for this function:


Variable Documentation

int EventSet = PAPI_NULL [static]

Definition at line 19 of file native.c.

Definition at line 11 of file test_utils.c.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1