|
PAPI
5.0.1.0
|
00001 /* This file tries to add,start,stop all events in a component it 00002 * is meant not to test the accuracy of the mapping but to make sure 00003 * that all events in the component will at least start (Helps to 00004 * catch typos. 00005 * 00006 * Author: Kevin London 00007 * london@cs.utk.edu 00008 */ 00009 #include "papi_test.h" 00010 00011 int 00012 main( int argc, char **argv ) 00013 { 00014 int retval, i; 00015 int EventSet = PAPI_NULL, count = 0, err_count = 0; 00016 long long values; 00017 PAPI_event_info_t info; 00018 00019 00020 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */ 00021 00022 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00023 if ( retval != PAPI_VER_CURRENT ) 00024 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval ); 00025 00026 retval = PAPI_create_eventset( &EventSet ); 00027 if ( retval != PAPI_OK ) 00028 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval ); 00029 00030 for ( i = 0; i < PAPI_MAX_PRESET_EVENTS; i++ ) { 00031 if ( PAPI_get_event_info( PAPI_PRESET_MASK | i, &info ) != PAPI_OK ) 00032 continue; 00033 if ( !( info.count ) ) 00034 continue; 00035 printf( "Adding %-14s", info.symbol ); 00036 retval = PAPI_add_event( EventSet, ( int ) info.event_code ); 00037 if ( retval != PAPI_OK ) { 00038 PAPI_perror( "PAPI_add_event" ); 00039 err_count++; 00040 } else { 00041 retval = PAPI_start( EventSet ); 00042 if ( retval != PAPI_OK ) { 00043 PAPI_perror( "PAPI_start" ); 00044 err_count++; 00045 } else { 00046 retval = PAPI_stop( EventSet, &values ); 00047 if ( retval != PAPI_OK ) { 00048 PAPI_perror( "PAPI_stop" ); 00049 err_count++; 00050 } else { 00051 printf( "successful\n" ); 00052 count++; 00053 } 00054 } 00055 retval = PAPI_remove_event( EventSet, ( int ) info.event_code ); 00056 if ( retval != PAPI_OK ) 00057 test_fail( __FILE__, __LINE__, "PAPI_remove_event", retval ); 00058 } 00059 } 00060 retval = PAPI_destroy_eventset( &EventSet ); 00061 if ( retval != PAPI_OK ) 00062 test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval ); 00063 00064 printf( "Successfully added, started and stopped %d events.\n", count ); 00065 if ( err_count ) 00066 printf( "Failed to add, start or stop %d events.\n", err_count ); 00067 if ( count > 0 ) 00068 test_pass( __FILE__, NULL, 0 ); 00069 else 00070 test_fail( __FILE__, __LINE__, "No events added", 1 ); 00071 exit( 1 ); 00072 }