|
PAPI
5.0.1.0
|

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[(1<< 23)]) |
| 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_t * | hw_info |
| static int | num_events = 0 |
| double | aa [(1<< 23)] |
| double | bb [(1<< 23)] |
| double | s = 0 |
| double | s2 = 0 |
| #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.
| static void cleara | ( | double | a[(1<< 23)] | ) | [static] |
| 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.
{
int i, retval;
unsigned long blength;
int num_buckets,j=0;
int num_bufs = num_events;
int event = num_events;
int events[MAX_TEST_EVENTS];
char header[BUFSIZ];
strncpy(header,"address\t\t",BUFSIZ);
//= "address\t\t\tcyc\tins\tfp_ins\n";
for(i=0;i<MAX_TEST_EVENTS;i++) {
if (mask & test_events[i].mask) {
events[j]=test_events[i].event;
if (events[j]==PAPI_TOT_CYC) {
strncat(header,"\tcyc",BUFSIZ-1);
}
if (events[j]==PAPI_TOT_INS) {
strncat(header,"\tins",BUFSIZ-1);
}
if (events[j]==PAPI_FP_INS) {
strncat(header,"\tfp_ins",BUFSIZ-1);
}
if (events[j]==PAPI_FP_OPS) {
strncat(header,"\tfp_ops",BUFSIZ-1);
}
if (events[j]==PAPI_L2_TCM) {
strncat(header,"\tl2_tcm",BUFSIZ-1);
}
j++;
}
}
strncat(header,"\n",BUFSIZ-1);
blength = prof_size( plength, scale, bucket, &num_buckets );
prof_alloc( num_bufs, blength );
if ( !TESTS_QUIET )
printf( "Overall event counts:\n" );
for ( i = 0; i < num_events; i++ ) {
if ( ( retval =
PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
EventSet, events[i], thresh,
PAPI_PROFIL_POSIX | bucket ) ) != PAPI_OK ) {
if (retval == PAPI_EINVAL) {
test_warn( __FILE__, __LINE__, "Trying to profile with derived event", 1);
num_events=i;
break;
}
else {
printf("Failed with event %d 0x%x\n",i,events[i]);
test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
}
}
}
if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
test_fail( __FILE__, __LINE__, "PAPI_start", retval );
my_main( );
if ( ( retval = PAPI_stop( EventSet, values[0] ) ) != PAPI_OK )
test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
if ( !TESTS_QUIET ) {
printf( TAB1, "PAPI_TOT_CYC:", ( values[0] )[--event] );
if ( strcmp( hw_info->model_string, "POWER6" ) != 0 ) {
printf( TAB1, "PAPI_TOT_INS:", ( values[0] )[--event] );
}
#if defined(__powerpc__)
printf( TAB1, "PAPI_FP_INS", ( values[0] )[--event] );
#else
if ( strcmp( hw_info->model_string, "Intel Pentium III" ) != 0 ) {
printf( TAB1, "PAPI_FP_OPS:", ( values[0] )[--event] );
printf( TAB1, "PAPI_L2_TCM:", ( values[0] )[--event] );
}
#endif
}
for ( i = 0; i < num_events; i++ ) {
if ( ( retval =
PAPI_profil( profbuf[i], ( unsigned int ) blength, start, scale,
EventSet, events[i], 0,
PAPI_PROFIL_POSIX ) ) != PAPI_OK )
test_fail( __FILE__, __LINE__, "PAPI_profil", retval );
}
prof_head( blength, bucket, num_buckets, header );
prof_out( start, num_events, bucket, num_buckets, scale );
retval = prof_check( num_bufs, bucket, num_buckets );
for ( i = 0; i < num_bufs; i++ ) {
free( profbuf[i] );
}
return retval;
}


| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 180 of file byte_profile.c.
{
long length;
int mask;
int retval;
const PAPI_exe_info_t *prginfo;
caddr_t start, end;
prof_init( argc, argv, &prginfo );
hw_info = PAPI_get_hardware_info( );
if ( hw_info == NULL )
test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
mask = MASK_TOT_CYC | MASK_TOT_INS | MASK_FP_OPS | MASK_L2_TCM;
#if defined(__powerpc__)
if ( strcmp( hw_info->model_string, "POWER6" ) == 0 )
mask = MASK_TOT_CYC | MASK_FP_INS;
else
mask = MASK_TOT_CYC | MASK_TOT_INS | MASK_FP_INS;
#endif
#if defined(ITANIUM2)
mask = MASK_TOT_CYC | MASK_FP_OPS | MASK_L2_TCM | MASK_L1_DCM;
#endif
EventSet = add_test_events( &num_events, &mask, 0 );
values = allocate_test_space( 1, num_events );
/* profile the cleara and my_main address space */
start = ( caddr_t ) cleara;
end = ( caddr_t ) my_dummy;
/* Itanium and PowerPC64 processors return function descriptors instead
* of function addresses. You must dereference the descriptor to get the address.
*/
#if defined(ITANIUM1) || defined(ITANIUM2) || defined(__powerpc64__)
start = ( caddr_t ) ( ( ( struct fdesc * ) start )->ip );
end = ( caddr_t ) ( ( ( struct fdesc * ) end )->ip );
#endif
/* call dummy so it doesn't get optimized away */
retval = my_dummy( 1 );
length = end - start;
if ( length < 0 )
test_fail( __FILE__, __LINE__, "Profile length < 0!", ( int ) length );
prof_print_address
( "Test case byte_profile: Multi-event profiling at byte resolution.\n",
prginfo );
prof_print_prof_info( start, end, THRESHOLD, event_name );
retval =
do_profile( start, ( unsigned ) length,
FULL_SCALE * 2, THRESHOLD,
PAPI_PROFIL_BUCKET_32, mask );
remove_test_events( &EventSet, mask );
if ( retval )
test_pass( __FILE__, values, 1 );
else
test_fail( __FILE__, __LINE__, "No information in buffers", 1 );
return 1;
}

| static int my_dummy | ( | int | i | ) | [static] |
Definition at line 44 of file byte_profile.c.
{
return ( i + 1 );
}

| static void my_main | ( | ) | [static] |
Definition at line 50 of file byte_profile.c.
{
int i, j;
for ( j = 0; j < T; j++ ) {
for ( i = 0; i < N; i++ ) {
bb[i] = 0;
}
cleara( aa );
memset( aa, 0, sizeof ( aa ) );
for ( i = 0; i < N; i++ ) {
s += aa[i] * bb[i];
s2 += aa[i] * aa[i] + bb[i] * bb[i];
}
}
}


| double aa[(1<< 23)] |
Definition at line 30 of file byte_profile.c.
| double bb[(1<< 23)] |
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.