PAPI  5.0.1.0
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.

{
    int i, retval, native;
    const PAPI_hw_info_t *hwinfo;
    long long values[8];

    tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */

    if ( ( retval =
           PAPI_library_init( PAPI_VER_CURRENT ) ) != PAPI_VER_CURRENT )
        test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );

    if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );

    if ( ( hwinfo = PAPI_get_hardware_info(  ) ) == NULL )
        test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", PAPI_EMISC );

    printf( "Architecture %s, %d\n", hwinfo->model_string, hwinfo->model );

#if ((defined(linux) && (defined(__i386__) || (defined __x86_64__))) )
    if ( !strncmp( hwinfo->model_string, "Intel Pentium 4", 15 ) ) {
        native_name = p4_native_name;
    } else if ( !strncmp( hwinfo->model_string, "AMD K7", 6 ) ) {
        native_name = k7_native_name;
    } else if ( !strncmp( hwinfo->model_string, "AMD K8", 6 ) ) {
        native_name = k8_native_name;
    } else if ( !strncmp( hwinfo->model_string, "Intel Core", 17 ) ||
                !strncmp( hwinfo->model_string, "Intel Core 2", 17 ) ) {
        native_name = core_native_name;
    }
#endif

    for ( i = 0; native_name[i] != NULL; i++ ) {
        retval = PAPI_event_name_to_code( native_name[i], &native );
        if ( retval != PAPI_OK )
            test_fail( __FILE__, __LINE__, "PAPI_event_name_to_code", retval );
        printf( "Adding %s\n", native_name[i] );
        if ( ( retval = PAPI_add_event( EventSet, native ) ) != PAPI_OK )
            test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
    }

    if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_start", retval );

    do_both( 1000 );

    if ( ( retval = PAPI_stop( EventSet, values ) ) != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_stop", retval );

    if ( !TESTS_QUIET ) {
        for ( i = 0; native_name[i] != NULL; i++ ) {
            fprintf( stderr, "%-40s: ", native_name[i] );
            fprintf( stderr, LLDFMT, values[i] );
            fprintf( stderr, "\n" );
        }
    }

    retval = PAPI_cleanup_eventset( EventSet );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_cleanup", retval );
    retval = PAPI_destroy_eventset( &EventSet );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );

    test_pass( __FILE__, NULL, 0 );
    exit( 0 );
}

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.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines