profile_twoevents.c File Reference

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

00017 {
00018     int i, num_tests = 6;
00019     unsigned long length, blength;
00020     int num_buckets, mask;
00021     char title[80];
00022     int retval;
00023     const PAPI_exe_info_t *prginfo;
00024     caddr_t start, end;
00025 
00026     prof_init( argc, argv, &prginfo );
00027 
00028     mask = prof_events( num_tests );
00029     start = prginfo->address_info.text_start;
00030     end = prginfo->address_info.text_end;
00031 
00032     /* Must have at least FP instr or Tot ins */
00033 
00034     if ( ( ( mask & MASK_FP_INS ) == 0 ) && ( ( mask & MASK_TOT_INS ) == 0 ) ) {
00035         test_skip( __FILE__, __LINE__, "No FP or Total Ins. event", 1 );
00036     }
00037 
00038     if ( start > end )
00039         test_fail( __FILE__, __LINE__, "Profile length < 0!", 0 );
00040     length = ( unsigned long ) ( end - start );
00041     prof_print_address
00042         ( "Test case profile: POSIX compatible profiling with two events.\n",
00043           prginfo );
00044     prof_print_prof_info( start, end, THRESHOLD, event_name );
00045     prof_alloc( 2, length );
00046 
00047     blength =
00048         prof_size( length, FULL_SCALE, PAPI_PROFIL_BUCKET_16, &num_buckets );
00049     do_no_profile(  );
00050 
00051     if ( !TESTS_QUIET ) {
00052         printf( "Test type   : \tPAPI_PROFIL_POSIX\n" );
00053     }
00054     if ( ( retval =
00055            PAPI_profil( profbuf[0], ( unsigned int ) blength, start, FULL_SCALE,
00056                         EventSet, PAPI_event, THRESHOLD,
00057                         PAPI_PROFIL_POSIX ) ) != PAPI_OK ) {
00058         test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
00059     }
00060     if ( ( retval =
00061            PAPI_profil( profbuf[1], ( unsigned int ) blength, start, FULL_SCALE,
00062                         EventSet, PAPI_TOT_CYC, THRESHOLD,
00063                         PAPI_PROFIL_POSIX ) ) != PAPI_OK )
00064         test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
00065 
00066     do_stuff(  );
00067 
00068     if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
00069         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00070 
00071     do_stuff(  );
00072 
00073     if ( ( retval = PAPI_stop( EventSet, values[1] ) ) != PAPI_OK )
00074         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00075 
00076     if ( !TESTS_QUIET ) {
00077         printf( TAB1, event_name, ( values[1] )[0] );
00078         printf( TAB1, "PAPI_TOT_CYC:", ( values[1] )[1] );
00079     }
00080     if ( ( retval =
00081            PAPI_profil( profbuf[0], ( unsigned int ) blength, start, FULL_SCALE,
00082                         EventSet, PAPI_event, 0,
00083                         PAPI_PROFIL_POSIX ) ) != PAPI_OK )
00084         test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
00085 
00086     if ( ( retval =
00087            PAPI_profil( profbuf[1], ( unsigned int ) blength, start, FULL_SCALE,
00088                         EventSet, PAPI_TOT_CYC, 0,
00089                         PAPI_PROFIL_POSIX ) ) != PAPI_OK )
00090         test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
00091 
00092     sprintf( title,
00093              "   \t\t    %s\tPAPI_TOT_CYC\naddress\t\t\tcounts\tcounts\n",
00094              event_name );
00095     prof_head( blength, PAPI_PROFIL_BUCKET_16, num_buckets, title );
00096     prof_out( start, 2, PAPI_PROFIL_BUCKET_16, num_buckets, FULL_SCALE );
00097 
00098     remove_test_events( &EventSet, mask );
00099 
00100     retval = prof_check( 2, PAPI_PROFIL_BUCKET_16, num_buckets );
00101 
00102     for ( i = 0; i < 2; i++ ) {
00103         free( profbuf[i] );
00104     }
00105 
00106     if ( retval == 0 )
00107         test_fail( __FILE__, __LINE__, "No information in buffers", 1 );
00108 
00109     test_pass( __FILE__, values, num_tests );
00110 
00111     exit( 1 );
00112 }

Here is the call graph for this function:


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1