inherit.c File Reference

Include dependency graph for inherit.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 11 of file inherit.c.

00012 {
00013     int retval, pid, status, EventSet = PAPI_NULL;
00014     long long int values[] = {0,0};
00015     PAPI_option_t opt;
00016     char event_name[BUFSIZ];
00017 
00018         tests_quiet( argc, argv );
00019 
00020     if ( ( retval = PAPI_library_init( PAPI_VER_CURRENT ) ) != PAPI_VER_CURRENT )
00021         test_fail_exit( __FILE__, __LINE__, "PAPI_library_init", retval );
00022 
00023     if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
00024         test_fail_exit( __FILE__, __LINE__, "PAPI_create_eventset", retval );
00025 
00026     if ( ( retval = PAPI_assign_eventset_component( EventSet, 0 ) ) != PAPI_OK )
00027         test_fail_exit( __FILE__, __LINE__, "PAPI_assign_eventset_component", retval );
00028 
00029     memset( &opt, 0x0, sizeof ( PAPI_option_t ) );
00030     opt.inherit.inherit = PAPI_INHERIT_ALL;
00031     opt.inherit.eventset = EventSet;
00032     if ( ( retval = PAPI_set_opt( PAPI_INHERIT, &opt ) ) != PAPI_OK ) {
00033         if ( retval == PAPI_ECMP) {
00034             test_skip( __FILE__, __LINE__, "Inherit not supported by current component.\n", retval );
00035         } else {
00036             test_fail_exit( __FILE__, __LINE__, "PAPI_set_opt", retval );
00037         }
00038     }
00039 
00040     if ( ( retval = PAPI_query_event( PAPI_TOT_CYC ) ) != PAPI_OK )
00041         test_fail_exit( __FILE__, __LINE__, "PAPI_query_event", retval );
00042 
00043     if ( ( retval = PAPI_add_event( EventSet, PAPI_TOT_CYC ) ) != PAPI_OK )
00044         test_fail_exit( __FILE__, __LINE__, "PAPI_add_event", retval );
00045 
00046     strcpy(event_name,"PAPI_FP_INS");
00047     retval = PAPI_add_named_event( EventSet, event_name );
00048     if (retval == PAPI_ENOEVNT) {
00049         strcpy(event_name,"PAPI_TOT_INS");
00050         retval = PAPI_add_named_event( EventSet, event_name );
00051     }
00052 
00053     if ( retval != PAPI_OK ) {
00054         test_fail_exit( __FILE__, __LINE__, "PAPI_add_event", retval );
00055     }
00056 
00057     if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
00058         test_fail_exit( __FILE__, __LINE__, "PAPI_start", retval );
00059 
00060     pid = fork(  );
00061     if ( pid == 0 ) {
00062         do_flops( NUM_FLOPS );
00063         exit( 0 );
00064     }
00065     if ( waitpid( pid, &status, 0 ) == -1 ) {
00066       perror( "waitpid()" );
00067       exit( 1 );
00068     }
00069 
00070     if ( ( retval = PAPI_stop( EventSet, values ) ) != PAPI_OK )
00071         test_fail_exit( __FILE__, __LINE__, "PAPI_stop", retval );
00072 
00073     if (!TESTS_QUIET) {
00074        printf( "Test case inherit: parent starts, child works, parent stops.\n" );
00075        printf( "------------------------------------------------------------\n" );
00076 
00077        printf( "Test run    : \t1\n" );
00078        printf( "%s : \t%lld\n", event_name, values[1] );
00079        printf( "PAPI_TOT_CYC: \t%lld\n", values[0] );
00080        printf( "------------------------------------------------------------\n" );
00081 
00082        printf( "Verification:\n" );
00083        printf( "Row 1 at least %d\n", NUM_FLOPS );
00084        printf( "Row 2 greater than row 1\n");
00085     }
00086 
00087     if ( values[1] < 100 ) {
00088         test_fail( __FILE__, __LINE__, event_name, 1 );
00089     }
00090 
00091     if ( (!strcmp(event_name,"PAPI_FP_INS")) && (values[1] < NUM_FLOPS)) {
00092         test_fail( __FILE__, __LINE__, "PAPI_FP_INS", 1 );
00093     }
00094 
00095     test_pass( __FILE__, NULL, 0 );
00096     exit( 1 );
00097 }

Here is the call graph for this function:


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1