byte_profile.c File Reference

Include dependency graph for byte_profile.c:

Go to the source code of this file.

Defines

#define PROFILE_ALL
#define N   (1 << 23)
#define T   (10)

Functions

static void cleara (double a[N])
static int my_dummy (int i)
static void my_main ()
static int do_profile (caddr_t start, unsigned long plength, unsigned scale, int thresh, int bucket, unsigned int mask)
int main (int argc, char **argv)

Variables

static const PAPI_hw_info_thw_info
static int num_events = 0
double aa [N]
double bb [N]
double s = 0
double s2 = 0

Define Documentation

#define N   (1 << 23)

Definition at line 27 of file byte_profile.c.

#define PROFILE_ALL

Definition at line 21 of file byte_profile.c.

#define T   (10)

Definition at line 28 of file byte_profile.c.


Function Documentation

static void cleara ( double  a[N]  )  [static]

Definition at line 34 of file byte_profile.c.

00035 {
00036     int i;
00037 
00038     for ( i = 0; i < N; i++ ) {
00039         a[i] = 0;
00040     }
00041 }

Here is the caller graph for this function:

static int do_profile ( caddr_t  start,
unsigned long  plength,
unsigned  scale,
int  thresh,
int  bucket,
unsigned int  mask 
) [static]

Definition at line 68 of file byte_profile.c.

00069                                         {
00070 
00071     int i, retval;
00072     unsigned long blength;
00073     int num_buckets,j=0;
00074 
00075     int num_bufs = num_events;
00076     int event = num_events;
00077 
00078     int events[MAX_TEST_EVENTS];
00079     char header[BUFSIZ];
00080 
00081     strncpy(header,"address\t\t",BUFSIZ);
00082 
00083     //= "address\t\t\tcyc\tins\tfp_ins\n";
00084 
00085     for(i=0;i<MAX_TEST_EVENTS;i++) {
00086       if (mask & test_events[i].mask) {
00087         events[j]=test_events[i].event;
00088 
00089         if (events[j]==PAPI_TOT_CYC) {
00090            strncat(header,"\tcyc",BUFSIZ-1);
00091         }
00092         if (events[j]==PAPI_TOT_INS) {
00093            strncat(header,"\tins",BUFSIZ-1);
00094         }
00095         if (events[j]==PAPI_FP_INS) {
00096            strncat(header,"\tfp_ins",BUFSIZ-1);
00097         }
00098         if (events[j]==PAPI_FP_OPS) {
00099            strncat(header,"\tfp_ops",BUFSIZ-1);
00100         }
00101         if (events[j]==PAPI_L2_TCM) {
00102            strncat(header,"\tl2_tcm",BUFSIZ-1);
00103         }
00104 
00105         j++;
00106 
00107       }
00108     }
00109 
00110     strncat(header,"\n",BUFSIZ-1);
00111 
00112 
00113 
00114     blength = prof_size( plength, scale, bucket, &num_buckets );
00115     prof_alloc( num_bufs, blength );
00116 
00117     if ( !TESTS_QUIET )
00118         printf( "Overall event counts:\n" );
00119 
00120     for ( i = 0; i < num_events; i++ ) {
00121         if ( ( retval =
00122                PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
00123                             EventSet, events[i], thresh,
00124                             PAPI_PROFIL_POSIX | bucket ) ) != PAPI_OK ) {
00125                if (retval == PAPI_EINVAL) {
00126               test_warn( __FILE__, __LINE__, "Trying to profile with derived event", 1);
00127               num_events=i;
00128               break;
00129            }
00130                    else {
00131                 printf("Failed with event %d %#x\n",i,events[i]);
00132             test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
00133            }
00134         }
00135     }
00136 
00137     if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
00138         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00139 
00140     my_main(  );
00141 
00142     if ( ( retval = PAPI_stop( EventSet, values[0] ) ) != PAPI_OK )
00143         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00144 
00145     if ( !TESTS_QUIET ) {
00146         printf( TAB1, "PAPI_TOT_CYC:", ( values[0] )[--event] );
00147         if ( strcmp( hw_info->model_string, "POWER6" ) != 0 ) {
00148             printf( TAB1, "PAPI_TOT_INS:", ( values[0] )[--event] );
00149         }
00150 #if defined(__powerpc__)
00151         printf( TAB1, "PAPI_FP_INS", ( values[0] )[--event] );
00152 #else
00153         if ( strcmp( hw_info->model_string, "Intel Pentium III" ) != 0 ) {
00154             printf( TAB1, "PAPI_FP_OPS:", ( values[0] )[--event] );
00155             printf( TAB1, "PAPI_L2_TCM:", ( values[0] )[--event] );
00156         }
00157 #endif
00158     }
00159 
00160     for ( i = 0; i < num_events; i++ ) {
00161         if ( ( retval =
00162                PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
00163                             EventSet, events[i], 0,
00164                             PAPI_PROFIL_POSIX ) ) != PAPI_OK )
00165             test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
00166     }
00167 
00168     prof_head( blength, bucket, num_buckets, header );
00169     prof_out( start, num_events, bucket, num_buckets, scale );
00170     retval = prof_check( num_bufs, bucket, num_buckets );
00171     for ( i = 0; i < num_bufs; i++ ) {
00172         free( profbuf[i] );
00173     }
00174     return retval;
00175 }

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 180 of file byte_profile.c.

