sprofile.c File Reference

Include dependency graph for ctests/sprofile.c:

Go to the source code of this file.

Defines

#define DO_READS   (unsigned long)(do_reads)
#define DO_FLOPS   (unsigned long)(do_flops)

Functions

int main (int argc, char **argv)

Define Documentation

#define DO_FLOPS   (unsigned long)(do_flops)

Definition at line 23 of file ctests/sprofile.c.

#define DO_READS   (unsigned long)(do_reads)

Definition at line 22 of file ctests/sprofile.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file ctests/sprofile.c.

00033 {
00034     int i, num_events, num_tests = 6, mask = 0x1;
00035     int EventSet = PAPI_NULL;
00036     unsigned short **buf = ( unsigned short ** ) profbuf;
00037     unsigned long length, blength;
00038     int num_buckets;
00039     PAPI_sprofil_t sprof[3];
00040     int retval;
00041     const PAPI_exe_info_t *prginfo;
00042     caddr_t start, end;
00043 
00044     prof_init( argc, argv, &prginfo );
00045 
00046     start = prginfo->address_info.text_start;
00047     end = prginfo->address_info.text_end;
00048     if ( start > end ) {
00049        test_fail( __FILE__, __LINE__, "Profile length < 0!", PAPI_ESYS );
00050     }
00051     length = ( unsigned long ) ( end - start );
00052     prof_print_address
00053         ( "Test case sprofile: POSIX compatible profiling over multiple regions.\n",
00054           prginfo );
00055     blength =
00056         prof_size( length, FULL_SCALE, PAPI_PROFIL_BUCKET_16, &num_buckets );
00057     prof_alloc( 3, blength );
00058 
00059     /* First half */
00060     sprof[0].pr_base = buf[0];
00061     sprof[0].pr_size = ( unsigned int ) blength;
00062     sprof[0].pr_off = ( caddr_t ) DO_FLOPS;
00063 #if defined(linux) && defined(__ia64__)
00064     if ( !TESTS_QUIET )
00065         fprintf( stderr, "do_flops is at %p %p\n", &do_flops, sprof[0].pr_off );
00066 #endif
00067     sprof[0].pr_scale = FULL_SCALE;
00068     /* Second half */
00069     sprof[1].pr_base = buf[1];
00070     sprof[1].pr_size = ( unsigned int ) blength;
00071     sprof[1].pr_off = ( caddr_t ) DO_READS;
00072 #if defined(linux) && defined(__ia64__)
00073     if ( !TESTS_QUIET )
00074         fprintf( stderr, "do_reads is at %p %p\n", &do_reads, sprof[1].pr_off );
00075 #endif
00076     sprof[1].pr_scale = FULL_SCALE;
00077     /* Overflow bin */
00078     sprof[2].pr_base = buf[2];
00079     sprof[2].pr_size = 1;
00080     sprof[2].pr_off = 0;
00081     sprof[2].pr_scale = 0x2;
00082 
00083     EventSet = add_test_events( &num_events, &mask, 1 );
00084 
00085     values = allocate_test_space( num_tests, num_events );
00086 
00087     if ( ( retval = PAPI_sprofil( sprof, 3, EventSet, PAPI_TOT_CYC, THRESHOLD,
00088                                   PAPI_PROFIL_POSIX | PAPI_PROFIL_BUCKET_16 ) )
00089          != PAPI_OK )
00090         test_fail( __FILE__, __LINE__, "PAPI_sprofil", retval );
00091 
00092     do_stuff(  );
00093 
00094     if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
00095         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00096 
00097     do_stuff(  );
00098 
00099     if ( ( retval = PAPI_stop( EventSet, values[1] ) ) != PAPI_OK )
00100         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00101 
00102     /* clear the profile flag before removing the event */
00103     if ( ( retval = PAPI_sprofil( sprof, 3, EventSet, PAPI_TOT_CYC, 0,
00104                                   PAPI_PROFIL_POSIX | PAPI_PROFIL_BUCKET_16 ) )
00105          != PAPI_OK )
00106         test_fail( __FILE__, __LINE__, "PAPI_sprofil", retval );
00107 
00108     remove_test_events( &EventSet, mask );
00109 
00110 
00111 
00112     if ( !TESTS_QUIET ) {
00113         printf( "Test case: PAPI_sprofil()\n" );
00114         printf( "---------Buffer 1--------\n" );
00115         for ( i = 0; i < ( int ) length / 2; i++ ) {
00116             if ( buf[0][i] )
00117                 printf( "%#lx\t%d\n", DO_FLOPS + 2 * ( unsigned long ) i,
00118                         buf[0][i] );
00119         }
00120         printf( "---------Buffer 2--------\n" );
00121         for ( i = 0; i < ( int ) length / 2; i++ ) {
00122             if ( buf[1][i] )
00123                 printf( "%#lx\t%d\n", DO_READS + 2 * ( unsigned long ) i,
00124                         buf[1][i] );
00125         }
00126         printf( "-------------------------\n" );
00127         printf( "%u samples fell outside the regions.\n", *buf[2] );
00128     }
00129     retval = prof_check( 2, PAPI_PROFIL_BUCKET_16, num_buckets );
00130 
00131     for ( i = 0; i < 3; i++ ) {
00132         free( profbuf[i] );
00133     }
00134     if ( retval == 0 )
00135         test_fail( __FILE__, __LINE__, "No information in buffers", 1 );
00136 
00137     test_pass( __FILE__, values, num_tests );
00138 
00139     exit( 1 );
00140 }

Here is the call graph for this function:


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1