PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
papi_test.h File Reference
Include dependency graph for papi_test.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  test_events_t
 

Macros

#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)
 
voidget_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
 

Macro Definition 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.

214 {
215  int retval,i;
216  int EventSet = PAPI_NULL;
217  int num_counters = 0;
218  char name_string[BUFSIZ];
219 
220  *number = 0;
221 
222  /* get the number of available HW counters */
223  num_counters = PAPI_get_opt( PAPI_MAX_HWCTRS, NULL );
224  if ( num_counters < 1 ) {
225  test_fail( __FILE__, __LINE__, "Zero HW Counters available",
226  num_counters );
227  }
228 
229  /* create the eventset */
230  retval = PAPI_create_eventset( &EventSet );
231  if ( retval != PAPI_OK ) {
232  test_fail( __FILE__, __LINE__, "PAPI_create_eventset",
233  retval );
234  }
235 
236  /* check all the masks */
237  for(i=0;i<MAX_TEST_EVENTS;i++) {
238 
239  if ( *mask & test_events[i].mask ) {
240 
241  /* remove any derived events if told to */
242  if ((is_event_derived(test_events[i].event)) && (!allow_derived)) {
243  *mask = *mask ^ test_events[i].mask;
244  continue;
245  }
246 
247  retval = PAPI_add_event( EventSet, test_events[i].event );
248 
249  if ( retval == PAPI_OK ) {
250 
251  ( *number )++;
252 #if 0
253  if ((*number)==num_counters) {
254  if ( !TESTS_QUIET) {
255  fprintf(stdout, "Stopping with %d events due to HW limit\n",
256  num_counters);
257  }
258  break;
259  }
260 #endif
261  }
262  else {
263  if ( !TESTS_QUIET ) {
264  PAPI_event_code_to_name(test_events[i].event,name_string);
265  fprintf( stdout, "%#x %s is not available.\n",
266  test_events[i].event,name_string);
267  }
268  *mask = *mask ^ test_events[i].mask;
269  }
270  }
271  }
272 
273  return EventSet;
274 }
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1622
int is_event_derived(unsigned int event)
Definition: test_utils.c:142
#define PAPI_NULL
Definition: papi.h:290
int EventSet
Definition: data_range.c:25
device[deviceId] domain[domainId] event
Definition: linux-cuda.c:306
#define MAX_TEST_EVENTS
Definition: papi_test.h:51
return PAPI_OK
Definition: linux-nvml.c:458
int TESTS_QUIET
Definition: test_utils.c:11
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int i
Definition: fileop.c:140
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4082
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:926
struct test_events_t test_events[]
Definition: test_utils.c:191
#define PAPI_MAX_HWCTRS
Definition: papi.h:441
ssize_t retval
Definition: libasync.c:338
unsigned int mask
Definition: papi_test.h:54

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.

680  {
681 
682  /* query and set up the right event to monitor */
683  int EventSet = PAPI_NULL;
684  PAPI_event_info_t info;
685  unsigned int potential_evt_to_add[3][2] =
686  { {( unsigned int ) PAPI_FP_INS, MASK_FP_INS},
687  {( unsigned int ) PAPI_FP_OPS, MASK_FP_OPS},
688  {( unsigned int ) PAPI_TOT_INS, MASK_TOT_INS}
689  };
690  int i = 0;
691  int counters = 0;
692 
693  *mask = 0;
694  counters = PAPI_num_hwctrs( );
695 
696  if (counters<=0) {
697  test_fail(__FILE__,__LINE__,"Zero Counters Available! PAPI Won't like this!\n",0);
698  }
699 
700  /* This code tries to ensure that the event generated will fit in the */
701  /* number of available counters. It has the potential to leak up to */
702  /* two event sets if events fail to add successfully. */
703 
704  for(i=0;i<3;i++) {
705  if ( PAPI_query_event( (int) potential_evt_to_add[i][0] ) == PAPI_OK ) {
706  if ( PAPI_get_event_info( (int) potential_evt_to_add[i][0], &info ) == PAPI_OK ) {
707  if ( ( info.count > 0 ) && ( (unsigned) counters > info.count ) ) {
708  *papi_event = ( int ) potential_evt_to_add[i][0];
709  *mask = ( int ) potential_evt_to_add[i][1] | MASK_TOT_CYC;
710  EventSet = add_test_events( num_events, mask, 1 );
711  if ( *num_events == 2 ) break;
712  }
713  }
714  }
715  }
716  if ( i == 3 ) {
717  test_fail( __FILE__, __LINE__, "Not enough room to add an event!", 0 );
718  }
719  return EventSet;
720 }
unsigned int count
Definition: papi.h:984
#define PAPI_FP_OPS
#define PAPI_NULL
Definition: papi.h:290
int EventSet
Definition: data_range.c:25
int num_events
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:458
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:846
#define MASK_FP_INS
Definition: papi_test.h:47
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int i
Definition: fileop.c:140
int PAPI_num_hwctrs(void)
Definition: papi.c:3848
#define MASK_TOT_CYC
Definition: papi_test.h:49
#define MASK_FP_OPS
Definition: papi_test.h:33
int PAPI_query_event(int EventCode)
Definition: papi.c:698
#define MASK_TOT_INS
Definition: papi_test.h:48
int
Definition: iozone.c:18528
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:213
#define PAPI_FP_INS

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.

723  {
724 
725  /* query and set up the right event to monitor */
726  int EventSet = PAPI_NULL;
727 
728 #define POTENTIAL_EVENTS 3
729 
730  unsigned int potential_evt_to_add[POTENTIAL_EVENTS][2] =
731  { {( unsigned int ) PAPI_FP_INS, MASK_FP_INS},
732  {( unsigned int ) PAPI_FP_OPS, MASK_FP_OPS},
733  {( unsigned int ) PAPI_TOT_INS, MASK_TOT_INS}
734  };
735 
736  int i;
737 
738  *mask = 0;
739 
740  /* could leak up to two event sets. */
741  for(i=0;i<POTENTIAL_EVENTS;i++) {
742 
743  if ( PAPI_query_event( ( int ) potential_evt_to_add[i][0] ) == PAPI_OK ) {
744  if ( !is_event_derived(potential_evt_to_add[i][0])) {
745  *papi_event = ( int ) potential_evt_to_add[i][0];
746  *mask = ( int ) potential_evt_to_add[i][1] | MASK_TOT_CYC;
747  EventSet = add_test_events( num_events, mask, 0 );
748  if ( *num_events == 2 ) break;
749  }
750  }
751  }
752 
753  if ( i == POTENTIAL_EVENTS ) {
754  test_fail( __FILE__, __LINE__, "Can't find a non-derived event!", 0 );
755  }
756  return EventSet;
757 }
int is_event_derived(unsigned int event)
Definition: test_utils.c:142
#define PAPI_FP_OPS
#define PAPI_NULL
Definition: papi.h:290
int EventSet
Definition: data_range.c:25
int num_events
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:458
#define MASK_FP_INS
Definition: papi_test.h:47
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int i
Definition: fileop.c:140
#define MASK_TOT_CYC
Definition: papi_test.h:49
#define MASK_FP_OPS
Definition: papi_test.h:33
int PAPI_query_event(int EventCode)
Definition: papi.c:698
#define MASK_TOT_INS
Definition: papi_test.h:48
#define POTENTIAL_EVENTS
int
Definition: iozone.c:18528
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:213
#define PAPI_FP_INS

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.

108 {
109  long long **values;
110  int i;
111 
112  values =
113  ( long long ** ) malloc( ( size_t ) num_tests *
114  sizeof ( long long * ) );
115  if ( values == NULL )
116  exit( 1 );
117  memset( values, 0x0, ( size_t ) num_tests * sizeof ( long long * ) );
118 
119  for ( i = 0; i < num_tests; i++ ) {
120  values[i] =
121  ( long long * ) malloc( ( size_t ) num_events *
122  sizeof ( long long ) );
123  if ( values[i] == NULL )
124  exit( 1 );
125  memset( values[i], 0x00, ( size_t ) num_events * sizeof ( long long ) );
126  }
127  return ( values );
128 }
memset(eventId, 0, size)
int num_events
int i
Definition: fileop.c:140
long long
Definition: iozone.c:19827
int num_tests
Definition: zero_fork.c:46
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void exit()

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.

95 {
96  if ( ( a >= b * ( 1.0 - TOLERANCE ) ) && ( a <= b * ( 1.0 + TOLERANCE ) ) )
97  return 1;
98  else {
99  printf( "Out of tolerance range %2.2f: %.0f vs %.0f [%.0f,%.0f]\n",
100  TOLERANCE, a, b, b * ( 1.0 - TOLERANCE ),
101  b * ( 1.0 + TOLERANCE ) );
102  return 0;
103  }
104 }
#define TOLERANCE
Definition: test_utils.h:13
#define printf
Definition: papi_test.h:125
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:38

Here is the caller graph for this function:

void clockcore ( void  )

Definition at line 99 of file clockcore.c.

100 {
101  /* check PAPI_get_real_cyc */
102  clock_res_check( 0 );
103  /* check PAPI_get_real_usec */
104  clock_res_check( 1 );
105 
106  /* check PAPI_get_virt_cyc */
107  /* Virtual */
108  if ( PAPI_get_virt_cyc( ) != -1 ) {
109  clock_res_check( 2 );
110  } else
111  test_fail( __FILE__, __LINE__, "PAPI_get_virt_cyc", -1 );
112 
113  /* check PAPI_get_virt_usec */
114  if ( PAPI_get_virt_usec( ) != -1 ) {
115  clock_res_check( 3 );
116  } else
117  test_fail( __FILE__, __LINE__, "PAPI_get_virt_usec", -1 );
118 }
long long PAPI_get_virt_usec(void)
Definition: papi.c:6298
long long PAPI_get_virt_cyc(void)
Definition: papi.c:6226
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
void clock_res_check(int flag)
Definition: clockcore.c:12
void do_both ( int  n)

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

38 {
39  int i;
40  const int flops2 = NUM_FLOPS / n;
41  const int flops1 = NUM_FLOPS / n;
42 
43  for (i = 0; i < n; i++)
44  {
45  do_flops1(flops1);
46  do_flops2(flops2);
47  }
48 }
#define NUM_FLOPS
int i
Definition: fileop.c:140
void do_flops2(int)
void do_flops1(int n)
int n
Definition: mendes-alt.c:164

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.

24 {
25  int i;
26  double a = 0.5;
27  double b = 6.2;
28 
29  for (i=0; i < n; i++)
30  c += a * b;
31  return;
32 }
double c
Definition: multiplex.c:22
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
int i
Definition: fileop.c:140
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:38
int n
Definition: mendes-alt.c:164

Here is the caller graph for this function:

void do_flush ( void  )

Definition at line 165 of file do_loops.c.

166 {
167  register int i;
168  if ( flush == NULL )
169  flush = ( int * ) malloc( ( 1024 * 1024 * 16 ) * sizeof ( int ) );
170  if ( !flush )
171  return;
172 
173  dummy( ( void * ) flush );
174  for ( i = 0; i < ( 1024 * 1024 * 16 ); i++ ) {
175  flush[i] += flush_dummy;
176  }
177  flush_dummy++;
178  dummy( ( void * ) flush );
179  dummy( ( void * ) &flush_dummy );
180 }
volatile int flush_dummy
Definition: do_loops.c:8
int dummy
Definition: iozone.c:19741
volatile int * flush
Definition: do_loops.c:7
int i
Definition: fileop.c:140
int
Definition: iozone.c:18528

Here is the caller graph for this function:

void do_l1misses ( int  n)

Definition at line 213 of file do_loops.c.

