PAPI  5.0.1.0
papi_test.h File Reference
Include dependency graph for papi_test.h:

Go to the source code of this file.

Data Structures

struct  test_events_t

Defines

#define MASK_FP_OPS   0x80000
#define MASK_L1_DCA   0x40000 /* three new events for POWER4 */
#define MASK_L1_DCW   0x20000
#define MASK_L1_DCR   0x10000
#define MASK_TOT_IIS   0x04000 /* Try this if TOT_INS won't work */
#define MASK_BR_PRC   0x02000
#define MASK_BR_MSP   0x01000
#define MASK_BR_CN   0x00800
#define MASK_L2_TCH   0x00400
#define MASK_L2_TCA   0x00200
#define MASK_L2_TCM   0x00100
#define MASK_L1_DCM   0x00040
#define MASK_L1_ICM   0x00020
#define MASK_L1_TCM   0x00010
#define MASK_FP_INS   0x00004
#define MASK_TOT_INS   0x00002
#define MASK_TOT_CYC   0x00001
#define MAX_TEST_EVENTS   18
#define ONEHDR   " %12s"
#define TAB2HDR   "%s %12s %12s\n"
#define TAB3HDR   "%s %12s %12s %12s\n"
#define TAB4HDR   "%s %12s %12s %12s %12s\n"
#define ONENUM   " %12lld"
#define TAB1   "%-12s %12lld\n"
#define TAB2   "%-12s %12lld %12lld\n"
#define TAB3   "%-12s %12lld %12lld %12lld\n"
#define TAB4   "%-12s %12lld %12lld %12lld %12lld\n"
#define TAB5   "%-12s %12lld %12lld %12lld %12lld %12lld\n"
#define TWO12   "%12lld %12lld %s"
#define LLDFMT   "%lld"
#define LLDFMT10   "%10lld"
#define LLDFMT12   "%12lld"
#define LLDFMT15   "%15lld"
#define printf   if (!TESTS_QUIET) printf

Functions

int papi_print_header (char *prompt, const PAPI_hw_info_t **hwinfo)
void validate_string (char *name, char *s)
void * get_overflow_address (void *context)
void free_test_space (long long **values, int num_tests)
long long ** allocate_test_space (int num_tests, int num_events)
int add_test_events (int *number, int *mask, int allow_derived)
int add_two_events (int *num_events, int *papi_event, int *mask)
int add_two_nonderived_events (int *num_events, int *papi_event, int *mask)
int add_test_events_r (int *number, int *mask, void *handle)
int find_nonderived_event (void)
int enum_add_native_events (int *num_events, int **evtcodes, int need_interrupts, int no_software_events, int cidx)
int remove_test_events (int *EventSet, int mask)
void do_flush (void)
void do_misses (int n, int size)
void do_flops (int n)
void fdo_flops (int *n)
void do_reads (int n)
void do_both (int n)
void do_l1misses (int n)
void do_stuff (void)
void dummy (void *)
char * stringify_domain (int domain)
char * stringify_all_domains (int domains)
char * stringify_granularity (int granularity)
char * stringify_all_granularities (int granularities)
void tests_quiet (int argc, char **argv)
void test_pass (char *file, long long **values, int num_tests)
void test_fail (char *file, int line, char *call, int retval)
void test_fail_exit (char *file, int line, char *call, int retval)
void test_skip (char *file, int line, char *call, int retval)
void test_warn (char *file, int line, char *call, int retval)
void test_print_event_header (char *call, int evset)
void touch_dummy (double *ptr, int size)
int approx_equals (double a, double b)
void init_multiplex (void)
void clockcore (void)

Variables

struct test_events_t test_events []
int TESTS_QUIET

Define Documentation

#define LLDFMT   "%lld"

Definition at line 118 of file papi_test.h.

#define LLDFMT10   "%10lld"

Definition at line 119 of file papi_test.h.

#define LLDFMT12   "%12lld"

Definition at line 120 of file papi_test.h.

#define LLDFMT15   "%15lld"

Definition at line 121 of file papi_test.h.

#define MASK_BR_CN   0x00800

Definition at line 40 of file papi_test.h.

#define MASK_BR_MSP   0x01000

Definition at line 39 of file papi_test.h.

#define MASK_BR_PRC   0x02000

Definition at line 38 of file papi_test.h.

#define MASK_FP_INS   0x00004

Definition at line 47 of file papi_test.h.

#define MASK_FP_OPS   0x80000

Definition at line 33 of file papi_test.h.

#define MASK_L1_DCA   0x40000 /* three new events for POWER4 */

Definition at line 34 of file papi_test.h.

#define MASK_L1_DCM   0x00040

Definition at line 44 of file papi_test.h.

#define MASK_L1_DCR   0x10000

Definition at line 36 of file papi_test.h.

#define MASK_L1_DCW   0x20000

Definition at line 35 of file papi_test.h.

#define MASK_L1_ICM   0x00020

Definition at line 45 of file papi_test.h.

#define MASK_L1_TCM   0x00010

Definition at line 46 of file papi_test.h.

#define MASK_L2_TCA   0x00200

Definition at line 42 of file papi_test.h.

#define MASK_L2_TCH   0x00400

Definition at line 41 of file papi_test.h.

#define MASK_L2_TCM   0x00100

Definition at line 43 of file papi_test.h.

#define MASK_TOT_CYC   0x00001

Definition at line 49 of file papi_test.h.

#define MASK_TOT_IIS   0x04000 /* Try this if TOT_INS won't work */

Definition at line 37 of file papi_test.h.

#define MASK_TOT_INS   0x00002

Definition at line 48 of file papi_test.h.

#define MAX_TEST_EVENTS   18

Definition at line 51 of file papi_test.h.

#define ONEHDR   " %12s"

Definition at line 107 of file papi_test.h.

#define ONENUM   " %12lld"

Definition at line 111 of file papi_test.h.

#define printf   if (!TESTS_QUIET) printf

Definition at line 125 of file papi_test.h.

#define TAB1   "%-12s %12lld\n"

Definition at line 112 of file papi_test.h.

#define TAB2   "%-12s %12lld %12lld\n"

Definition at line 113 of file papi_test.h.

#define TAB2HDR   "%s %12s %12s\n"

Definition at line 108 of file papi_test.h.

#define TAB3   "%-12s %12lld %12lld %12lld\n"

Definition at line 114 of file papi_test.h.

#define TAB3HDR   "%s %12s %12s %12s\n"

Definition at line 109 of file papi_test.h.

#define TAB4   "%-12s %12lld %12lld %12lld %12lld\n"

Definition at line 115 of file papi_test.h.

#define TAB4HDR   "%s %12s %12s %12s %12s\n"

Definition at line 110 of file papi_test.h.

#define TAB5   "%-12s %12lld %12lld %12lld %12lld %12lld\n"

Definition at line 116 of file papi_test.h.

#define TWO12   "%12lld %12lld %s"

Definition at line 117 of file papi_test.h.


Function Documentation

int add_test_events ( int *  number,
int *  mask,
int  allow_derived 
)

Definition at line 213 of file test_utils.c.

