multiplex2.c File Reference

Include dependency graph for multiplex2.c:

Go to the source code of this file.

Functions

void init_papi (void)
int case1 (void)
int main (int argc, char **argv)

Function Documentation

int case1 ( void   ) 

Definition at line 31 of file multiplex2.c.

00032 {
00033     int retval, i, EventSet = PAPI_NULL, j = 0, k = 0, allvalid = 1;
00034     int max_mux, nev, *events;
00035     long long *values;
00036     PAPI_event_info_t pset;
00037     char evname[PAPI_MAX_STR_LEN];
00038 
00039     init_papi(  );
00040     init_multiplex(  );
00041 
00042 #if 0
00043     if ( PAPI_set_domain( PAPI_DOM_KERNEL ) != PAPI_OK )
00044         test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
00045 #endif
00046     retval = PAPI_create_eventset( &EventSet );
00047     if ( retval != PAPI_OK )
00048         test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
00049 
00050 #if 0
00051     if ( PAPI_set_domain( PAPI_DOM_KERNEL ) != PAPI_OK )
00052         test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
00053 #endif
00054     /* In Component PAPI, EventSets must be assigned a component index
00055        before you can fiddle with their internals.
00056        0 is always the cpu component */
00057     retval = PAPI_assign_eventset_component( EventSet, 0 );
00058     if ( retval != PAPI_OK )
00059         test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component",
00060                    retval );
00061 #if 0
00062     if ( PAPI_set_domain( PAPI_DOM_KERNEL ) != PAPI_OK )
00063         test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
00064 #endif
00065 
00066     retval = PAPI_set_multiplex( EventSet );
00067         if ( retval == PAPI_ENOSUPP) {
00068        test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
00069     }
00070         else if ( retval != PAPI_OK )
00071         test_fail( __FILE__, __LINE__, "PAPI_set_multiplex", retval );
00072 
00073     max_mux = PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL );
00074     if ( max_mux > 32 )
00075         max_mux = 32;
00076 
00077 #if 0
00078     if ( PAPI_set_domain( PAPI_DOM_KERNEL ) != PAPI_OK )
00079         test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
00080 #endif
00081 
00082     /* Fill up the event set with as many non-derived events as we can */
00083     printf
00084         ( "\nFilling the event set with as many non-derived events as we can...\n" );
00085 
00086     i = PAPI_PRESET_MASK;
00087     do {
00088         if ( PAPI_get_event_info( i, &pset ) == PAPI_OK ) {
00089             if ( pset.count && ( strcmp( pset.derived, "NOT_DERIVED" ) == 0 ) ) {
00090                 retval = PAPI_add_event( EventSet, ( int ) pset.event_code );
00091                 if ( retval != PAPI_OK ) {
00092                    printf("Failed trying to add %s\n",pset.symbol);
00093                    break;
00094                 }
00095                 else {
00096                     printf( "Added %s\n", pset.symbol );
00097                     j++;
00098                 }
00099             }
00100         }
00101     } while ( ( PAPI_enum_event( &i, PAPI_PRESET_ENUM_AVAIL ) == PAPI_OK ) &&
00102               ( j < max_mux ) );
00103 
00104     events = ( int * ) malloc( ( size_t ) j * sizeof ( int ) );
00105     if ( events == NULL )
00106         test_fail( __FILE__, __LINE__, "malloc events", 0 );
00107 
00108     values = ( long long * ) malloc( ( size_t ) j * sizeof ( long long ) );
00109     if ( values == NULL )
00110         test_fail( __FILE__, __LINE__, "malloc values", 0 );
00111 
00112     do_stuff(  );
00113 
00114 #if 0
00115     if ( PAPI_set_domain( PAPI_DOM_KERNEL ) != PAPI_OK )
00116         test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
00117 #endif
00118     
00119     if ( PAPI_start( EventSet ) != PAPI_OK )
00120         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00121 
00122     do_stuff(  );
00123 
00124     retval = PAPI_stop( EventSet, values );
00125     if ( retval != PAPI_OK )
00126         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00127 
00128     nev = j;
00129     retval = PAPI_list_events( EventSet, events, &nev );
00130     if ( retval != PAPI_OK )
00131         test_fail( __FILE__, __LINE__, "PAPI_list_events", retval );
00132 
00133     printf( "\nEvent Counts:\n" );
00134     for ( i = 0, allvalid = 0; i < j; i++ ) {
00135         PAPI_event_code_to_name( events[i], evname );
00136         printf( TAB1, evname, values[i] );
00137         if ( values[i] == 0 )
00138             allvalid++;
00139     }
00140     printf( "\n" );
00141     if ( allvalid ) {
00142         printf( "Caution: %d counters had zero values\n", allvalid );
00143     }
00144    
00145         if (allvalid==j) {
00146        test_fail( __FILE__, __LINE__, "All counters returned zero", 5 );
00147     }
00148 
00149     for ( i = 0, allvalid = 0; i < j; i++ ) {
00150         for ( k = i + 1; k < j; k++ ) {
00151             if ( ( i != k ) && ( values[i] == values[k] ) ) {
00152                 allvalid++;
00153                 break;
00154             }
00155         }
00156     }
00157 
00158     if ( allvalid ) {
00159         printf( "Caution: %d counter pair(s) had identical values\n",
00160                 allvalid );
00161     }
00162 
00163     free( events );
00164     free( values );
00165 
00166     retval = PAPI_cleanup_eventset( EventSet );
00167     if ( retval != PAPI_OK )
00168         test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
00169 
00170     retval = PAPI_destroy_eventset( &EventSet );
00171     if ( retval != PAPI_OK )
00172         test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
00173 
00174     return ( SUCCESS );
00175 }

Here is the call graph for this function:

void init_papi ( void   ) 

Definition at line 16 of file multiplex2.c.

00017 {
00018     int retval;
00019 
00020     /* Initialize the library */
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 }

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 178 of file multiplex2.c.

00179 {
00180 
00181     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00182 
00183     printf( "%s: Does PAPI_multiplex_init() handle lots of events?\n",
00184             argv[0] );
00185     printf( "Using %d iterations\n", NUM_ITERS );
00186 
00187     case1(  );
00188     test_pass( __FILE__, NULL, 0 );
00189     exit( 1 );
00190 }

Here is the call graph for this function:


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1