PAPI  5.3.0.0
get_event_component.c
Go to the documentation of this file.
00001 /*
00002  * File:    get_event_component.c
00003  * Author:  Vince Weaver
00004  *          vweaver1@eecs.utk.edu
00005  */
00006 
00007 /*
00008   This test makes sure PAPI_get_event_component() works
00009 */
00010 
00011 #include "papi_test.h"
00012 
00013 int
00014 main( int argc, char **argv )
00015 {
00016     
00017     int i;
00018     int retval;
00019     PAPI_event_info_t info;
00020     int numcmp, cid, our_cid;
00021     const PAPI_component_info_t* cmpinfo;
00022 
00023     /* Set TESTS_QUIET variable */
00024     tests_quiet( argc, argv );
00025 
00026     /* Init PAPI library */
00027     retval = PAPI_library_init( PAPI_VER_CURRENT );
00028     if ( retval != PAPI_VER_CURRENT ) {
00029        test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00030     }
00031 
00032     numcmp = PAPI_num_components(  );
00033 
00034 
00035     /* Loop through all components */
00036     for( cid = 0; cid < numcmp; cid++ )
00037     {
00038         cmpinfo = PAPI_get_component_info( cid );
00039 
00040          if (cmpinfo  == NULL)
00041          {
00042             test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );
00043          }
00044 
00045          if (cmpinfo->disabled)
00046          {
00047            printf( "Name:   %-23s %s\n", cmpinfo->name ,cmpinfo->description);
00048            printf("   \\-> Disabled: %s\n",cmpinfo->disabled_reason);
00049            continue;
00050          }
00051 
00052 
00053        i = 0 | PAPI_NATIVE_MASK;
00054        retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cid );
00055        if (retval!=PAPI_OK) continue;
00056 
00057        do {
00058           retval = PAPI_get_event_info( i, &info );
00059       our_cid=PAPI_get_event_component(i);
00060 
00061       if (our_cid!=cid) {
00062          if (!TESTS_QUIET) {
00063             printf("%d %d %s\n",cid,our_cid,info.symbol);
00064          }
00065              test_fail( __FILE__, __LINE__, "component mismatch", 1 );
00066       }
00067 
00068       if (!TESTS_QUIET) {
00069         printf("%d %d %s\n",cid,our_cid,info.symbol);
00070       }
00071 
00072       
00073        } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cid ) == PAPI_OK );
00074 
00075     }
00076 
00077     test_pass( __FILE__, NULL, 0 );
00078    
00079     return 0;
00080 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines