prof_utils.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define FULL_SCALE   65536

Functions

void prof_init (int argc, char **argv, const PAPI_exe_info_t **prginfo)
int prof_events (int num_tests)
void prof_print_address (char *title, const PAPI_exe_info_t *prginfo)
void prof_print_prof_info (caddr_t start, caddr_t end, int threshold, char *event_name)
void prof_alloc (int num, unsigned long plength)
void prof_head (unsigned long blength, int bucket_size, int num_buckets, char *header)
void prof_out (caddr_t start, int n, int bucket, int num_buckets, unsigned int scale)
unsigned long prof_size (unsigned long plength, unsigned scale, int bucket, int *num_buckets)
int prof_check (int n, int bucket, int num_buckets)
int prof_buckets (int bucket)
void do_no_profile (void)

Variables

long long ** values
char event_name [PAPI_MAX_STR_LEN]
int PAPI_event
int EventSet
void * profbuf [5]

Define Documentation

#define FULL_SCALE   65536

Definition at line 23 of file prof_utils.h.


Function Documentation

void do_no_profile ( void   ) 

Definition at line 126 of file prof_utils.c.

00127 {
00128     int retval;
00129 
00130     if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
00131         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00132 
00133     do_flops( getenv( "NUM_ITERS" ) ? atoi( getenv( "NUM_ITERS" ) ) :
00134               NUM_ITERS );
00135 
00136     if ( ( retval = PAPI_stop( EventSet, values[0] ) ) != PAPI_OK )
00137         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00138 
00139     printf( "Test type   : \t%s\n", "No profiling" );
00140     printf( TAB1, event_name, ( values[0] )[0] );
00141     printf( TAB1, "PAPI_TOT_CYC", ( values[0] )[1] );
00142 }

Here is the call graph for this function:

Here is the caller graph for this function:

void prof_alloc ( int  num,
unsigned long  plength 
)

Definition at line 151 of file prof_utils.c.

00152 {
00153     int i;
00154 
00155     for ( i = 0; i < num; i++ ) {
00156         profbuf[i] = malloc( blength );
00157         if ( profbuf[i] == NULL ) {
00158             test_fail( __FILE__, __LINE__, "malloc", PAPI_ESYS );
00159         }
00160         memset( profbuf[i], 0x00, blength );
00161     }
00162 }

Here is the call graph for this function:

Here is the caller graph for this function:

int prof_buckets ( int  bucket  ) 

Definition at line 171 of file prof_utils.c.

00172 {
00173     int bucket_size;
00174     switch ( bucket ) {
00175     case PAPI_PROFIL_BUCKET_16:
00176         bucket_size = sizeof ( short );
00177         break;
00178     case PAPI_PROFIL_BUCKET_32:
00179         bucket_size = sizeof ( int );
00180         break;
00181     case PAPI_PROFIL_BUCKET_64:
00182         bucket_size = sizeof ( unsigned long long );
00183         break;
00184     default:
00185         bucket_size = 0;
00186         break;
00187     }
00188     return ( bucket_size );
00189 }

Here is the caller graph for this function:

int prof_check ( int  n,
int  bucket,
int  num_buckets 
)

Definition at line 283 of file prof_utils.c.

00284 {
00285     int i, j;
00286     int retval = 0;
00287     unsigned short **buf16 = ( unsigned short ** ) profbuf;
00288     unsigned int **buf32 = ( unsigned int ** ) profbuf;
00289     unsigned long long **buf64 = ( unsigned long long ** ) profbuf;
00290 
00291     switch ( bucket ) {
00292     case PAPI_PROFIL_BUCKET_16:
00293         for ( i = 0; i < num_buckets; i++ )
00294             for ( j = 0; j < n; j++ )
00295                 retval = retval || buf16[j][i];
00296         break;
00297     case PAPI_PROFIL_BUCKET_32:
00298         for ( i = 0; i < num_buckets; i++ )
00299             for ( j = 0; j < n; j++ )
00300                 retval = retval || buf32[j][i];
00301         break;
00302     case PAPI_PROFIL_BUCKET_64:
00303         for ( i = 0; i < num_buckets; i++ )
00304             for ( j = 0; j < n; j++ )
00305                 retval = retval || buf64[j][i];
00306         break;
00307     }
00308     return ( retval );
00309 }

Here is the caller graph for this function:

int prof_events ( int  num_tests  ) 

Definition at line 59 of file prof_utils.c.

00060 {
00061     int retval;
00062     int num_events, mask;
00063 
00064     /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or
00065        PAPI_TOT_INS, depends on the availability of the event on the
00066        platform */
00067     EventSet =
00068         add_two_nonderived_events( &num_events, &PAPI_event, &mask );
00069 
00070     values = allocate_test_space( num_tests, num_events );
00071 
00072     if ( ( retval =
00073            PAPI_event_code_to_name( PAPI_event, event_name ) ) != PAPI_OK )
00074         test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
00075 
00076     return ( mask );
00077 }

Here is the call graph for this function:

Here is the caller graph for this function:

void prof_head ( unsigned long  blength,
int  bucket_size,
int  num_buckets,
char *  header 
)

Definition at line 194 of file prof_utils.c.

00195 {
00196     int bucket_size = prof_buckets( bucket );
00197     printf
00198         ( "\n------------------------------------------------------------\n" );
00199     printf( "PAPI_profil() hash table, Bucket size: %d bits.\n",
00200             bucket_size * 8 );
00201     printf( "Number of buckets: %d.\nLength of buffer: %ld bytes.\n",
00202             num_buckets, blength );
00203     printf( "------------------------------------------------------------\n" );
00204     printf( "%s\n", header );
00205 }

Here is the call graph for this function:

Here is the caller graph for this function:

void prof_init ( int  argc,
char **  argv,
const PAPI_exe_info_t **  prginfo 
)

Definition at line 39 of file prof_utils.c.

00040 {
00041     int retval;
00042 
00043     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00044 
00045     if ( ( retval =
00046            PAPI_library_init( PAPI_VER_CURRENT ) ) != PAPI_VER_CURRENT )
00047         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00048 
00049     if ( ( *prginfo = PAPI_get_executable_info(  ) ) == NULL )
00050         test_fail( __FILE__, __LINE__, "PAPI_get_executable_info", 1 );
00051 }

Here is the call graph for this function:

Here is the caller graph for this function:

void prof_out ( caddr_t  start,
int  n,
int  bucket,
int  num_buckets,
unsigned int  scale 
)

Definition at line 213 of file prof_utils.c.

00215 {
00216     int i, j;
00217     unsigned short buf_16;
00218     unsigned int buf_32;
00219     unsigned long long buf_64;
00220     unsigned short **buf16 = ( unsigned short ** ) profbuf;
00221     unsigned int **buf32 = ( unsigned int ** ) profbuf;
00222     unsigned long long **buf64 = ( unsigned long long ** ) profbuf;
00223 
00224     if ( !TESTS_QUIET ) {
00225         /* printf("%#lx\n",(unsigned long) start + (unsigned long) (2 * i)); */
00226         /* printf("start: %p; i: %#x; scale: %#x; i*scale: %#x; i*scale >>15: %#x\n", start, i, scale, i*scale, (i*scale)>>15); */
00227         switch ( bucket ) {
00228         case PAPI_PROFIL_BUCKET_16:
00229             for ( i = 0; i < num_buckets; i++ ) {
00230                 for ( j = 0, buf_16 = 0; j < n; j++ )
00231                     buf_16 |= ( buf16[j] )[i];
00232                 if ( buf_16 ) {
00233 /* On 32bit builds with gcc 4.3 gcc complained about casting caddr_t => long long
00234  * Thus the unsigned long to long long cast */
00235                     printf( "%#-16llx",
00236                         (long long) (unsigned long)start +
00237                         ( ( ( long long ) i * scale ) >> 15 ) );
00238                     for ( j = 0, buf_16 = 0; j < n; j++ )
00239                         printf( "\t%d", ( buf16[j] )[i] );
00240                     printf( "\n" );
00241                 }
00242             }
00243             break;
00244         case PAPI_PROFIL_BUCKET_32:
00245             for ( i = 0; i < num_buckets; i++ ) {
00246                 for ( j = 0, buf_32 = 0; j < n; j++ )
00247                     buf_32 |= ( buf32[j] )[i];
00248                 if ( buf_32 ) {
00249                     printf( "%#-16llx",
00250                         (long long) (unsigned long)start +
00251                         ( ( ( long long ) i * scale ) >> 15 ) );
00252                     for ( j = 0, buf_32 = 0; j < n; j++ )
00253                         printf( "\t%d", ( buf32[j] )[i] );
00254                     printf( "\n" );
00255                 }
00256             }
00257             break;
00258         case PAPI_PROFIL_BUCKET_64:
00259             for ( i = 0; i < num_buckets; i++ ) {
00260                 for ( j = 0, buf_64 = 0; j < n; j++ )
00261                     buf_64 |= ( buf64[j] )[i];
00262                 if ( buf_64 ) {
00263                     printf( "%#-16llx",
00264                         (long long) (unsigned long)start +
00265                             ( ( ( long long ) i * scale ) >> 15 ) );
00266                     for ( j = 0, buf_64 = 0; j < n; j++ )
00267                         printf( "\t%lld", ( buf64[j] )[i] );
00268                     printf( "\n" );
00269                 }
00270             }
00271             break;
00272         }
00273         printf
00274             ( "------------------------------------------------------------\n\n" );
00275     }
00276 }

Here is the caller graph for this function:

void prof_print_address ( char *  title,
const PAPI_exe_info_t prginfo 
)

Definition at line 82 of file prof_utils.c.

00083 {
00084     printf( "%s\n", title );
00085     printf
00086         ( "----------------------------------------------------------------\n" );
00087     printf( "Text start: %p, Text end: %p, Text length: %#x\n",
00088             prginfo->address_info.text_start, prginfo->address_info.text_end,
00089             ( unsigned int ) ( prginfo->address_info.text_end -
00090                                prginfo->address_info.text_start ) );
00091     printf( "Data start: %p, Data end: %p\n", prginfo->address_info.data_start,
00092             prginfo->address_info.data_end );
00093     printf( "BSS start : %p, BSS end : %p\n", prginfo->address_info.bss_start,
00094             prginfo->address_info.bss_end );
00095 
00096     printf
00097         ( "----------------------------------------------------------------\n" );
00098 }

Here is the caller graph for this function:

void prof_print_prof_info ( caddr_t  start,
caddr_t  end,
int  threshold,
char *  event_name 
)

Definition at line 106 of file prof_utils.c.

00108 {
00109     printf( "Profiling event  : %s\n", event_name );
00110     printf( "Profile Threshold: %d\n", threshold );
00111     printf( "Profile Iters    : %d\n",
00112             ( getenv( "NUM_ITERS" ) ? atoi( getenv( "NUM_ITERS" ) ) :
00113               NUM_ITERS ) );
00114     printf( "Profile Range    : %p to %p\n", start, end );
00115     printf
00116         ( "----------------------------------------------------------------\n" );
00117     printf( "\n" );
00118 }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long prof_size ( unsigned long  plength,
unsigned  scale,
int  bucket,
int *  num_buckets 
)

Definition at line 321 of file prof_utils.c.

00322 {
00323     unsigned long blength;
00324     long long llength = ( ( long long ) plength * scale );
00325     int bucket_size = prof_buckets( bucket );
00326     *num_buckets = ( int ) ( llength / 65536 / 2 );
00327     blength = ( unsigned long ) ( *num_buckets * bucket_size );
00328     return ( blength );
00329 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char event_name[PAPI_MAX_STR_LEN]

Definition at line 23 of file data_range.c.

int EventSet

Definition at line 27 of file cuda_ld_preload_example.c.

Definition at line 24 of file data_range.c.

void* profbuf[5]

Definition at line 28 of file prof_utils.c.

long long** values

Definition at line 24 of file prof_utils.c.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1