max_multiplex.c File Reference

Include dependency graph for max_multiplex.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 9 of file max_multiplex.c.

00009                                 {
00010 
00011   int retval,max_multiplex,i,EventSet=PAPI_NULL;
00012   PAPI_event_info_t info;
00013   int added=0;
00014   int events_tried=0;
00015 
00016         /* Set TESTS_QUIET variable */
00017         tests_quiet( argc, argv );      
00018 
00019     /* Initialize the library */
00020     retval = PAPI_library_init( PAPI_VER_CURRENT );
00021     if ( retval != PAPI_VER_CURRENT ) {
00022        test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00023     }
00024 
00025     retval = PAPI_multiplex_init(  );
00026         if ( retval != PAPI_OK) {
00027        test_fail(__FILE__, __LINE__, "Multiplex not supported", 1);
00028     }
00029 
00030     max_multiplex=PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL );
00031 
00032         if (!TESTS_QUIET) {
00033        printf("Maximum multiplexed counters=%d\n",max_multiplex);
00034     }
00035     
00036     if (!TESTS_QUIET) {
00037        printf("Trying to multiplex as many as possible:\n");
00038     }
00039 
00040     retval = PAPI_create_eventset( &EventSet );
00041     if ( retval != PAPI_OK ) {
00042        test_fail(__FILE__, __LINE__, "PAPI_create_eventset", retval );
00043     }
00044 
00045     retval = PAPI_assign_eventset_component( EventSet, 0 );
00046     if ( retval != PAPI_OK ) {
00047        test_fail(__FILE__, __LINE__, "PAPI_assign_eventset_component", 
00048              retval );
00049     }
00050 
00051     retval = PAPI_set_multiplex( EventSet );
00052     if ( retval != PAPI_OK ) {
00053        test_fail(__FILE__, __LINE__, "PAPI_create_multiplex", retval );
00054     }
00055 
00056 
00057     i = 0 | PAPI_PRESET_MASK;
00058     PAPI_enum_event( &i, PAPI_ENUM_FIRST );
00059     do {
00060       retval = PAPI_get_event_info( i, &info );
00061       if (retval==PAPI_OK) {
00062          if (!TESTS_QUIET) printf("Adding %s: ",info.symbol);
00063       }
00064 
00065       retval = PAPI_add_event( EventSet, info.event_code );
00066       if (retval!=PAPI_OK) {
00067          if (!TESTS_QUIET) printf("Fail!\n");
00068       }
00069       else {
00070          if (!TESTS_QUIET) printf("Success!\n");
00071          added++;
00072       }
00073       events_tried++;
00074 
00075     } while (PAPI_enum_event( &i, PAPI_PRESET_ENUM_AVAIL ) == PAPI_OK );
00076 
00077     PAPI_shutdown(  );
00078 
00079     if (!TESTS_QUIET) {
00080            printf("Added %d of theoretical max %d\n",added,max_multiplex);
00081     }
00082 
00083     if (events_tried<max_multiplex) {
00084        if (!TESTS_QUIET) {
00085               printf("Ran out of events before we ran out of room\n");        
00086        }
00087     }
00088     else if (added!=max_multiplex) {
00089        test_fail(__FILE__, __LINE__, 
00090              "Couldn't max out multiplexed events", 1);
00091     }
00092 
00093     test_pass( __FILE__, NULL, 0 );
00094     exit( 0 );
00095 }

Here is the call graph for this function:


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1