214 {
216 }
void do_misses(int n, int bytes)
Definition: do_loops.c:113
#define L1_MISS_BUFFER_SIZE_INTS
Definition: test_utils.h:11
int n
Definition: mendes-alt.c:164

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.

114 {
115  register int i, j, tmp = buf_dummy, len = bytes / ( int ) sizeof ( int );
116  dummy( ( void * ) buf );
117  dummy( ( void * ) &buf_dummy );
118  assert( len <= CACHE_FLUSH_BUFFER_SIZE_INTS );
119  for ( j = 0; j < n; j++ ) {
120  for ( i = 0; i < len; i++ ) {
121  /* We need to read, modify, write here to look
122  out for the write allocate policies. */
123  buf[i] += tmp;
124  /* Fake out some naive prefetchers */
125  buf[len - 1 - i] -= tmp;
126  }
127  tmp += len;
128  }
129  buf_dummy = tmp;
130  dummy( ( void * ) buf );
131  dummy( ( void * ) &buf_dummy );
132 }
int dummy
Definition: iozone.c:19741
int i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
#define CACHE_FLUSH_BUFFER_SIZE_INTS
Definition: test_utils.h:12
int
Definition: iozone.c:18528
long j
Definition: iozone.c:19135
long long tmp
Definition: iozone.c:12031
volatile int buf_dummy
Definition: do_loops.c:6
int n
Definition: mendes-alt.c:164

Here is the caller graph for this function:

void do_reads ( int  n)

Definition at line 12 of file do_loops.c.

13 {
14  int i, retval;
15  static int fd = -1;
16  char buf;
17 
18  if ( fd == -1 ) {
19  fd = open( "/dev/zero", O_RDONLY );
20  if ( fd == -1 ) {
21  perror( "open(/dev/zero)" );
22  exit( 1 );
23  }
24  }
25 
26  for ( i = 0; i < n; i++ ) {
27  retval = ( int ) read( fd, &buf, sizeof ( buf ) );
28  if ( retval != sizeof ( buf ) ) {
29  if ( retval < 0 )
30  perror( "/dev/zero cannot be read" );
31  else
32  fprintf( stderr,
33  "/dev/zero cannot be read: only got %d bytes.\n",
34  retval );
35  exit( 1 );
36  }
37  }
38 }
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:225
int fd
Definition: iozone.c:1291
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:184
int i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
int
Definition: iozone.c:18528
ssize_t retval
Definition: libasync.c:338
void exit()
int n
Definition: mendes-alt.c:164

Here is the call graph for this function:

Here is the caller graph for this function:

void do_stuff ( void  )

Definition at line 249 of file do_loops.c.

250 {
251  static int loops = 0;
252 
253  if ( loops == 0 ) {
254  struct timeval now, then;
255  gettimeofday( &then, NULL );
256  do {
257  do_flops( NUM_FLOPS );
258  do_reads( NUM_READS );
259  do_misses( 1, 1024 * 1024 );
260  gettimeofday( &now, NULL );
261  loops++;
262  } while ( now.tv_sec - then.tv_sec < NUM_WORK_SECONDS );
263  } else {
264  int i = 0;
265  do {
266  do_flops( NUM_FLOPS );
267  do_reads( NUM_READS );
268  do_misses( 1, 1024 * 1024 );
269  i++;
270  } while ( i < loops );
271  }
272 }
#define NUM_FLOPS
void do_reads(int n)
Definition: do_loops.c:12
int i
Definition: fileop.c:140
#define NUM_WORK_SECONDS
Definition: test_utils.h:1
void do_misses(int n, int bytes)
Definition: do_loops.c:113
void do_flops(int n)
Definition: multiplex.c:23
#define NUM_READS
Definition: test_utils.h:4

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.

5 {
6 /* Confuse the compiler so as not to optimize
7  away the flops in the calling routine */
8 /* Cast the array as a void to eliminate unused argument warning */
9  ( void ) array;
10 }
void
Definition: iozone.c:18627
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.

764 {
765  /* query and set up the right event to monitor */
766  int EventSet = PAPI_NULL;
767  int i = 0, k, event_code, retval;
768  int counters, event_found = 0;
769  PAPI_event_info_t info;
770  const PAPI_component_info_t *s = NULL;
771  const PAPI_hw_info_t *hw_info = NULL;
772 
774  if ( s == NULL ) {
775  test_fail( __FILE__, __LINE__,
776  "PAPI_get_component_info", PAPI_ECMP );
777  }
778 
779  hw_info = PAPI_get_hardware_info( );
780  if ( hw_info == NULL ) {
781  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
782  }
783 
784  counters = PAPI_num_hwctrs( );
785  if (counters<1) {
786  test_fail(__FILE__,__LINE__, "No counters available!\n",1);
787  }
788 
789  if (!TESTS_QUIET) printf("Trying to fill %d hardware counters...\n",
790  counters);
791 
792  if (need_interrupt) {
793  if ( (!strcmp(hw_info->model_string,"POWER6")) ||
794  (!strcmp(hw_info->model_string,"POWER5")) ) {
795 
796  test_warn(__FILE__, __LINE__,
797  "Limiting num_counters because of LIMITED_PMC on Power5 and Power6",1);
798  counters=4;
799  }
800  }
801 
802  ( *evtcodes ) = ( int * ) calloc( counters, sizeof ( int ) );
803 
804  retval = PAPI_create_eventset( &EventSet );
805  if ( retval != PAPI_OK ) {
806  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
807  }
808 
809  /* For platform independence, always ASK FOR the first event */
810  /* Don't just assume it'll be the first numeric value */
811  i = 0 | PAPI_NATIVE_MASK;
812  retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cidx );
813  if ( retval != PAPI_OK )
814  {
815  test_fail( __FILE__, __LINE__, "PAPI_enum_cmp_event", retval );
816  }
817 
818  do {
819  retval = PAPI_get_event_info( i, &info );
820 
821  /* HACK! FIXME */
822  if (no_software_events && ( strstr(info.symbol,"PERF_COUNT_SW") || strstr(info.long_descr, "PERF_COUNT_SW") ) ) {
823  if (!TESTS_QUIET) {
824  printf("Blocking event %s as a SW event\n", info.symbol);
825  }
826  continue;
827  }
828 
829  if ( s->cntr_umasks ) {
830  k = i;
831 
833  do {
834  retval = PAPI_get_event_info( k, &info );
835  event_code = ( int ) info.event_code;
836 
837  retval = PAPI_add_event( EventSet, event_code );
838  if ( retval == PAPI_OK ) {
839  ( *evtcodes )[event_found] = event_code;
840  if ( !TESTS_QUIET ) {
841  printf( "event_code[%d] = %#x (%s)\n",
842  event_found, event_code, info.symbol );
843  }
844  event_found++;
845  } else {
846  if ( !TESTS_QUIET ) {
847  printf( "%#x (%s) can't be added to the EventSet.\n",
848  event_code, info.symbol );
849  }
850  }
852  && event_found < counters );
853  } else {
854  event_code = ( int ) info.event_code;
855  retval = PAPI_add_event( EventSet, event_code );
856  if ( retval == PAPI_OK ) {
857  ( *evtcodes )[event_found] = event_code;
858  if ( !TESTS_QUIET ) {
859  printf( "event_code[%d] = %#x (%s)\n",
860  event_found, event_code, info.symbol );
861  }
862  event_found++;
863  }
864  }
865  if ( !TESTS_QUIET && retval == PAPI_OK ) {
866  /* */
867  }
868  } else {
869  event_code = ( int ) info.event_code;
870  retval = PAPI_add_event( EventSet, event_code );
871  if ( retval == PAPI_OK ) {
872  ( *evtcodes )[event_found] = event_code;
873  event_found++;
874  } else {
875  if ( !TESTS_QUIET )
876  fprintf( stdout, "%#x is not available.\n", event_code );
877  }
878  }
879  }
880  while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cidx ) == PAPI_OK &&
881  event_found < counters );
882 
883  *num_events = ( int ) event_found;
884 
885  if (!TESTS_QUIET) printf("Tried to fill %d counters with events, "
886  "found %d\n",counters,event_found);
887 
888  return EventSet;
889 }
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:807
Hardware info structure.
Definition: papi.h:777
#define PAPI_NULL
Definition: papi.h:290
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
int EventSet
Definition: data_range.c:25
int num_events
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
unsigned int cntr_umasks
Definition: papi.h:665
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:846
int TESTS_QUIET
Definition: test_utils.c:11
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int i
Definition: fileop.c:140
void test_warn(char *file, int line, char *call, int retval)
Definition: test_utils.c:578
int PAPI_num_hwctrs(void)
Definition: papi.c:3848
static int cidx
Definition: event_info.c:40
int k
Definition: iozone.c:19136
s
Definition: iozone.c:20289
#define PAPI_ECMP
Definition: papi.h:254
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1324
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
int
Definition: iozone.c:18528
add PAPI preset or native hardware event to an event set
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:787
unsigned int event_code
Definition: papi.h:961
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6111
ssize_t retval
Definition: libasync.c:338
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:23

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.

84 {
85  do_flops( *n );
86 }
void do_flops(int n)
Definition: multiplex.c:23
int n
Definition: mendes-alt.c:164

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.

160 {
161  /* query and set up the right event to monitor */
162  PAPI_event_info_t info;
163  int potential_evt_to_add[3] = { PAPI_FP_OPS, PAPI_FP_INS, PAPI_TOT_INS };
164  int i;
165 
166  for ( i = 0; i < 3; i++ ) {
167  if ( PAPI_query_event( potential_evt_to_add[i] ) == PAPI_OK ) {
168  if ( PAPI_get_event_info( potential_evt_to_add[i], &info ) ==
169  PAPI_OK ) {
170  if ( ( info.count > 0 ) &&
171  !strcmp( info.derived, "NOT_DERIVED" ) )
172  return ( potential_evt_to_add[i] );
173  }
174  }
175  }
176  return ( 0 );
177 }
unsigned int count
Definition: papi.h:984
#define PAPI_FP_OPS
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:458
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:846
int i
Definition: fileop.c:140
int PAPI_query_event(int EventCode)
Definition: papi.c:698
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:992
#define PAPI_FP_INS

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.

132 {
133  int i;
134 
135  for ( i = 0; i < num_tests; i++ )
136  free( values[i] );
137  free( values );
138 }
int i
Definition: fileop.c:140
free(dummyfile[xx])
int num_tests
Definition: zero_fork.c:46
static long long values[NUM_EVENTS]
Definition: init_fini.c:10

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 892 of file test_utils.c.

893 {
894  int retval;
895  const PAPI_hw_info_t *hw_info;
896  const PAPI_component_info_t *cmpinfo;
897 
898  /* Initialize the library */
899 
900  /* for now, assume multiplexing on CPU compnent only */
901  cmpinfo = PAPI_get_component_info( 0 );
902  if ( cmpinfo == NULL )
903  test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );
904 
905  hw_info = PAPI_get_hardware_info( );
906  if ( hw_info == NULL )
907  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
908 
909  if ( ( strstr( cmpinfo->name, "perfctr.c" ) ) && (hw_info !=NULL) &&
910  strcmp( hw_info->model_string, "POWER6" ) == 0 ) {
911  retval = PAPI_set_domain( PAPI_DOM_ALL );
912  if ( retval != PAPI_OK )
913  test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
914  }
915  retval = PAPI_multiplex_init( );
916  if ( retval != PAPI_OK )
917  test_fail( __FILE__, __LINE__, "PAPI multiplex init fail\n", retval );
918 }
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:626
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:807
Hardware info structure.
Definition: papi.h:777
#define PAPI_DOM_ALL
Definition: papi.h:301
return PAPI_OK
Definition: linux-nvml.c:458
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_multiplex_init(void)
Definition: papi.c:2926
int PAPI_set_domain(int domain)
Definition: papi.c:5614
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:787
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6111
ssize_t retval
Definition: libasync.c:338
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:23

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.

22 {
23  int cnt, mpx;
24 
25  if ( ( *hwinfo = PAPI_get_hardware_info( ) ) == NULL ) {
26  return PAPI_ESYS;
27  }
28 
29  printf( "%s", prompt );
30  printf
31  ( "--------------------------------------------------------------------------------\n" );
32  printf( "PAPI Version : %d.%d.%d.%d\n",
37  printf( "Vendor string and code : %s (%d)\n", ( *hwinfo )->vendor_string,
38  ( *hwinfo )->vendor );
39  printf( "Model string and code : %s (%d)\n", ( *hwinfo )->model_string,
40  ( *hwinfo )->model );
41  printf( "CPU Revision : %f\n", ( *hwinfo )->revision );
42  if ( ( *hwinfo )->cpuid_family > 0 )
43  printf
44  ( "CPUID Info : Family: %d Model: %d Stepping: %d\n",
45  ( *hwinfo )->cpuid_family, ( *hwinfo )->cpuid_model,
46  ( *hwinfo )->cpuid_stepping );
47  printf( "CPU Max Megahertz : %d\n", ( *hwinfo )->cpu_max_mhz );
48  printf( "CPU Min Megahertz : %d\n", ( *hwinfo )->cpu_min_mhz );
49  if ( ( *hwinfo )->threads > 0 )
50  printf( "Hdw Threads per core : %d\n", ( *hwinfo )->threads );
51  if ( ( *hwinfo )->cores > 0 )
52  printf( "Cores per Socket : %d\n", ( *hwinfo )->cores );
53  if ( ( *hwinfo )->sockets > 0 )
54  printf( "Sockets : %d\n", ( *hwinfo )->sockets );
55  if ( ( *hwinfo )->nnodes > 0 )
56  printf( "NUMA Nodes : %d\n", ( *hwinfo )->nnodes );
57  printf( "CPUs per Node : %d\n", ( *hwinfo )->ncpu );
58  printf( "Total CPUs : %d\n", ( *hwinfo )->totalcpus );
59  printf( "Running in a VM : %s\n", ( *hwinfo )->virtualized?
60  "yes":"no");
61  if ( (*hwinfo)->virtualized) {
62  printf( "VM Vendor: : %s\n", (*hwinfo)->virtual_vendor_string);
63  }
64  cnt = PAPI_get_opt( PAPI_MAX_HWCTRS, NULL );
65  mpx = PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL );
66  if ( cnt >= 0 ) {
67  printf( "Number Hardware Counters : %d\n",cnt );
68  } else {
69  printf( "Number Hardware Counters : PAPI error %d: %s\n", cnt, PAPI_strerror(cnt));
70  }
71  if ( mpx >= 0 ) {
72  printf( "Max Multiplex Counters : %d\n", mpx );
73  } else {
74  printf( "Max Multiplex Counters : PAPI error %d: %s\n", mpx, PAPI_strerror(mpx));
75  }
76  printf
77  ( "--------------------------------------------------------------------------------\n" );
78  printf( "\n" );
79  return PAPI_OK;
80 }
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
#define PAPI_VERSION_MAJOR(x)
Definition: papi.h:215
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4082
#define PAPI_VERSION_REVISION(x)
Definition: papi.h:217
#define PAPI_ESYS
Definition: papi.h:253
#define PAPI_MAX_MPX_CTRS
Definition: papi.h:437
#define PAPI_VERSION_MINOR(x)
Definition: papi.h:216
#define PAPI_VERSION
Definition: papi.h:222
char * PAPI_strerror(int errorCode)
Definition: papi.c:4529
#define PAPI_MAX_HWCTRS
Definition: papi.h:441
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6111
#define PAPI_VERSION_INCREMENT(x)
Definition: papi.h:218

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.

278 {
279  int retval = PAPI_OK;
280 
281  if ( mask & MASK_L1_DCA ) {
282  retval = PAPI_remove_event( *EventSet, PAPI_L1_DCA );
283  if ( retval < PAPI_OK )
284  return ( retval );
285  }
286 
287  if ( mask & MASK_L1_DCW ) {
288  retval = PAPI_remove_event( *EventSet, PAPI_L1_DCW );
289  if ( retval < PAPI_OK )
290  return ( retval );
291  }
292 
293  if ( mask & MASK_L1_DCR ) {
294  retval = PAPI_remove_event( *EventSet, PAPI_L1_DCR );
295  if ( retval < PAPI_OK )
296  return ( retval );
297  }
298 
299  if ( mask & MASK_L2_TCH ) {
300  retval = PAPI_remove_event( *EventSet, PAPI_L2_TCH );
301  if ( retval < PAPI_OK )
302  return ( retval );
303  }
304 
305  if ( mask & MASK_L2_TCA ) {
306  retval = PAPI_remove_event( *EventSet, PAPI_L2_TCA );
307  if ( retval < PAPI_OK )
308  return ( retval );
309  }
310 
311  if ( mask & MASK_L2_TCM ) {
312  retval = PAPI_remove_event( *EventSet, PAPI_L2_TCM );
313  if ( retval < PAPI_OK )
314  return ( retval );
315  }
316 
317  if ( mask & MASK_L1_DCM ) {
318  retval = PAPI_remove_event( *EventSet, PAPI_L1_DCM );
319  if ( retval < PAPI_OK )
320  return ( retval );
321  }
322 
323  if ( mask & MASK_L1_ICM ) {
324  retval = PAPI_remove_event( *EventSet, PAPI_L1_ICM );
325  if ( retval < PAPI_OK )
326  return ( retval );
327  }
328 
329  if ( mask & MASK_L1_TCM ) {
330  retval = PAPI_remove_event( *EventSet, PAPI_L1_TCM );
331  if ( retval < PAPI_OK )
332  return ( retval );
333  }
334 
335  if ( mask & MASK_FP_OPS ) {
336  retval = PAPI_remove_event( *EventSet, PAPI_FP_OPS );
337  if ( retval < PAPI_OK )
338  return ( retval );
339  }
340 
341  if ( mask & MASK_FP_INS ) {
342  retval = PAPI_remove_event( *EventSet, PAPI_FP_INS );
343  if ( retval < PAPI_OK )
344  return ( retval );
345  }
346 
347  if ( mask & MASK_TOT_INS ) {
349  if ( retval < PAPI_OK )
350  return ( retval );
351  }
352 
353  if ( mask & MASK_TOT_IIS ) {
355  if ( retval < PAPI_OK )
356  return ( retval );
357  }
358 
359  if ( mask & MASK_TOT_CYC ) {
361  if ( retval < PAPI_OK )
362  return ( retval );
363  }
364 
365  return ( PAPI_destroy_eventset( EventSet ) );
366 }
#define PAPI_TOT_IIS
#define PAPI_L2_TCH
#define PAPI_L2_TCM
#define PAPI_L1_DCM
#define PAPI_FP_OPS
int PAPI_remove_event(int EventSet, int EventCode)
Definition: papi.c:1717
#define PAPI_L1_TCM
int EventSet
Definition: data_range.c:25
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_L1_DCA
#define MASK_L1_TCM
Definition: papi_test.h:46
#define MASK_FP_INS
Definition: papi_test.h:47
#define PAPI_L1_DCR
#define PAPI_L2_TCA
#define PAPI_TOT_CYC
#define MASK_L2_TCH
Definition: papi_test.h:41
#define MASK_L2_TCA
Definition: papi_test.h:42
#define MASK_TOT_CYC
Definition: papi_test.h:49
#define PAPI_L1_ICM
#define MASK_FP_OPS
Definition: papi_test.h:33
#define MASK_L1_DCR
Definition: papi_test.h:36
#define MASK_L1_DCA
Definition: papi_test.h:34
#define MASK_TOT_INS
Definition: papi_test.h:48
#define PAPI_L1_DCW
#define MASK_TOT_IIS
Definition: papi_test.h:37
#define MASK_L2_TCM
Definition: papi_test.h:43
#define MASK_L1_ICM
Definition: papi_test.h:45
#define MASK_L1_DCM
Definition: papi_test.h:44
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1971
#define MASK_L1_DCW
Definition: papi_test.h:35
ssize_t retval
Definition: libasync.c:338
#define PAPI_FP_INS

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.

370 {
371  static char buf[PAPI_HUGE_STR_LEN];
372  int i, did = 0;
373  buf[0] = '\0';
374 
375  for ( i = PAPI_DOM_MIN; i <= PAPI_DOM_MAX; i = i << 1 )
376  if ( domains & i ) {
377  if ( did )
378  strcpy( buf + strlen( buf ), "|" );
379  strcpy( buf + strlen( buf ), stringify_domain( domains & i ) );
380  did++;
381  }
382  if ( did == 0 )
383  test_fail( __FILE__, __LINE__, "Unrecognized domains!", 0 );
384  return ( buf );
385 }
#define PAPI_DOM_MIN
Definition: papi.h:297
#define PAPI_HUGE_STR_LEN
Definition: papi.h:465
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
strcpy(filename, default_filename)
char * stringify_domain(int domain)
Definition: test_utils.c:388
#define PAPI_DOM_MAX
Definition: papi.h:303

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.

409 {
410  static char buf[PAPI_HUGE_STR_LEN];
411  int i, did = 0;
412 
413  buf[0] = '\0';
414  for ( i = PAPI_GRN_MIN; i <= PAPI_GRN_MAX; i = i << 1 )
415  if ( granularities & i ) {
416  if ( did )
417  strcpy( buf + strlen( buf ), "|" );
418  strcpy( buf + strlen( buf ),
419  stringify_granularity( granularities & i ) );
420  did++;
421  }
422  if ( did == 0 )
423  test_fail( __FILE__, __LINE__, "Unrecognized granularity!", 0 );
424 
425  return ( buf );
426 }
char * stringify_granularity(int granularity)
Definition: test_utils.c:429
#define PAPI_HUGE_STR_LEN
Definition: papi.h:465
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
#define PAPI_GRN_MAX
Definition: papi.h:366
strcpy(filename, default_filename)
#define PAPI_GRN_MIN
Definition: papi.h:361

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.

389 {
390  switch ( domain ) {
391  case PAPI_DOM_SUPERVISOR:
392  return ( "PAPI_DOM_SUPERVISOR" );
393  case PAPI_DOM_USER:
394  return ( "PAPI_DOM_USER" );
395  case PAPI_DOM_KERNEL:
396  return ( "PAPI_DOM_KERNEL" );
397  case PAPI_DOM_OTHER:
398  return ( "PAPI_DOM_OTHER" );
399  case PAPI_DOM_ALL:
400  return ( "PAPI_DOM_ALL" );
401  default:
402  test_fail( __FILE__, __LINE__, "Unrecognized domains!", 0 );
403  }
404  return ( NULL );
405 }
#define PAPI_DOM_KERNEL
Definition: papi.h:298
#define PAPI_DOM_ALL
Definition: papi.h:301
#define PAPI_DOM_USER
Definition: papi.h:296
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
#define PAPI_DOM_OTHER
Definition: papi.h:299
#define PAPI_DOM_SUPERVISOR
Definition: papi.h:300

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.

430 {
431  switch ( granularity ) {
432  case PAPI_GRN_THR:
433  return ( "PAPI_GRN_THR" );
434  case PAPI_GRN_PROC:
435  return ( "PAPI_GRN_PROC" );
436  case PAPI_GRN_PROCG:
437  return ( "PAPI_GRN_PROCG" );
438  case PAPI_GRN_SYS_CPU:
439  return ( "PAPI_GRN_SYS_CPU" );
440  case PAPI_GRN_SYS:
441  return ( "PAPI_GRN_SYS" );
442  default:
443  test_fail( __FILE__, __LINE__, "Unrecognized granularity!", 0 );
444  }
445  return ( NULL );
446 }
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
#define PAPI_GRN_THR
Definition: papi.h:360
#define PAPI_GRN_SYS_CPU
Definition: papi.h:365
#define PAPI_GRN_PROCG
Definition: papi.h:363
#define PAPI_GRN_SYS
Definition: papi.h:364
#define PAPI_GRN_PROC
Definition: papi.h:362

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.

514 {
515 
516  int line_pad;
517  char buf[128];
518 
519  line_pad=(int)(50-strlen(file));
520  if (line_pad<0) line_pad=0;
521 
522  memset( buf, '\0', sizeof ( buf ) );
523 
524  if (TESTS_COLOR) {
525  fprintf( stdout, "%-*s %sFAILED%s\nLine # %d\n", line_pad, file,
526  RED,NORMAL,line );
527  }
528  else {
529  fprintf( stdout, "%-*s FAILED\nLine # %d\n", line_pad, file, line );
530  }
531 
532  if ( retval == PAPI_ESYS ) {
533  sprintf( buf, "System error in %s", call );
534  perror( buf );
535  } else if ( retval > 0 ) {
536  fprintf( stdout, "Error: %s\n", call );
537  } else if ( retval == 0 ) {
538 #if defined(sgi)
539  fprintf( stdout, "SGI requires root permissions for this test\n" );
540 #else
541  fprintf( stdout, "Error: %s\n", call );
542 #endif
543  } else {
544  fprintf( stdout, "Error in %s: %s\n", call, PAPI_strerror( retval ) );
545  }
546 
547  fprintf( stdout, "\n" );
548 
549  /* NOTE: Because test_fail is called from thread functions,
550  calling PAPI_shutdown here could prevent some threads
551  from being able to free memory they have allocated.
552  */
553 
554  /* This is stupid. Threads are the rare case */
555  /* and in any case an exit() should clear everything out */
556  /* adding back the exit() call */
557 
558  exit(1);
559 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
memset(eventId, 0, size)
static int TESTS_COLOR
Definition: test_utils.c:12
char buf[200]
Definition: iozone.c:19609
const char FILE * file
Definition: pscanf.h:13
#define PAPI_ESYS
Definition: papi.h:253
#define NORMAL
Definition: test_utils.c:471
char * PAPI_strerror(int errorCode)
Definition: papi.c:4529
int
Definition: iozone.c:18528
#define RED
Definition: test_utils.c:468
ssize_t retval
Definition: libasync.c:338
void exit()

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.

568 {
569  test_fail( file, line, call, retval );
570  if ( PAPI_is_initialized( ) )
571  PAPI_shutdown( );
572  exit( 1 );
573 }
int PAPI_is_initialized(void)
Definition: papi.c:6389
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
void PAPI_shutdown(void)
Definition: papi.c:4400
const char FILE * file
Definition: pscanf.h:13
ssize_t retval
Definition: libasync.c:338
void exit()

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.

475 {
476  int line_pad;
477 
478  line_pad=(int)(50-strlen(file));
479  if (line_pad<0) line_pad=0;
480 
481  if ( TEST_WARN ) {
482  if (TESTS_COLOR) {
483  fprintf( stdout, "%-*s %sPASSED with WARNING%s\n",
484  line_pad, file, YELLOW, NORMAL);
485  }
486  else {
487  fprintf( stdout, "%-*s PASSED with WARNING\n",
488  line_pad, file );
489  }
490  }
491  else {
492  if (TESTS_COLOR) {
493  fprintf( stdout, "%-*s %sPASSED%s\n", line_pad, file,
494  GREEN, NORMAL );
495  }
496  else {
497  fprintf( stdout, "%-*s PASSED\n", line_pad, file );
498  }
499  }
500 
501  if ( values )
503 
504  if ( PAPI_is_initialized( ) )
505  PAPI_shutdown( );
506 
507  exit( 0 );
508 
509 }
int PAPI_is_initialized(void)
Definition: papi.c:6389
#define GREEN
Definition: test_utils.c:470
static int TESTS_COLOR
Definition: test_utils.c:12
void PAPI_shutdown(void)
Definition: papi.c:4400
const char FILE * file
Definition: pscanf.h:13
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:131
#define NORMAL
Definition: test_utils.c:471
int num_tests
Definition: zero_fork.c:46
int
Definition: iozone.c:18528
#define YELLOW
Definition: test_utils.c:469
static int TEST_WARN
Definition: test_utils.c:13
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void exit()

Here is the call graph for this function:

void test_print_event_header ( char *  call,
int  evset 
)

Definition at line 645 of file test_utils.c.

646 {
647  int *ev_ids;
648  int i, nev;
649  int retval;
650  char evname[PAPI_MAX_STR_LEN];
651 
652  if ( *call )
653  fprintf( stdout, "%s", call );
654 
655  if ((nev = PAPI_get_cmp_opt(PAPI_MAX_MPX_CTRS,NULL,0)) <= 0) {
656  fprintf( stdout, "Can not list event names.\n" );
657  return;
658  }
659 
660  if ((ev_ids = calloc(nev,sizeof(int))) == NULL) {
661  fprintf( stdout, "Can not list event names.\n" );
662  return;
663  }
664 
665  retval = PAPI_list_events( evset, ev_ids, &nev );
666 
667  if ( retval == PAPI_OK ) {
668  for ( i = 0; i < nev; i++ ) {
669  PAPI_event_code_to_name( ev_ids[i], evname );
670  printf( ONEHDR, evname );
671  }
672  } else {
673  fprintf( stdout, "Can not list event names." );
674  }
675  fprintf( stdout, "\n" );
676  free(ev_ids);
677 }
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
int i
Definition: fileop.c:140
int PAPI_get_cmp_opt(int option, PAPI_option_t *ptr, int cidx)
Definition: papi.c:4274
free(dummyfile[xx])
#define PAPI_MAX_MPX_CTRS
Definition: papi.h:437
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:926
#define ONEHDR
Definition: papi_test.h:107
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
ssize_t retval
Definition: libasync.c:338
int PAPI_list_events(int EventSet, int *Events, int *number)
Definition: papi.c:5927

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.

615 {
616  char buf[128];
617 
618  memset( buf, '\0', sizeof ( buf ) );
619  fprintf( stdout, "%-40s SKIPPED\n", file );
620  if ( !TESTS_QUIET ) {
621  if ( retval == PAPI_ESYS ) {
622  fprintf( stdout, "Line # %d\n", line );
623  sprintf( buf, "System error in %s:", call );
624  perror( buf );
625  } else if ( retval == PAPI_EPERM ) {
626  fprintf( stdout, "Line # %d\n", line );
627  fprintf( stdout, "Invalid permissions for %s.", call );
628  } else if ( retval == PAPI_ECMP ) {
629  fprintf( stdout, "Line # %d\n", line );
630  fprintf( stdout, "%s.", call );
631  } else if ( retval >= 0 ) {
632  fprintf( stdout, "Line # %d\n", line );
633  fprintf( stdout, "Error calculating: %s\n", call );
634  } else if ( retval < 0 ) {
635  fprintf( stdout, "Line # %d\n", line );
636  fprintf( stdout, "Error in %s: %s\n", call, PAPI_strerror(retval) );
637  }
638  fprintf( stdout, "\n" );
639  }
640  exit( 0 );
641 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
memset(eventId, 0, size)
#define PAPI_EPERM
Definition: papi.h:266
int TESTS_QUIET
Definition: test_utils.c:11
char buf[200]
Definition: iozone.c:19609
const char FILE * file
Definition: pscanf.h:13
#define PAPI_ESYS
Definition: papi.h:253
#define PAPI_ECMP
Definition: papi.h:254
char * PAPI_strerror(int errorCode)
Definition: papi.c:4529
ssize_t retval
Definition: libasync.c:338
void exit()

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.

579 {
580 
581  int line_pad;
582 
583  line_pad=(int)(50-strlen(file));
584  if (line_pad<0) line_pad=0;
585 
586  char buf[128];
587  memset( buf, '\0', sizeof ( buf ) );
588 
589  if (TESTS_COLOR) {
590  fprintf( stdout, "%-*s %sWARNING%s\nLine # %d\n", line_pad, file,
591  YELLOW, NORMAL, line );
592  }
593  else {
594  fprintf( stdout, "%-*s WARNING\nLine # %d\n", line_pad, file, line );
595  }
596 
597  if ( retval == PAPI_ESYS ) {
598  sprintf( buf, "System warning in %s", call );
599  perror( buf );
600  } else if ( retval > 0 ) {
601  fprintf( stdout, "Warning: %s\n", call );
602  } else if ( retval == 0 ) {
603  fprintf( stdout, "Warning: %s\n", call );
604  } else {
605  fprintf( stdout, "Warning in %s: %s\n", call, PAPI_strerror( retval ));
606  }
607 
608  fprintf( stdout, "\n" );
609  TEST_WARN++;
610 
611 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
memset(eventId, 0, size)
static int TESTS_COLOR
Definition: test_utils.c:12
char buf[200]
Definition: iozone.c:19609
const char FILE * file
Definition: pscanf.h:13
#define PAPI_ESYS
Definition: papi.h:253
#define NORMAL
Definition: test_utils.c:471
char * PAPI_strerror(int errorCode)
Definition: papi.c:4529
int
Definition: iozone.c:18528
#define YELLOW
Definition: test_utils.c:469
static int TEST_WARN
Definition: test_utils.c:13
ssize_t retval
Definition: libasync.c:338

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.

450 {
451  if ( ( argc > 1 )
452  && ( ( strcasecmp( argv[1], "TESTS_QUIET" ) == 0 )
453  || ( strcasecmp( argv[1], "-q" ) == 0 ) ) ) {
454  TESTS_QUIET = 1;
455  } else {
456  int retval;
457 
458  retval = PAPI_set_debug( PAPI_VERB_ECONT );
459  if ( retval != PAPI_OK )
460  test_fail( __FILE__, __LINE__, "PAPI_set_debug", retval );
461  }
462  if (getenv("TESTS_COLOR")!=NULL) {
463  TESTS_COLOR=1;
464  }
465 
466 }
char * getenv()
#define PAPI_VERB_ECONT
Definition: papi.h:387
return PAPI_OK
Definition: linux-nvml.c:458
static int TESTS_COLOR
Definition: test_utils.c:12
int int argc
Definition: iozone.c:1609
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
ssize_t retval
Definition: libasync.c:338
int PAPI_set_debug(int level)
Definition: papi.c:3070

Here is the call graph for this function:

void touch_dummy ( double ptr,
int  size 
)

Definition at line 41 of file dummy.c.

42 {
43  int i;
44  double *tmp = array;
45  for ( i = 0; i < size; i++, tmp++ )
46  *tmp = ( double ) rand( );
47 }
int i
Definition: fileop.c:140
char *long long size
Definition: iozone.c:12023
int rand()
long long tmp
Definition: iozone.c:12031

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.

85 {
86  if ( ( s == NULL ) || ( strlen( s ) == 0 ) ) {
87  char s2[1024] = "";
88  sprintf( s2, "%s was NULL or length 0", name );
89  test_fail( __FILE__, __LINE__, s2, 0 );
90  }
91 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
s
Definition: iozone.c:20289
double s2
Definition: byte_profile.c:31
char * name
Definition: iozone.c:23648

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct test_events_t test_events[]

Definition at line 191 of file test_utils.c.

int TESTS_QUIET

Definition at line 11 of file test_utils.c.