00181 {
00182     long length;
00183     int mask;
00184     int retval;
00185     const PAPI_exe_info_t *prginfo;
00186     caddr_t start, end;
00187 
00188     prof_init( argc, argv, &prginfo );
00189 
00190     hw_info = PAPI_get_hardware_info(  );
00191         if ( hw_info == NULL )
00192       test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
00193 
00194         mask = MASK_TOT_CYC | MASK_TOT_INS | MASK_FP_OPS | MASK_L2_TCM;
00195 
00196 #if defined(__powerpc__)
00197     if ( strcmp( hw_info->model_string, "POWER6" ) == 0 )
00198         mask = MASK_TOT_CYC | MASK_FP_INS;
00199     else
00200         mask = MASK_TOT_CYC | MASK_TOT_INS | MASK_FP_INS;
00201 #endif
00202 
00203 #if defined(ITANIUM2)
00204     mask = MASK_TOT_CYC | MASK_FP_OPS | MASK_L2_TCM | MASK_L1_DCM;
00205 #endif
00206     EventSet = add_test_events( &num_events, &mask, 0 );
00207     values = allocate_test_space( 1, num_events );
00208 
00209 /* profile the cleara and my_main address space */
00210     start = ( caddr_t ) cleara;
00211     end = ( caddr_t ) my_dummy;
00212 
00213 /* Itanium and PowerPC64 processors return function descriptors instead
00214  * of function addresses. You must dereference the descriptor to get the address.
00215 */
00216 #if defined(ITANIUM1) || defined(ITANIUM2) \
00217     || (defined(__powerpc64__) && (_CALL_ELF != 2))
00218     start = ( caddr_t ) ( ( ( struct fdesc * ) start )->ip );
00219     end = ( caddr_t ) ( ( ( struct fdesc * ) end )->ip );
00220         /* PPC64 Big Endian is ELF version 1 which uses function descriptors.
00221          *  PPC64 Little Endian is ELF version 2 which does not use
00222          * function descriptors
00223          */
00224 #endif
00225 
00226     /* call dummy so it doesn't get optimized away */
00227     retval = my_dummy( 1 );
00228 
00229     length = end - start;
00230     if ( length < 0 )
00231         test_fail( __FILE__, __LINE__, "Profile length < 0!", ( int ) length );
00232 
00233     prof_print_address
00234         ( "Test case byte_profile: Multi-event profiling at byte resolution.\n",
00235           prginfo );
00236     prof_print_prof_info( start, end, THRESHOLD, event_name );
00237 
00238     retval =
00239         do_profile( start, ( unsigned ) length, 
00240                 FULL_SCALE * 2, THRESHOLD,
00241                 PAPI_PROFIL_BUCKET_32, mask );
00242 
00243     remove_test_events( &EventSet, mask );
00244 
00245     if ( retval )
00246         test_pass( __FILE__, values, 1 );
00247     else
00248         test_fail( __FILE__, __LINE__, "No information in buffers", 1 );
00249     return 1;
00250 }

Here is the call graph for this function:

static int my_dummy ( int  i  )  [static]

Definition at line 44 of file byte_profile.c.

00045 {
00046     return ( i + 1 );
00047 }

Here is the caller graph for this function:

static void my_main (  )  [static]

Definition at line 50 of file byte_profile.c.

00051 {
00052     int i, j;
00053 
00054     for ( j = 0; j < T; j++ ) {
00055         for ( i = 0; i < N; i++ ) {
00056             bb[i] = 0;
00057         }
00058         cleara( aa );
00059         memset( aa, 0, sizeof ( aa ) );
00060         for ( i = 0; i < N; i++ ) {
00061             s += aa[i] * bb[i];
00062             s2 += aa[i] * aa[i] + bb[i] * bb[i];
00063         }
00064     }
00065 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

double aa[N]

Definition at line 30 of file byte_profile.c.

double bb[N]

Definition at line 30 of file byte_profile.c.

const PAPI_hw_info_t* hw_info [static]

Definition at line 23 of file byte_profile.c.

int num_events = 0 [static]

Definition at line 25 of file byte_profile.c.

double s = 0

Definition at line 31 of file byte_profile.c.

double s2 = 0

Definition at line 31 of file byte_profile.c.


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1