PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test_utils.c File Reference
Include dependency graph for test_utils.c:

Go to the source code of this file.

Macros

#define TOLERANCE   .2
 
#define RED   "\033[1;31m"
 
#define YELLOW   "\033[1;33m"
 
#define GREEN   "\033[1;32m"
 
#define NORMAL   "\033[0m"
 
#define POTENTIAL_EVENTS   3
 

Functions

void validate_string (const char *name, char *s)
 
int approx_equals (double a, double b)
 
long long ** allocate_test_space (int num_tests, int num_events)
 
void free_test_space (long long **values, int num_tests)
 
int is_event_derived (unsigned int event)
 
int find_nonderived_event (void)
 
int add_test_events (int *number, int *mask, int allow_derived)
 
int remove_test_events (int *EventSet, int mask)
 
char * stringify_all_domains (int domains)
 
char * stringify_domain (int domain)
 
char * stringify_all_granularities (int granularities)
 
char * stringify_granularity (int granularity)
 
int tests_quiet (int argc, char **argv)
 
static void print_spaces (int count)
 
void test_pass (const char *filename)
 
void test_fail (const char *file, int line, const char *call, int retval)
 
void test_warn (const char *file, int line, const char *call, int retval)
 
void test_skip (const char *file, int line, const char *call, int retval)
 
void test_print_event_header (const char *call, int evset)
 
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 enum_add_native_events (int *num_events, int **evtcodes, int need_interrupt, int no_software_events, int cidx)
 

Variables

int TESTS_QUIET = 0
 
static int TESTS_COLOR = 1
 
static int TEST_WARN = 0
 
struct test_events_t test_events [MAX_TEST_EVENTS]
 

Macro Definition Documentation

#define GREEN   "\033[1;32m"

Definition at line 414 of file test_utils.c.

#define NORMAL   "\033[0m"

Definition at line 415 of file test_utils.c.

#define POTENTIAL_EVENTS   3
#define RED   "\033[1;31m"

Definition at line 412 of file test_utils.c.

#define TOLERANCE   .2

Definition at line 9 of file test_utils.c.

#define YELLOW   "\033[1;33m"

Definition at line 413 of file test_utils.c.

Function Documentation

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

Definition at line 152 of file test_utils.c.

153 {
154  int retval,i;
155  int EventSet = PAPI_NULL;
156  char name_string[BUFSIZ];
157 
158  *number = 0;
159 
160  /* create the eventset */
161  retval = PAPI_create_eventset( &EventSet );
162  if ( retval != PAPI_OK ) {
163  test_fail(__FILE__,__LINE__,"Trouble creating eventset",retval);
164  }
165 
166 
167  /* check all the masks */
168  for(i=0;i<MAX_TEST_EVENTS;i++) {
169 
170  if ( *mask & test_events[i].mask ) {
171 
172  /* remove any derived events if told to */
173  if ((is_event_derived(test_events[i].event)) &&
174  (!allow_derived)) {
175  *mask = *mask ^ test_events[i].mask;
176  continue;
177  }
178 
179  retval = PAPI_add_event( EventSet,
180  test_events[i].event );
181 
182  if ( retval == PAPI_OK ) {
183  ( *number )++;
184  }
185  else {
186  if ( !TESTS_QUIET ) {
188  name_string);
189  fprintf( stdout, "%#x %s is not available.\n",
190  test_events[i].event,name_string);
191  }
192  *mask = *mask ^ test_events[i].mask;
193  }
194  }
195  }
196 
197  return EventSet;
198 }
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
int is_event_derived(unsigned int event)
Definition: test_utils.c:81
#define PAPI_NULL
Definition: papi.h:292
#define MAX_TEST_EVENTS
Definition: papi_test.h:42
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
int i
Definition: fileop.c:140
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
struct test_events_t test_events[]
Definition: test_utils.c:130
int TESTS_QUIET
Definition: test_utils.c:18
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
ssize_t retval
Definition: libasync.c:338
unsigned int mask
Definition: papi_test.h:45

Here is the call graph for this function:

Here is the caller graph for this function:

int add_two_events ( int num_events,
int papi_event,
int mask 
)

Definition at line 615 of file test_utils.c.

615  {
616 
617  int retval;
618  int EventSet = PAPI_NULL;
619 
620  *num_events=2;
621  *papi_event=PAPI_TOT_INS;
622  (void)mask;
623 
624  /* create the eventset */
625  retval = PAPI_create_eventset( &EventSet );
626  if ( retval != PAPI_OK ) {
627  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
628  }
629 
630  retval = PAPI_add_named_event( EventSet, "PAPI_TOT_CYC");
631  if ( retval != PAPI_OK ) {
632  if (!TESTS_QUIET) printf("Couldn't add PAPI_TOT_CYC\n");
633  test_skip(__FILE__,__LINE__,"Couldn't add PAPI_TOT_CYC",0);
634  }
635 
636  retval = PAPI_add_named_event( EventSet, "PAPI_TOT_INS");
637  if ( retval != PAPI_OK ) {
638  if (!TESTS_QUIET) printf("Couldn't add PAPI_TOT_CYC\n");
639  test_skip(__FILE__,__LINE__,"Couldn't add PAPI_TOT_CYC",0);
640  }
641 
642  return EventSet;
643 }
#define PAPI_NULL
Definition: papi.h:292
static int num_events
#define PAPI_TOT_INS
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
int PAPI_add_named_event(int EventSet, const char *EventName)
Definition: papi.c:1876
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
ssize_t retval
Definition: libasync.c:338

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 646 of file test_utils.c.

646  {
647 
648  /* query and set up the right event to monitor */
649  int EventSet = PAPI_NULL;
650  int retval;
651 
652  *num_events=0;
653 
654 #define POTENTIAL_EVENTS 3
655 
656  unsigned int potential_evt_to_add[POTENTIAL_EVENTS][2] =
657  { {( unsigned int ) PAPI_FP_INS, MASK_FP_INS},
658  {( unsigned int ) PAPI_FP_OPS, MASK_FP_OPS},
659  {( unsigned int ) PAPI_TOT_INS, MASK_TOT_INS}
660  };
661 
662  int i;
663 
664  *mask = 0;
665 
666  /* could leak up to two event sets. */
667  for(i=0;i<POTENTIAL_EVENTS;i++) {
668  retval = PAPI_query_event( ( int ) potential_evt_to_add[i][0] );
669  if (retval == PAPI_OK ) {
670  if ( !is_event_derived(potential_evt_to_add[i][0])) {
671  *papi_event = ( int ) potential_evt_to_add[i][0];
672  *mask = ( int ) potential_evt_to_add[i][1] | MASK_TOT_CYC;
673  EventSet = add_test_events( num_events, mask, 0 );
674  if ( *num_events == 2 ) break;
675  }
676  }
677  }
678 
679  return EventSet;
680 }
int is_event_derived(unsigned int event)
Definition: test_utils.c:81
#define PAPI_FP_OPS
#define PAPI_NULL
Definition: papi.h:292
static int num_events
#define PAPI_TOT_INS
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
#define MASK_FP_INS
Definition: papi_test.h:38
int i
Definition: fileop.c:140
#define MASK_TOT_CYC
Definition: papi_test.h:40
#define MASK_FP_OPS
Definition: papi_test.h:24
int PAPI_query_event(int EventCode)
Definition: papi.c:684
#define MASK_TOT_INS
Definition: papi_test.h:39
#define POTENTIAL_EVENTS
int
Definition: iozone.c:18528
ssize_t retval
Definition: libasync.c:338
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:152
#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 46 of file test_utils.c.

47 {
48  long long **values;
49  int i;
50 
51  values =
52  ( long long ** ) malloc( ( size_t ) num_tests *
53  sizeof ( long long * ) );
54  if ( values == NULL )
55  exit( 1 );
56  memset( values, 0x0, ( size_t ) num_tests * sizeof ( long long * ) );
57 
58  for ( i = 0; i < num_tests; i++ ) {
59  values[i] =
60  ( long long * ) malloc( ( size_t ) num_events *
61  sizeof ( long long ) );
62  if ( values[i] == NULL )
63  exit( 1 );
64  memset( values[i], 0x00, ( size_t ) num_events * sizeof ( long long ) );
65  }
66  return ( values );
67 }
static int num_events
int i
Definition: fileop.c:140
long long
Definition: iozone.c:19827
int num_tests
Definition: zero_fork.c:53
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 33 of file test_utils.c.

34 {
35  if ( ( a >= b * ( 1.0 - TOLERANCE ) ) && ( a <= b * ( 1.0 + TOLERANCE ) ) )
36  return 1;
37  else {
38  printf( "Out of tolerance range %2.2f: %.0f vs %.0f [%.0f,%.0f]\n",
39  TOLERANCE, a, b, b * ( 1.0 - TOLERANCE ),
40  b * ( 1.0 + TOLERANCE ) );
41  return 0;
42  }
43 }
#define TOLERANCE
Definition: test_utils.c:9
printf("\tTry: -i 0 -i 1 \n\n")
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:39
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38

Here is the call graph for this function:

Here is the caller graph for this function:

int enum_add_native_events ( int num_events,
int **  evtcodes,
int  need_interrupt,
int  no_software_events,
int  cidx 
)

Definition at line 684 of file test_utils.c.

687 {
688  /* query and set up the right event to monitor */
689 
690  int EventSet = PAPI_NULL;
691  int i = 0, k, event_code, retval;
692  int counters, event_found = 0;
693  PAPI_event_info_t info;
694  const PAPI_component_info_t *s = NULL;
695  const PAPI_hw_info_t *hw_info = NULL;
696 
697  *num_events=0;
698 
700  if ( s == NULL ) {
701  test_fail( __FILE__, __LINE__,
702  "PAPI_get_component_info", PAPI_ECMP );
703  }
704 
705  hw_info = PAPI_get_hardware_info( );
706  if ( hw_info == NULL ) {
707  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
708  }
709 
710  counters = PAPI_num_hwctrs( );
711  if (counters<1) {
712  if (!TESTS_QUIET) printf("No counters available\n");
713  return EventSet;
714  }
715 
716  if (!TESTS_QUIET) {
717  printf("Trying to fill %d hardware counters...\n", counters);
718  }
719 
720  if (need_interrupt) {
721  if ( (!strcmp(hw_info->model_string,"POWER6")) ||
722  (!strcmp(hw_info->model_string,"POWER5")) ) {
723 
724  test_warn(__FILE__, __LINE__,
725  "Limiting num_counters because of "
726  "LIMITED_PMC on Power5 and Power6",1);
727  counters=4;
728  }
729  }
730 
731  ( *evtcodes ) = ( int * ) calloc( counters, sizeof ( int ) );
732 
733  retval = PAPI_create_eventset( &EventSet );
734  if ( retval != PAPI_OK ) {
735  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
736  }
737 
738  /* For platform independence, always ASK FOR the first event */
739  /* Don't just assume it'll be the first numeric value */
740  i = 0 | PAPI_NATIVE_MASK;
741  retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cidx );
742  if ( retval != PAPI_OK ) {
743  test_fail( __FILE__, __LINE__, "PAPI_enum_cmp_event", retval );
744  }
745 
746  do {
747  retval = PAPI_get_event_info( i, &info );
748 
749  /* HACK! FIXME */
750  if (no_software_events && ( strstr(info.symbol,"PERF_COUNT_SW") || strstr(info.long_descr, "PERF_COUNT_SW") ) ) {
751  if (!TESTS_QUIET) {
752  printf("Blocking event %s as a SW event\n", info.symbol);
753  }
754  continue;
755  }
756 
757  if ( s->cntr_umasks ) {
758  k = i;
759 
761  do {
762  retval = PAPI_get_event_info( k, &info );
763  event_code = ( int ) info.event_code;
764 
765  retval = PAPI_add_event( EventSet, event_code );
766  if ( retval == PAPI_OK ) {
767  ( *evtcodes )[event_found] = event_code;
768  if ( !TESTS_QUIET ) {
769  printf( "event_code[%d] = %#x (%s)\n",
770  event_found, event_code, info.symbol );
771  }
772  event_found++;
773  } else {
774  if ( !TESTS_QUIET ) {
775  printf( "%#x (%s) can't be added to the EventSet.\n",
776  event_code, info.symbol );
777  }
778  }
780  && event_found < counters );
781  } else {
782  event_code = ( int ) info.event_code;
783  retval = PAPI_add_event( EventSet, event_code );
784  if ( retval == PAPI_OK ) {
785  ( *evtcodes )[event_found] = event_code;
786  if ( !TESTS_QUIET ) {
787  printf( "event_code[%d] = %#x (%s)\n",
788  event_found, event_code, info.symbol );
789  }
790  event_found++;
791  }
792  }
793  if ( !TESTS_QUIET && retval == PAPI_OK ) {
794  /* */
795  }
796  } else {
797  event_code = ( int ) info.event_code;
798  retval = PAPI_add_event( EventSet, event_code );
799  if ( retval == PAPI_OK ) {
800  ( *evtcodes )[event_found] = event_code;
801  event_found++;
802  } else {
803  if ( !TESTS_QUIET )
804  fprintf( stdout, "%#x is not available.\n", event_code );
805  }
806  }
807  }
808  while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cidx ) == PAPI_OK &&
809  event_found < counters );
810 
811  *num_events = ( int ) event_found;
812 
813  if (!TESTS_QUIET) printf("Tried to fill %d counters with events, "
814  "found %d\n",counters,event_found);
815 
816  return EventSet;
817 }
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:796
Hardware info structure.
Definition: papi.h:780
#define PAPI_NULL
Definition: papi.h:292
static int num_events
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:969
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
void test_warn(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:522
unsigned int cntr_umasks
Definition: papi.h:668
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:835
static int cidx
int i
Definition: fileop.c:140
int PAPI_num_hwctrs(void)
Definition: papi.c:3909
int k
Definition: iozone.c:19136
s
Definition: iozone.c:20289
#define PAPI_ECMP
Definition: papi.h:256
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1357
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
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:790
unsigned int event_code
Definition: papi.h:964
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6185
ssize_t retval
Definition: libasync.c:338
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28

Here is the call graph for this function:

Here is the caller graph for this function:

int find_nonderived_event ( void  )

Definition at line 98 of file test_utils.c.

99 {
100  /* query and set up the right event to monitor */
101  PAPI_event_info_t info;
102  int potential_evt_to_add[3] = { PAPI_FP_OPS, PAPI_FP_INS, PAPI_TOT_INS };
103  int i;
104 
105  for ( i = 0; i < 3; i++ ) {
106  if ( PAPI_query_event( potential_evt_to_add[i] ) == PAPI_OK ) {
107  if ( PAPI_get_event_info( potential_evt_to_add[i], &info ) ==
108  PAPI_OK ) {
109  if ( ( info.count > 0 ) &&
110  !strcmp( info.derived, "NOT_DERIVED" ) )
111  return ( potential_evt_to_add[i] );
112  }
113  }
114  }
115  return ( 0 );
116 }
unsigned int count
Definition: papi.h:987
#define PAPI_FP_OPS
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:497
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:835
int i
Definition: fileop.c:140
int PAPI_query_event(int EventCode)
Definition: papi.c:684
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:995
#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 70 of file test_utils.c.

71 {
72  int i;
73 
74  for ( i = 0; i < num_tests; i++ )
75  free( values[i] );
76  free( values );
77 }
int i
Definition: fileop.c:140
free(dummyfile[xx])
int num_tests
Definition: zero_fork.c:53
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:

int is_event_derived ( unsigned int  event)

Definition at line 81 of file test_utils.c.

81  {
82 
83  PAPI_event_info_t info;
84 
85  if (event & PAPI_PRESET_MASK) {
86 
87  PAPI_get_event_info(event,&info);
88 
89  if (strcmp(info.derived,"NOT_DERIVED")) {
90  // printf("%#x is derived\n",event);
91  return 1;
92  }
93  }
94  return 0;
95 }
#define PAPI_PRESET_MASK
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:835
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:995

Here is the call graph for this function:

Here is the caller graph for this function:

static void print_spaces ( int  count)
static

Definition at line 418 of file test_utils.c.

418  {
419  int i;
420 
421  for(i=0;i<count;i++) {
422  fprintf(stdout, " ");
423  }
424 }
int count
Definition: iozone.c:22422
int i
Definition: fileop.c:140

Here is the caller graph for this function:

int remove_test_events ( int EventSet,
int  mask 
)

Definition at line 201 of file test_utils.c.

202 {
203  int retval = PAPI_OK;
204 
205  if ( mask & MASK_L1_DCA ) {
206  retval = PAPI_remove_event( *EventSet, PAPI_L1_DCA );
207  if ( retval < PAPI_OK )
208  return ( retval );
209  }
210 
211  if ( mask & MASK_L1_DCW ) {
212  retval = PAPI_remove_event( *EventSet, PAPI_L1_DCW );
213  if ( retval < PAPI_OK )
214  return ( retval );
215  }
216 
217  if ( mask & MASK_L1_DCR ) {
218  retval = PAPI_remove_event( *EventSet, PAPI_L1_DCR );
219  if ( retval < PAPI_OK )
220  return ( retval );
221  }
222 
223  if ( mask & MASK_L2_TCH ) {
224  retval = PAPI_remove_event( *EventSet, PAPI_L2_TCH );
225  if ( retval < PAPI_OK )
226  return ( retval );
227  }
228 
229  if ( mask & MASK_L2_TCA ) {
230  retval = PAPI_remove_event( *EventSet, PAPI_L2_TCA );
231  if ( retval < PAPI_OK )
232  return ( retval );
233  }
234 
235  if ( mask & MASK_L2_TCM ) {
236  retval = PAPI_remove_event( *EventSet, PAPI_L2_TCM );
237  if ( retval < PAPI_OK )
238  return ( retval );
239  }
240 
241  if ( mask & MASK_L1_DCM ) {
242  retval = PAPI_remove_event( *EventSet, PAPI_L1_DCM );
243  if ( retval < PAPI_OK )
244  return ( retval );
245  }
246 
247  if ( mask & MASK_L1_ICM ) {
248  retval = PAPI_remove_event( *EventSet, PAPI_L1_ICM );
249  if ( retval < PAPI_OK )
250  return ( retval );
251  }
252 
253  if ( mask & MASK_L1_TCM ) {
254  retval = PAPI_remove_event( *EventSet, PAPI_L1_TCM );
255  if ( retval < PAPI_OK )
256  return ( retval );
257  }
258 
259  if ( mask & MASK_FP_OPS ) {
260  retval = PAPI_remove_event( *EventSet, PAPI_FP_OPS );
261  if ( retval < PAPI_OK )
262  return ( retval );
263  }
264 
265  if ( mask & MASK_FP_INS ) {
266  retval = PAPI_remove_event( *EventSet, PAPI_FP_INS );
267  if ( retval < PAPI_OK )
268  return ( retval );
269  }
270 
271  if ( mask & MASK_TOT_INS ) {
273  if ( retval < PAPI_OK )
274  return ( retval );
275  }
276 
277  if ( mask & MASK_TOT_IIS ) {
279  if ( retval < PAPI_OK )
280  return ( retval );
281  }
282 
283  if ( mask & MASK_TOT_CYC ) {
285  if ( retval < PAPI_OK )
286  return ( retval );
287  }
288 
289  return ( PAPI_destroy_eventset( EventSet ) );
290 }
#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:1758
#define PAPI_L1_TCM
#define PAPI_TOT_INS
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
#define PAPI_L1_DCA
#define MASK_L1_TCM
Definition: papi_test.h:37
#define MASK_FP_INS
Definition: papi_test.h:38
#define PAPI_L1_DCR
#define PAPI_L2_TCA
#define PAPI_TOT_CYC
#define MASK_L2_TCH
Definition: papi_test.h:32
#define MASK_L2_TCA
Definition: papi_test.h:33
#define MASK_TOT_CYC
Definition: papi_test.h:40
#define PAPI_L1_ICM
#define MASK_FP_OPS
Definition: papi_test.h:24
#define MASK_L1_DCR
Definition: papi_test.h:27
#define MASK_L1_DCA
Definition: papi_test.h:25
#define MASK_TOT_INS
Definition: papi_test.h:39
#define PAPI_L1_DCW
#define MASK_TOT_IIS
Definition: papi_test.h:28
#define MASK_L2_TCM
Definition: papi_test.h:34
#define MASK_L1_ICM
Definition: papi_test.h:36
#define MASK_L1_DCM
Definition: papi_test.h:35
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:2014
#define MASK_L1_DCW
Definition: papi_test.h:26
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 293 of file test_utils.c.

294 {
295  static char buf[PAPI_HUGE_STR_LEN];
296  int i, did = 0;
297  buf[0] = '\0';
298 
299  for ( i = PAPI_DOM_MIN; i <= PAPI_DOM_MAX; i = i << 1 )
300  if ( domains & i ) {
301  if ( did )
302  strcpy( buf + strlen( buf ), "|" );
303  strcpy( buf + strlen( buf ), stringify_domain( domains & i ) );
304  did++;
305  }
306  if ( did == 0 )
307  test_fail( __FILE__, __LINE__, "Unrecognized domains!", 0 );
308  return ( buf );
309 }
#define PAPI_DOM_MIN
Definition: papi.h:299
#define PAPI_HUGE_STR_LEN
Definition: papi.h:467
int i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
strcpy(filename, default_filename)
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
char * stringify_domain(int domain)
Definition: test_utils.c:312
#define PAPI_DOM_MAX
Definition: papi.h:305

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 332 of file test_utils.c.

333 {
334  static char buf[PAPI_HUGE_STR_LEN];
335  int i, did = 0;
336 
337  buf[0] = '\0';
338  for ( i = PAPI_GRN_MIN; i <= PAPI_GRN_MAX; i = i << 1 )
339  if ( granularities & i ) {
340  if ( did )
341  strcpy( buf + strlen( buf ), "|" );
342  strcpy( buf + strlen( buf ),
343  stringify_granularity( granularities & i ) );
344  did++;
345  }
346  if ( did == 0 )
347  test_fail( __FILE__, __LINE__, "Unrecognized granularity!", 0 );
348 
349  return ( buf );
350 }
char * stringify_granularity(int granularity)
Definition: test_utils.c:353
#define PAPI_HUGE_STR_LEN
Definition: papi.h:467
int i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
#define PAPI_GRN_MAX
Definition: papi.h:368
strcpy(filename, default_filename)
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
#define PAPI_GRN_MIN
Definition: papi.h:363

Here is the call graph for this function:

Here is the caller graph for this function:

char* stringify_domain ( int  domain)

Definition at line 312 of file test_utils.c.

313 {
314  switch ( domain ) {
315  case PAPI_DOM_SUPERVISOR:
316  return ( "PAPI_DOM_SUPERVISOR" );
317  case PAPI_DOM_USER:
318  return ( "PAPI_DOM_USER" );
319  case PAPI_DOM_KERNEL:
320  return ( "PAPI_DOM_KERNEL" );
321  case PAPI_DOM_OTHER:
322  return ( "PAPI_DOM_OTHER" );
323  case PAPI_DOM_ALL:
324  return ( "PAPI_DOM_ALL" );
325  default:
326  test_fail( __FILE__, __LINE__, "Unrecognized domains!", 0 );
327  }
328  return ( NULL );
329 }
#define PAPI_DOM_KERNEL
Definition: papi.h:300
#define PAPI_DOM_ALL
Definition: papi.h:303
#define PAPI_DOM_USER
Definition: papi.h:298
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
#define PAPI_DOM_OTHER
Definition: papi.h:301
#define PAPI_DOM_SUPERVISOR
Definition: papi.h:302

Here is the call graph for this function:

Here is the caller graph for this function:

char* stringify_granularity ( int  granularity)

Definition at line 353 of file test_utils.c.

354 {
355  switch ( granularity ) {
356  case PAPI_GRN_THR:
357  return ( "PAPI_GRN_THR" );
358  case PAPI_GRN_PROC:
359  return ( "PAPI_GRN_PROC" );
360  case PAPI_GRN_PROCG:
361  return ( "PAPI_GRN_PROCG" );
362  case PAPI_GRN_SYS_CPU:
363  return ( "PAPI_GRN_SYS_CPU" );
364  case PAPI_GRN_SYS:
365  return ( "PAPI_GRN_SYS" );
366  default:
367  test_fail( __FILE__, __LINE__, "Unrecognized granularity!", 0 );
368  }
369  return ( NULL );
370 }
#define PAPI_GRN_THR
Definition: papi.h:362
#define PAPI_GRN_SYS_CPU
Definition: papi.h:367
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
#define PAPI_GRN_PROCG
Definition: papi.h:365
#define PAPI_GRN_SYS
Definition: papi.h:366
#define PAPI_GRN_PROC
Definition: papi.h:364

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 468 of file test_utils.c.

469 {
470 // int line_pad;
471  char buf[128];
472 
473  (void)file;
474 
475 // line_pad=(60-strlen(file));
476 // if (line_pad<0) line_pad=0;
477 
478 // fprintf(stdout,"%s",file);
479 // print_spaces(line_pad);
480 
481  memset( buf, '\0', sizeof ( buf ) );
482 
483  if (TESTS_COLOR) fprintf(stdout,"%s",RED);
484  fprintf( stdout, "FAILED!!!");
485  if (TESTS_COLOR) fprintf(stdout,"%s",NORMAL);
486  fprintf( stdout, "\nLine # %d ", line );
487 
488  if ( retval == PAPI_ESYS ) {
489  sprintf( buf, "System error in %s", call );
490  perror( buf );
491  } else if ( retval > 0 ) {
492  fprintf( stdout, "Error: %s\n", call );
493  } else if ( retval == 0 ) {
494 #if defined(sgi)
495  fprintf( stdout, "SGI requires root permissions for this test\n" );
496 #else
497  fprintf( stdout, "Error: %s\n", call );
498 #endif
499  } else {
500  fprintf( stdout, "Error in %s: %s\n", call, PAPI_strerror( retval ) );
501  }
502 
503 // fprintf( stdout, "\n" );
504 
505  /* NOTE: Because test_fail is called from thread functions,
506  calling PAPI_shutdown here could prevent some threads
507  from being able to free memory they have allocated.
508  */
509  if ( PAPI_is_initialized( ) ) {
510  PAPI_shutdown( );
511  }
512 
513  /* This is stupid. Threads are the rare case */
514  /* and in any case an exit() should clear everything out */
515  /* adding back the exit() call */
516 
517  exit(1);
518 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
int PAPI_is_initialized(void)
Definition: papi.c:6463
static int TESTS_COLOR
Definition: test_utils.c:19
void
Definition: iozone.c:18627
char buf[200]
Definition: iozone.c:19609
void PAPI_shutdown(void)
Definition: papi.c:4461
FILE * file
Definition: pscanf.h:13
#define PAPI_ESYS
Definition: papi.h:255
#define NORMAL
Definition: test_utils.c:415
char * PAPI_strerror(int errorCode)
Definition: papi.c:4603
#define RED
Definition: test_utils.c:412
ssize_t retval
Definition: libasync.c:338
void exit()

Here is the call graph for this function:

void test_pass ( const char *  filename)

Definition at line 432 of file test_utils.c.

433 {
434  (void)filename;
435 
436 // int line_pad;
437 
438 // line_pad=60-strlen(filename);
439 // if (line_pad<0) line_pad=0;
440 
441 // fprintf(stdout,"%s",filename);
442 // print_spaces(line_pad);
443 
444  if ( TEST_WARN ) {
445  print_spaces(59);
446  if (TESTS_COLOR) fprintf( stdout, "%s", YELLOW);
447  fprintf( stdout, "PASSED with WARNING");
448  if (TESTS_COLOR) fprintf( stdout, "%s", NORMAL);
449  fprintf( stdout, "\n");
450  }
451  else {
452  if (TESTS_COLOR) fprintf( stdout, "%s",GREEN);
453  fprintf( stdout, "PASSED");
454  if (TESTS_COLOR) fprintf( stdout, "%s",NORMAL);
455  fprintf( stdout, "\n");
456  }
457 
458  if ( PAPI_is_initialized( ) ) {
459  PAPI_shutdown( );
460  }
461 
462  exit( 0 );
463 
464 }
int PAPI_is_initialized(void)
Definition: papi.c:6463
#define GREEN
Definition: test_utils.c:414
static int TESTS_COLOR
Definition: test_utils.c:19
char filename[MAXNAMESIZE]
Definition: iozone.c:1360
void
Definition: iozone.c:18627
void PAPI_shutdown(void)
Definition: papi.c:4461
static void print_spaces(int count)
Definition: test_utils.c:418
#define NORMAL
Definition: test_utils.c:415
#define YELLOW
Definition: test_utils.c:413
static int TEST_WARN
Definition: test_utils.c:20
void exit()

Here is the call graph for this function:

Here is the caller graph for this function:

void test_print_event_header ( const char *  call,
int  evset 
)

Definition at line 580 of file test_utils.c.

581 {
582  int *ev_ids;
583  int i, nev;
584  int retval;
585  char evname[PAPI_MAX_STR_LEN];
586 
587  if ( *call )
588  fprintf( stdout, "%s", call );
589 
590  if ((nev = PAPI_get_cmp_opt(PAPI_MAX_MPX_CTRS,NULL,0)) <= 0) {
591  fprintf( stdout, "Can not list event names.\n" );
592  return;
593  }
594 
595  if ((ev_ids = calloc(nev,sizeof(int))) == NULL) {
596  fprintf( stdout, "Can not list event names.\n" );
597  return;
598  }
599 
600  retval = PAPI_list_events( evset, ev_ids, &nev );
601 
602  if ( retval == PAPI_OK ) {
603  for ( i = 0; i < nev; i++ ) {
604  PAPI_event_code_to_name( ev_ids[i], evname );
605  printf( ONEHDR, evname );
606  }
607  } else {
608  fprintf( stdout, "Can not list event names." );
609  }
610  fprintf( stdout, "\n" );
611  free(ev_ids);
612 }
return PAPI_OK
Definition: linux-nvml.c:497
int i
Definition: fileop.c:140
int PAPI_get_cmp_opt(int option, PAPI_option_t *ptr, int cidx)
Definition: papi.c:4335
free(dummyfile[xx])
#define PAPI_MAX_MPX_CTRS
Definition: papi.h:439
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
#define ONEHDR
Definition: papi_test.h:83
printf("\tTry: -i 0 -i 1 \n\n")
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
ssize_t retval
Definition: libasync.c:338
int PAPI_list_events(int EventSet, int *Events, int *number)
Definition: papi.c:6001

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 559 of file test_utils.c.

560 {
561 // int line_pad;
562 
563  (void)file;
564  (void)line;
565  (void)call;
566  (void)retval;
567 
568 // line_pad=(60-strlen(file));
569 
570 // fprintf(stdout,"%s",file);
571 // print_spaces(line_pad);
572 
573  fprintf( stdout, "SKIPPED\n");
574 
575  exit( 0 );
576 }
void
Definition: iozone.c:18627
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_warn ( const char *  file,
int  line,
const char *  call,
int  retval 
)

Definition at line 522 of file test_utils.c.

523 {
524 
525  (void)file;
526 
527 // int line_pad;
528 
529 // line_pad=60-strlen(file);
530 // if (line_pad<0) line_pad=0;
531 
532  char buf[128];
533  memset( buf, '\0', sizeof ( buf ) );
534 
535 // fprintf(stdout,"%s",file);
536 // print_spaces(line_pad);
537 
538  if (TEST_WARN==0) fprintf(stdout,"\n");
539  if (TESTS_COLOR) fprintf( stdout, "%s", YELLOW);
540  fprintf( stdout, "WARNING ");
541  if (TESTS_COLOR) fprintf( stdout, "%s", NORMAL);
542  fprintf( stdout, "Line # %d ", line );
543 
544  if ( retval == PAPI_ESYS ) {
545  sprintf( buf, "System warning in %s", call );
546  perror( buf );
547  } else if ( retval > 0 ) {
548  fprintf( stdout, "Warning: %s\n", call );
549  } else if ( retval == 0 ) {
550  fprintf( stdout, "Warning: %s\n", call );
551  } else {
552  fprintf( stdout, "Warning in %s: %s\n", call, PAPI_strerror( retval ));
553  }
554 
555  TEST_WARN++;
556 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
static int TESTS_COLOR
Definition: test_utils.c:19
void
Definition: iozone.c:18627
char buf[200]
Definition: iozone.c:19609
FILE * file
Definition: pscanf.h:13
#define PAPI_ESYS
Definition: papi.h:255
#define NORMAL
Definition: test_utils.c:415
char * PAPI_strerror(int errorCode)
Definition: papi.c:4603
#define YELLOW
Definition: test_utils.c:413
static int TEST_WARN
Definition: test_utils.c:20
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int tests_quiet ( int  argc,
char **  argv 
)

Definition at line 376 of file test_utils.c.

377 {
378  char *value;
379  int retval;
380 
381  if ( ( argc > 1 )
382  && ( ( strcasecmp( argv[1], "TESTS_QUIET" ) == 0 )
383  || ( strcasecmp( argv[1], "-q" ) == 0 ) ) ) {
384  TESTS_QUIET = 1;
385  }
386 
387  /* Always report PAPI errors when testing */
388  /* Even in quiet mode */
389  retval = PAPI_set_debug( PAPI_VERB_ECONT );
390  if ( retval != PAPI_OK ) {
391  test_fail( __FILE__, __LINE__, "PAPI_set_debug", retval );
392  }
393 
394  value=getenv("TESTS_COLOR");
395  if (value!=NULL) {
396  if (value[0]=='y') {
397  TESTS_COLOR=1;
398  }
399  else {
400  TESTS_COLOR=0;
401  }
402  }
403 
404  /* Disable colors if sending to a file */
405  if (!isatty(fileno(stdout))) {
406  TESTS_COLOR=0;
407  }
408 
409  return TESTS_QUIET;
410 }
char * getenv()
#define PAPI_VERB_ECONT
Definition: papi.h:389
return PAPI_OK
Definition: linux-nvml.c:497
static int TESTS_COLOR
Definition: test_utils.c:19
void double value
Definition: iozone.c:18781
int int argc
Definition: iozone.c:1609
char ** argv
Definition: iozone.c:1610
int TESTS_QUIET
Definition: test_utils.c:18
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
ssize_t retval
Definition: libasync.c:338
int PAPI_set_debug(int level)
Definition: papi.c:3126

Here is the call graph for this function:

Here is the caller graph for this function:

void validate_string ( const char *  name,
char *  s 
)

Definition at line 23 of file test_utils.c.

24 {
25  if ( ( s == NULL ) || ( strlen( s ) == 0 ) ) {
26  char s2[1024] = "";
27  sprintf( s2, "%s was NULL or length 0", name );
28  test_fail( __FILE__, __LINE__, s2, 0 );
29  }
30 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
s
Definition: iozone.c:20289
double s2
Definition: byte_profile.c:36
char * name
Definition: iozone.c:23648
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct test_events_t test_events[MAX_TEST_EVENTS]
Initial value:
= {
}
#define PAPI_TOT_IIS
#define PAPI_L2_TCH
#define PAPI_L2_TCM
#define MASK_BR_CN
Definition: papi_test.h:31
#define PAPI_L1_DCM
#define PAPI_FP_OPS
#define PAPI_L1_TCM
#define PAPI_TOT_INS
#define PAPI_L1_DCA
#define PAPI_BR_MSP
#define MASK_L1_TCM
Definition: papi_test.h:37
#define MASK_FP_INS
Definition: papi_test.h:38
#define PAPI_L1_DCR
#define PAPI_BR_CN
#define PAPI_L2_TCA
#define PAPI_TOT_CYC
#define MASK_L2_TCH
Definition: papi_test.h:32
#define MASK_BR_PRC
Definition: papi_test.h:29
#define MASK_L2_TCA
Definition: papi_test.h:33
#define MASK_TOT_CYC
Definition: papi_test.h:40
#define PAPI_L1_ICM
#define MASK_FP_OPS
Definition: papi_test.h:24
#define MASK_L1_DCR
Definition: papi_test.h:27
#define MASK_L1_DCA
Definition: papi_test.h:25
#define MASK_TOT_INS
Definition: papi_test.h:39
#define PAPI_L1_DCW
#define MASK_TOT_IIS
Definition: papi_test.h:28
#define MASK_L2_TCM
Definition: papi_test.h:34
#define MASK_L1_ICM
Definition: papi_test.h:36
#define MASK_L1_DCM
Definition: papi_test.h:35
#define MASK_L1_DCW
Definition: papi_test.h:26
#define MASK_BR_MSP
Definition: papi_test.h:30
#define PAPI_BR_PRC
#define PAPI_FP_INS

Definition at line 130 of file test_utils.c.

int TEST_WARN = 0
static

Definition at line 20 of file test_utils.c.

int TESTS_COLOR = 1
static

Definition at line 19 of file test_utils.c.

int TESTS_QUIET = 0

Definition at line 18 of file test_utils.c.