{
  int retval,i;
  int EventSet = PAPI_NULL;
  int num_counters = 0;
  char name_string[BUFSIZ];

  *number = 0;

     /* get the number of available HW counters */
  num_counters = PAPI_get_opt( PAPI_MAX_HWCTRS, NULL );
  if ( num_counters < 1 ) {
     test_fail( __FILE__, __LINE__, "Zero HW Counters available", 
               num_counters );
  }

     /* create the eventset */
  retval = PAPI_create_eventset( &EventSet );
  if ( retval != PAPI_OK ) {
     test_fail( __FILE__, __LINE__, "PAPI_create_eventset", 
               retval );
  }

     /* check all the masks */
  for(i=0;i<MAX_TEST_EVENTS;i++) {
    
     if ( *mask & test_events[i].mask ) {

           /* remove any derived events if told to */
        if ((is_event_derived(test_events[i].event)) && (!allow_derived)) {
       *mask = *mask ^ test_events[i].mask;
       continue;
        }

    retval = PAPI_add_event( EventSet, test_events[i].event );

    if ( retval == PAPI_OK ) {

       ( *number )++;
#if 0
       if ((*number)==num_counters) {
         if ( !TESTS_QUIET) {
           fprintf(stdout, "Stopping with %d events due to HW limit\n",
               num_counters);
         }
         break;
       }
#endif
    }
    else {
       if ( !TESTS_QUIET ) {
         PAPI_event_code_to_name(test_events[i].event,name_string);
         fprintf( stdout, "%x %s is not available.\n", 
              test_events[i].event,name_string);
       }
       *mask = *mask ^ test_events[i].mask;
    }
     }
  }

  return EventSet;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int add_test_events_r ( int *  number,
int *  mask,
void *  handle 
)
int add_two_events ( int *  num_events,
int *  papi_event,
int *  mask 
)

Definition at line 680 of file test_utils.c.

                                                              {

     /* query and set up the right event to monitor */
  int EventSet = PAPI_NULL;
  PAPI_event_info_t info;
  unsigned int potential_evt_to_add[3][2] =
    { {( unsigned int ) PAPI_FP_INS, MASK_FP_INS},
      {( unsigned int ) PAPI_FP_OPS, MASK_FP_OPS},
      {( unsigned int ) PAPI_TOT_INS, MASK_TOT_INS}
    };
  int i = 0;
  int counters = 0;

  *mask = 0;
  counters = PAPI_num_hwctrs(  );

  if (counters<=0) {
     test_fail(__FILE__,__LINE__,"Zero Counters Available!  PAPI Won't like this!\n",0);
  }

  /* This code tries to ensure that the event  generated will fit in the */
  /* number of available counters. It has the potential to leak up to    */
  /* two event sets if events fail to add successfully.                  */

  for(i=0;i<3;i++) {
    if ( PAPI_query_event( (int) potential_evt_to_add[i][0] ) == PAPI_OK ) {
        if ( PAPI_get_event_info( (int) potential_evt_to_add[i][0], &info ) == PAPI_OK ) {
            if ( ( info.count > 0 ) && ( (unsigned) counters > info.count ) ) {
                *papi_event = ( int ) potential_evt_to_add[i][0];
                *mask = ( int ) potential_evt_to_add[i][1] | MASK_TOT_CYC;
                EventSet = add_test_events( num_events, mask, 1 );
                if ( *num_events == 2 ) break;
            }
        }
    }
  }
  if ( i == 3 ) {
     test_fail( __FILE__, __LINE__, "Not enough room to add an event!", 0 );
  }
  return EventSet;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int add_two_nonderived_events ( int *  num_events,
int *  papi_event,
int *  mask 
)

Definition at line 723 of file test_utils.c.

                                                                         {

    /* query and set up the right event to monitor */
  int EventSet = PAPI_NULL;

#define POTENTIAL_EVENTS 3

  unsigned int potential_evt_to_add[POTENTIAL_EVENTS][2] =
        { {( unsigned int ) PAPI_FP_INS, MASK_FP_INS},
          {( unsigned int ) PAPI_FP_OPS, MASK_FP_OPS},
          {( unsigned int ) PAPI_TOT_INS, MASK_TOT_INS}
        };

  int i;

  *mask = 0;
  
   /* could leak up to two event sets. */
  for(i=0;i<POTENTIAL_EVENTS;i++) {

     if ( PAPI_query_event( ( int ) potential_evt_to_add[i][0] ) == PAPI_OK ) {
       if ( !is_event_derived(potential_evt_to_add[i][0])) {
         *papi_event = ( int ) potential_evt_to_add[i][0];
         *mask = ( int ) potential_evt_to_add[i][1] | MASK_TOT_CYC;
         EventSet = add_test_events( num_events, mask, 0 );
         if ( *num_events == 2 ) break;
       }
    }
  }
    
  if ( i == POTENTIAL_EVENTS ) {
     test_fail( __FILE__, __LINE__, "Can't find a non-derived event!", 0 );
  }
  return EventSet;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long long** allocate_test_space ( int  num_tests,
int  num_events 
)

Definition at line 107 of file test_utils.c.

{
    long long **values;
    int i;

    values =
        ( long long ** ) malloc( ( size_t ) num_tests *
                                 sizeof ( long long * ) );
    if ( values == NULL )
        exit( 1 );
    memset( values, 0x0, ( size_t ) num_tests * sizeof ( long long * ) );

    for ( i = 0; i < num_tests; i++ ) {
        values[i] =
            ( long long * ) malloc( ( size_t ) num_events *
                                    sizeof ( long long ) );
        if ( values[i] == NULL )
            exit( 1 );
        memset( values[i], 0x00, ( size_t ) num_events * sizeof ( long long ) );
    }
    return ( values );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int approx_equals ( double  a,
double  b 
)

Definition at line 94 of file test_utils.c.

{
    if ( ( a >= b * ( 1.0 - TOLERANCE ) ) && ( a <= b * ( 1.0 + TOLERANCE ) ) )
        return 1;
    else {
        printf( "Out of tolerance range %2.2f: %.0f vs %.0f [%.0f,%.0f]\n",
                TOLERANCE, a, b, b * ( 1.0 - TOLERANCE ),
                b * ( 1.0 + TOLERANCE ) );
        return 0;
    }
}

Here is the caller graph for this function:

void clockcore ( void  )

Definition at line 99 of file clockcore.c.

{
    /* check PAPI_get_real_cyc */
    clock_res_check( 0 );
    /* check PAPI_get_real_usec */
    clock_res_check( 1 );

    /* check PAPI_get_virt_cyc */
    /* Virtual */
    if ( PAPI_get_virt_cyc(  ) != -1 ) {
        clock_res_check( 2 );
    } else
        test_fail( __FILE__, __LINE__, "PAPI_get_virt_cyc", -1 );

    /* check PAPI_get_virt_usec */
    if ( PAPI_get_virt_usec(  ) != -1 ) {
        clock_res_check( 3 );
    } else
        test_fail( __FILE__, __LINE__, "PAPI_get_virt_usec", -1 );
}
void do_both ( int  n)

Definition at line 37 of file examples/sprofile.c.

{
   int i;
   const int flops2 = NUM_FLOPS / n;
   const int flops1 = NUM_FLOPS / n;

   for (i = 0; i < n; i++) 
   {
      do_flops1(flops1);
      do_flops2(flops2);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void do_flops ( int  n)

Definition at line 23 of file multiplex.c.

{
    int i;
    double a = 0.5;
    double b = 6.2;

    for (i=0; i < n; i++)
        c += a * b;
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void do_flush ( void  )

Definition at line 166 of file do_loops.c.

{
    register int i;
    if ( flush == NULL )
        flush = ( int * ) malloc( ( 1024 * 1024 * 16 ) * sizeof ( int ) );
    if ( !flush )
        return;

    dummy( ( void * ) flush );
    for ( i = 0; i < ( 1024 * 1024 * 16 ); i++ ) {
        flush[i] += flush_dummy;
    }
    flush_dummy++;
    dummy( ( void * ) flush );
    dummy( ( void * ) &flush_dummy );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void do_l1misses ( int  n)

Definition at line 214 of file do_loops.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void do_misses ( int  n,
int  size 
)

Definition at line 113 of file do_loops.c.

{
    register int i, j, tmp = buf_dummy, len = bytes / ( int ) sizeof ( int );
    dummy( ( void * ) buf );
    dummy( ( void * ) &buf_dummy );
    assert( len <= CACHE_FLUSH_BUFFER_SIZE_INTS );
    n = n / 2;
    for ( j = 0; j < n; j++ ) {
        for ( i = 0; i < len; i++ ) {
            /* We need to read, modify, write here to look
               out for the write allocate policies. */
            buf[i] += tmp;
            /* Fake out some naive prefetchers */
            buf[len - 1 - i] -= tmp;
        }
        tmp += len;
    }
    buf_dummy = tmp;
    dummy( ( void * ) buf );
    dummy( ( void * ) &buf_dummy );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void do_reads ( int  n)

Definition at line 12 of file do_loops.c.

{
    int i, retval;
    static int fd = -1;
    char buf;

    if ( fd == -1 ) {
        fd = open( "/dev/zero", O_RDONLY );
        if ( fd == -1 ) {
            perror( "open(/dev/zero)" );
            exit( 1 );
        }
    }

    for ( i = 0; i < n; i++ ) {
        retval = ( int ) read( fd, &buf, sizeof ( buf ) );
        if ( retval != sizeof ( buf ) ) {
            if ( retval < 0 )
                perror( "/dev/zero cannot be read" );
            else
                fprintf( stderr,
                         "/dev/zero cannot be read: only got %d bytes.\n",
                         retval );
            exit( 1 );
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void do_stuff ( void  )

Definition at line 250 of file do_loops.c.

{
    static int loops = 0;

    if ( loops == 0 ) {
        struct timeval now, then;
        gettimeofday( &then, NULL );
        do {
            do_flops( NUM_FLOPS );
            do_reads( NUM_READS );
            do_misses( 1, 1024 * 1024 );
            gettimeofday( &now, NULL );
            loops++;
        } while ( now.tv_sec - then.tv_sec < NUM_WORK_SECONDS );
    } else {
        int i = 0;
        do {
            do_flops( NUM_FLOPS );
            do_reads( NUM_READS );
            do_misses( 1, 1024 * 1024 );
            i++;
        } while ( i < loops );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dummy ( void *  )

Definition at line 4 of file dummy.c.

{
/* Confuse the compiler so as not to optimize
   away the flops in the calling routine    */
/* Cast the array as a void to eliminate unused argument warning */
    ( void ) array;
}
int enum_add_native_events ( int *  num_events,
int **  evtcodes,
int  need_interrupts,
int  no_software_events,
int  cidx 
)

Definition at line 761 of file test_utils.c.

{
    /* query and set up the right event to monitor */
     int EventSet = PAPI_NULL;
     int i = 0, k, event_code, retval;
     int counters, event_found = 0;
     PAPI_event_info_t info;
     const PAPI_component_info_t *s = NULL;
     const PAPI_hw_info_t *hw_info = NULL;
   
     s = PAPI_get_component_info( cidx );
     if ( s == NULL ) {
    test_fail( __FILE__, __LINE__, 
               "PAPI_get_component_info", PAPI_ECMP );
     }

     hw_info = PAPI_get_hardware_info(  );
     if ( hw_info == NULL ) {
        test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
     }
   
     counters = PAPI_num_hwctrs(  );
     if (counters<1) {
    test_fail(__FILE__,__LINE__, "No counters available!\n",1);
     }

     if (!TESTS_QUIET) printf("Trying to fill %d hardware counters...\n",
                  counters);
   
     if (need_interrupt) {
        if ( (!strcmp(hw_info->model_string,"POWER6")) ||
         (!strcmp(hw_info->model_string,"POWER5")) ) {
       
       test_warn(__FILE__, __LINE__,
            "Limiting num_counters because of LIMITED_PMC on Power5 and Power6",1);
           counters=4;
    }
     }

     ( *evtcodes ) = ( int * ) calloc( counters, sizeof ( int ) );

     retval = PAPI_create_eventset( &EventSet );
     if ( retval != PAPI_OK ) {
    test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
     }

     /* For platform independence, always ASK FOR the first event */
     /* Don't just assume it'll be the first numeric value */
     i = 0 | PAPI_NATIVE_MASK;
     PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cidx );

     do {
        retval = PAPI_get_event_info( i, &info );

    /* HACK! FIXME */
        if (no_software_events && ( strstr(info.symbol,"PERF_COUNT_SW") || strstr(info.long_descr, "PERF_COUNT_SW") ) ) {
       if (!TESTS_QUIET) {
          printf("Blocking event %s as a SW event\n", info.symbol);
       }
       continue;
    }

    if ( s->cntr_umasks ) {
       k = i;
            
       if ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cidx ) == PAPI_OK ) {
          do {
             retval = PAPI_get_event_info( k, &info );
         event_code = ( int ) info.event_code;

         retval = PAPI_add_event( EventSet, event_code );
         if ( retval == PAPI_OK ) {
            ( *evtcodes )[event_found] = event_code;
            if ( !TESTS_QUIET ) {
               printf( "event_code[%d] = 0x%x (%s)\n",
                   event_found, event_code, info.symbol );
            }
            event_found++;
         } else {
            if ( !TESTS_QUIET ) {
               printf( "0x%x (%s) can't be added to the EventSet.\n",
                   event_code, info.symbol );
            }
         }
          } while ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cidx ) == PAPI_OK
                        && event_found < counters );
       } else {
          event_code = ( int ) info.event_code;
          retval = PAPI_add_event( EventSet, event_code );
          if ( retval == PAPI_OK ) {
          ( *evtcodes )[event_found] = event_code;
          if ( !TESTS_QUIET ) {
             printf( "event_code[%d] = 0x%x (%s)\n",
                   event_found, event_code, info.symbol );
          }
          event_found++;
          }
       }
       if ( !TESTS_QUIET && retval == PAPI_OK ) {
         /* */
       }
    } else {
            event_code = ( int ) info.event_code;
            retval = PAPI_add_event( EventSet, event_code );
            if ( retval == PAPI_OK ) {
                ( *evtcodes )[event_found] = event_code;
                event_found++;
            } else {
                if ( !TESTS_QUIET )
                    fprintf( stdout, "0x%x is not available.\n", event_code );
            }
        }
    }
     while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cidx ) == PAPI_OK &&
            event_found < counters );

    *num_events = ( int ) event_found;

    if (!TESTS_QUIET) printf("Tried to fill %d counters with events, "
                 "found %d\n",counters,event_found);

    return EventSet;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fdo_flops ( int *  n)

Definition at line 83 of file do_loops.c.

{
    do_flops( *n );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int find_nonderived_event ( void  )

Definition at line 159 of file test_utils.c.

{
    /* query and set up the right event to monitor */
    PAPI_event_info_t info;
    int potential_evt_to_add[3] = { PAPI_FP_OPS, PAPI_FP_INS, PAPI_TOT_INS };
    int i;

    for ( i = 0; i < 3; i++ ) {
        if ( PAPI_query_event( potential_evt_to_add[i] ) == PAPI_OK ) {
            if ( PAPI_get_event_info( potential_evt_to_add[i], &info ) ==
                 PAPI_OK ) {
                if ( ( info.count > 0 ) &&
                     !strcmp( info.derived, "NOT_DERIVED" ) )
                    return ( potential_evt_to_add[i] );
            }
        }
    }
    return ( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void free_test_space ( long long **  values,
int  num_tests 
)

Definition at line 131 of file test_utils.c.

{
    int i;

    for ( i = 0; i < num_tests; i++ )
        free( values[i] );
    free( values );
}

Here is the caller graph for this function:

void* get_overflow_address ( void *  context)
void init_multiplex ( void  )

Definition at line 888 of file test_utils.c.

{
    int retval;
    const PAPI_hw_info_t *hw_info;
    const PAPI_component_info_t *cmpinfo;

    /* Initialize the library */

    /* for now, assume multiplexing on CPU compnent only */
    cmpinfo = PAPI_get_component_info( 0 );
    if ( cmpinfo == NULL )
        test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );

    hw_info = PAPI_get_hardware_info(  );
    if ( hw_info == NULL )
        test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );

    if ( ( strstr( cmpinfo->name, "perfctr.c" ) ) && (hw_info !=NULL) &&
         strcmp( hw_info->model_string, "POWER6" ) == 0 ) {
        retval = PAPI_set_domain( PAPI_DOM_ALL );
        if ( retval != PAPI_OK )
            test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
    }
    retval = PAPI_multiplex_init(  );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI multiplex init fail\n", retval );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int papi_print_header ( char *  prompt,
const PAPI_hw_info_t **  hwinfo 
)

Definition at line 21 of file test_utils.c.

{
    int cnt, mpx;
    
    if ( ( *hwinfo = PAPI_get_hardware_info(  ) ) == NULL ) {
        return PAPI_ESYS;
    }

    printf( "%s", prompt );
    printf
        ( "--------------------------------------------------------------------------------\n" );
    printf( "PAPI Version             : %d.%d.%d.%d\n",
            PAPI_VERSION_MAJOR( PAPI_VERSION ),
            PAPI_VERSION_MINOR( PAPI_VERSION ),
            PAPI_VERSION_REVISION( PAPI_VERSION ),
            PAPI_VERSION_INCREMENT( PAPI_VERSION ) );
    printf( "Vendor string and code   : %s (%d)\n", ( *hwinfo )->vendor_string,
            ( *hwinfo )->vendor );
    printf( "Model string and code    : %s (%d)\n", ( *hwinfo )->model_string,
            ( *hwinfo )->model );
    printf( "CPU Revision             : %f\n", ( *hwinfo )->revision );
    if ( ( *hwinfo )->cpuid_family > 0 )
        printf
            ( "CPUID Info               : Family: %d  Model: %d  Stepping: %d\n",
              ( *hwinfo )->cpuid_family, ( *hwinfo )->cpuid_model,
              ( *hwinfo )->cpuid_stepping );
    printf( "CPU Max Megahertz        : %d\n", ( *hwinfo )->cpu_max_mhz );
    printf( "CPU Min Megahertz        : %d\n", ( *hwinfo )->cpu_min_mhz );
    if ( ( *hwinfo )->threads > 0 )
        printf( "Hdw Threads per core     : %d\n", ( *hwinfo )->threads );
    if ( ( *hwinfo )->cores > 0 )
        printf( "Cores per Socket         : %d\n", ( *hwinfo )->cores );
    if ( ( *hwinfo )->sockets > 0 )
        printf( "Sockets                  : %d\n", ( *hwinfo )->sockets );
    if ( ( *hwinfo )->nnodes > 0 )
        printf( "NUMA Nodes               : %d\n", ( *hwinfo )->nnodes );
    printf( "CPUs per Node            : %d\n", ( *hwinfo )->ncpu );
    printf( "Total CPUs               : %d\n", ( *hwinfo )->totalcpus );
    printf( "Running in a VM          : %s\n", ( *hwinfo )->virtualized?
        "yes":"no");
    if ( (*hwinfo)->virtualized) {
           printf( "VM Vendor:               : %s\n", (*hwinfo)->virtual_vendor_string);
    }
    cnt = PAPI_get_opt( PAPI_MAX_HWCTRS, NULL );
    mpx = PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL );
    if ( cnt >= 0 ) {
        printf( "Number Hardware Counters : %d\n",cnt );
    } else {
        printf( "Number Hardware Counters : PAPI error %d: %s\n", cnt, PAPI_strerror(cnt));
    }
    if ( mpx >= 0 ) {
        printf( "Max Multiplex Counters   : %d\n", mpx );
    } else {
        printf( "Max Multiplex Counters   : PAPI error %d: %s\n", mpx, PAPI_strerror(mpx));
    }
    printf
        ( "--------------------------------------------------------------------------------\n" );
    printf( "\n" );
    return PAPI_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int remove_test_events ( int *  EventSet,
int  mask 
)

Definition at line 277 of file test_utils.c.

{
    int retval = PAPI_OK;

    if ( mask & MASK_L1_DCA ) {
        retval = PAPI_remove_event( *EventSet, PAPI_L1_DCA );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_L1_DCW ) {
        retval = PAPI_remove_event( *EventSet, PAPI_L1_DCW );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_L1_DCR ) {
        retval = PAPI_remove_event( *EventSet, PAPI_L1_DCR );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_L2_TCH ) {
        retval = PAPI_remove_event( *EventSet, PAPI_L2_TCH );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_L2_TCA ) {
        retval = PAPI_remove_event( *EventSet, PAPI_L2_TCA );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_L2_TCM ) {
        retval = PAPI_remove_event( *EventSet, PAPI_L2_TCM );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_L1_DCM ) {
        retval = PAPI_remove_event( *EventSet, PAPI_L1_DCM );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_L1_ICM ) {
        retval = PAPI_remove_event( *EventSet, PAPI_L1_ICM );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_L1_TCM ) {
        retval = PAPI_remove_event( *EventSet, PAPI_L1_TCM );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_FP_OPS ) {
        retval = PAPI_remove_event( *EventSet, PAPI_FP_OPS );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_FP_INS ) {
        retval = PAPI_remove_event( *EventSet, PAPI_FP_INS );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_TOT_INS ) {
        retval = PAPI_remove_event( *EventSet, PAPI_TOT_INS );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_TOT_IIS ) {
        retval = PAPI_remove_event( *EventSet, PAPI_TOT_IIS );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    if ( mask & MASK_TOT_CYC ) {
        retval = PAPI_remove_event( *EventSet, PAPI_TOT_CYC );
        if ( retval < PAPI_OK )
            return ( retval );
    }

    return ( PAPI_destroy_eventset( EventSet ) );
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* stringify_all_domains ( int  domains)

Definition at line 369 of file test_utils.c.

{
    static char buf[PAPI_HUGE_STR_LEN];
    int i, did = 0;
    buf[0] = '\0';

    for ( i = PAPI_DOM_MIN; i <= PAPI_DOM_MAX; i = i << 1 )
        if ( domains & i ) {
            if ( did )
                strcpy( buf + strlen( buf ), "|" );
            strcpy( buf + strlen( buf ), stringify_domain( domains & i ) );
            did++;
        }
    if ( did == 0 )
        test_fail( __FILE__, __LINE__, "Unrecognized domains!", 0 );
    return ( buf );
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* stringify_all_granularities ( int  granularities)

Definition at line 408 of file test_utils.c.

{
    static char buf[PAPI_HUGE_STR_LEN];
    int i, did = 0;

    buf[0] = '\0';
    for ( i = PAPI_GRN_MIN; i <= PAPI_GRN_MAX; i = i << 1 )
        if ( granularities & i ) {
            if ( did )
                strcpy( buf + strlen( buf ), "|" );
            strcpy( buf + strlen( buf ),
                    stringify_granularity( granularities & i ) );
            did++;
        }
    if ( did == 0 )
        test_fail( __FILE__, __LINE__, "Unrecognized granularity!", 0 );

    return ( buf );
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* stringify_domain ( int  domain)

Definition at line 388 of file test_utils.c.

{
    switch ( domain ) {
    case PAPI_DOM_SUPERVISOR:
        return ( "PAPI_DOM_SUPERVISOR" );
    case PAPI_DOM_USER:
        return ( "PAPI_DOM_USER" );
    case PAPI_DOM_KERNEL:
        return ( "PAPI_DOM_KERNEL" );
    case PAPI_DOM_OTHER:
        return ( "PAPI_DOM_OTHER" );
    case PAPI_DOM_ALL:
        return ( "PAPI_DOM_ALL" );
    default:
        test_fail( __FILE__, __LINE__, "Unrecognized domains!", 0 );
    }
    return ( NULL );
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* stringify_granularity ( int  granularity)

Definition at line 429 of file test_utils.c.

{
    switch ( granularity ) {
    case PAPI_GRN_THR:
        return ( "PAPI_GRN_THR" );
    case PAPI_GRN_PROC:
        return ( "PAPI_GRN_PROC" );
    case PAPI_GRN_PROCG:
        return ( "PAPI_GRN_PROCG" );
    case PAPI_GRN_SYS_CPU:
        return ( "PAPI_GRN_SYS_CPU" );
    case PAPI_GRN_SYS:
        return ( "PAPI_GRN_SYS" );
    default:
        test_fail( __FILE__, __LINE__, "Unrecognized granularity!", 0 );
    }
    return ( NULL );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void test_fail ( char *  file,
int  line,
char *  call,
int  retval 
)

Definition at line 513 of file test_utils.c.

{

  int line_pad;
  char buf[128];

  line_pad=(int)(50-strlen(file));
  if (line_pad<0) line_pad=0;

  memset( buf, '\0', sizeof ( buf ) );

  if (TESTS_COLOR) {
     fprintf( stdout, "%-*s %sFAILED%s\nLine # %d\n", line_pad, file, 
            RED,NORMAL,line );
  }
  else {
     fprintf( stdout, "%-*s FAILED\nLine # %d\n", line_pad, file, line );
  }

  if ( retval == PAPI_ESYS ) {
     sprintf( buf, "System error in %s", call );
     perror( buf );
  } else if ( retval > 0 ) {
     fprintf( stdout, "Error: %s\n", call );
  } else if ( retval == 0 ) {
#if defined(sgi)
        fprintf( stdout, "SGI requires root permissions for this test\n" );
#else
        fprintf( stdout, "Error: %s\n", call );
#endif
  } else {
     fprintf( stdout, "Error in %s: %s\n", call, PAPI_strerror( retval ) );
  }

  fprintf( stdout, "\n" );

    /* NOTE: Because test_fail is called from thread functions, 
       calling PAPI_shutdown here could prevent some threads
       from being able to free memory they have allocated.
     */

    /* This is stupid.  Threads are the rare case */
    /* and in any case an exit() should clear everything out */
    /* adding back the exit() call */

    exit(1);
}

Here is the call graph for this function:

void test_fail_exit ( char *  file,
int  line,
char *  call,
int  retval 
)

Definition at line 567 of file test_utils.c.

{
    test_fail( file, line, call, retval );
    if ( PAPI_is_initialized(  ) )
        PAPI_shutdown(  );
    exit( 1 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void test_pass ( char *  file,
long long **  values,
int  num_tests 
)

Definition at line 474 of file test_utils.c.

{
  int line_pad;

  line_pad=(int)(50-strlen(file));
  if (line_pad<0) line_pad=0;

        if ( TEST_WARN ) {
      if (TESTS_COLOR) {
        fprintf( stdout, "%-*s %sPASSED with WARNING%s\n", 
             line_pad, file, YELLOW, NORMAL);      
      }
      else {
            fprintf( stdout, "%-*s PASSED with WARNING\n", 
             line_pad, file );     
      }
    }
        else {
      if (TESTS_COLOR) {
        fprintf( stdout, "%-*s %sPASSED%s\n", line_pad, file, 
             GREEN, NORMAL );
      }
      else {
        fprintf( stdout, "%-*s PASSED\n", line_pad, file );
      }
    }
   
    if ( values )
        free_test_space( values, num_tests );

    if ( PAPI_is_initialized(  ) )
        PAPI_shutdown(  );

    exit( 0 );

}

Here is the call graph for this function:

Here is the caller graph for this function:

void test_print_event_header ( char *  call,
int  evset 
)

Definition at line 645 of file test_utils.c.

{
        int *ev_ids;
    int i, nev;
    int retval;
    char evname[PAPI_MAX_STR_LEN];

    if ( *call )
        fprintf( stdout, "%s", call );

    if ((nev = PAPI_get_cmp_opt(PAPI_MAX_MPX_CTRS,NULL,0)) <= 0) {
        fprintf( stdout, "Can not list event names.\n" );
        return;
    }

    if ((ev_ids = calloc(nev,sizeof(int))) == NULL) {
        fprintf( stdout, "Can not list event names.\n" );
        return;
    }

    retval = PAPI_list_events( evset, ev_ids, &nev );

    if ( retval == PAPI_OK ) {
        for ( i = 0; i < nev; i++ ) {
            PAPI_event_code_to_name( ev_ids[i], evname );
            printf( ONEHDR, evname );
        }
    } else {
        fprintf( stdout, "Can not list event names." );
    }
    fprintf( stdout, "\n" );
    free(ev_ids);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void test_skip ( char *  file,
int  line,
char *  call,
int  retval 
)

Definition at line 614 of file test_utils.c.

{
    char buf[128];

    memset( buf, '\0', sizeof ( buf ) );
    fprintf( stdout, "%-40s SKIPPED\n", file );
    if ( !TESTS_QUIET ) {
        if ( retval == PAPI_ESYS ) {
            fprintf( stdout, "Line # %d\n", line );
            sprintf( buf, "System error in %s:", call );
            perror( buf );
        } else if ( retval == PAPI_EPERM ) {
            fprintf( stdout, "Line # %d\n", line );
            fprintf( stdout, "Invalid permissions for %s.", call );
        } else if ( retval == PAPI_ECMP ) {
            fprintf( stdout, "Line # %d\n", line );
            fprintf( stdout, "%s.", call );
        } else if ( retval >= 0 ) {
            fprintf( stdout, "Line # %d\n", line );
            fprintf( stdout, "Error calculating: %s\n", call );
        } else if ( retval < 0 ) {
            fprintf( stdout, "Line # %d\n", line );
            fprintf( stdout, "Error in %s: %s\n", call, PAPI_strerror(retval) );
        }
        fprintf( stdout, "\n" );
    }
    exit( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void test_warn ( char *  file,
int  line,
char *  call,
int  retval 
)

Definition at line 578 of file test_utils.c.

{

  int line_pad;

  line_pad=(int)(50-strlen(file));
  if (line_pad<0) line_pad=0;

    char buf[128];
    memset( buf, '\0', sizeof ( buf ) );

    if (TESTS_COLOR) {
      fprintf( stdout, "%-*s %sWARNING%s\nLine # %d\n", line_pad, file, 
           YELLOW, NORMAL, line );
    }
    else {
      fprintf( stdout, "%-*s WARNING\nLine # %d\n", line_pad, file, line );
    }

    if ( retval == PAPI_ESYS ) {
        sprintf( buf, "System warning in %s", call );
        perror( buf );
    } else if ( retval > 0 ) {
        fprintf( stdout, "Warning: %s\n", call );
    } else if ( retval == 0 ) {
        fprintf( stdout, "Warning: %s\n", call );
    } else {
        fprintf( stdout, "Warning in %s: %s\n", call, PAPI_strerror( retval ));
    }

    fprintf( stdout, "\n" );
    TEST_WARN++;

}

Here is the call graph for this function:

Here is the caller graph for this function:

void tests_quiet ( int  argc,
char **  argv 
)

Definition at line 449 of file test_utils.c.

{
    if ( ( argc > 1 )
         && ( ( strcasecmp( argv[1], "TESTS_QUIET" ) == 0 )
              || ( strcasecmp( argv[1], "-q" ) == 0 ) ) ) {
        TESTS_QUIET = 1;
    } else {
        int retval;

        retval = PAPI_set_debug( PAPI_VERB_ECONT );
        if ( retval != PAPI_OK )
            test_fail( __FILE__, __LINE__, "PAPI_set_debug", retval );
    }
   if (getenv("TESTS_COLOR")!=NULL) {
      TESTS_COLOR=1;
   }
   
}

Here is the call graph for this function:

Here is the caller graph for this function:

void touch_dummy ( double *  ptr,
int  size 
)

Definition at line 41 of file dummy.c.

{
    int i;
    double *tmp = array;
    for ( i = 0; i < size; i++, tmp++ )
        *tmp = ( double ) rand(  );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void validate_string ( char *  name,
char *  s 
)

Definition at line 84 of file test_utils.c.

{
    if ( ( s == NULL ) || ( strlen( s ) == 0 ) ) {
        char s2[1024] = "";
        sprintf( s2, "%s was NULL or length 0", name );
        test_fail( __FILE__, __LINE__, s2, 0 );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 191 of file test_utils.c.

Definition at line 11 of file test_utils.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines