PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test_utils.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 
6 #include "papi.h"
7 #include "papi_test.h"
8 
9 #define TOLERANCE .2
10 
11 
12 /* Variable to hold reporting status
13  if TRUE, output is suppressed
14  if FALSE output is sent to stdout
15  initialized to FALSE
16  declared here so it can be available globally
17 */
18 int TESTS_QUIET = 0;
19 static int TESTS_COLOR = 1;
20 static int TEST_WARN = 0;
21 
22 void
23 validate_string( const char *name, char *s )
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 }
31 
32 int
33 approx_equals( double a, double b )
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 }
44 
45 long long **
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 }
68 
69 void
70 free_test_space( long long **values, int num_tests )
71 {
72  int i;
73 
74  for ( i = 0; i < num_tests; i++ )
75  free( values[i] );
76  free( values );
77 }
78 
79 
80 
81 int is_event_derived(unsigned int event) {
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 }
96 
97 
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 }
117 
118 
119 /* Add events to an EventSet, as specified by a mask.
120 
121  Returns: number = number of events added
122 
123 */
124 
125 //struct test_events_t {
126 // unsigned int mask;
127 // unsigned int event;
128 //};
129 
140  { MASK_BR_CN, PAPI_BR_CN },
148 };
149 
150 
151 int
152 add_test_events( int *number, int *mask, int allow_derived )
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 ) {
187  PAPI_event_code_to_name(test_events[i].event,
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 }
199 
200 int
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 ) {
272  retval = PAPI_remove_event( *EventSet, PAPI_TOT_INS );
273  if ( retval < PAPI_OK )
274  return ( retval );
275  }
276 
277  if ( mask & MASK_TOT_IIS ) {
278  retval = PAPI_remove_event( *EventSet, PAPI_TOT_IIS );
279  if ( retval < PAPI_OK )
280  return ( retval );
281  }
282 
283  if ( mask & MASK_TOT_CYC ) {
284  retval = PAPI_remove_event( *EventSet, PAPI_TOT_CYC );
285  if ( retval < PAPI_OK )
286  return ( retval );
287  }
288 
289  return ( PAPI_destroy_eventset( EventSet ) );
290 }
291 
292 char *
293 stringify_all_domains( int domains )
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 }
310 
311 char *
312 stringify_domain( int domain )
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 }
330 
331 char *
332 stringify_all_granularities( int granularities )
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 }
351 
352 char *
353 stringify_granularity( int granularity )
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 }
371 
372 /* Checks for TESTS_QUIET or -q command line variable */
373 /* Sets the TESTS_QUIET global variable */
374 /* Also returns the value. */
375 int
376 tests_quiet( int argc, char **argv )
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 }
411 
412 #define RED "\033[1;31m"
413 #define YELLOW "\033[1;33m"
414 #define GREEN "\033[1;32m"
415 #define NORMAL "\033[0m"
416 
417 
418 static void print_spaces(int count) {
419  int i;
420 
421  for(i=0;i<count;i++) {
422  fprintf(stdout, " ");
423  }
424 }
425 
426 
427 /* Ugh, all these "fprintf(stdout)" are due to the */
428 /* TESTS_QUIET #define printf hack */
429 /* FIXME! Revert to printf once we are done converting */
430 
431 void
432 test_pass( const char *filename )
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 }
465 
466 /* Use a positive value of retval to simply print an error message */
467 void
468 test_fail( const char *file, int line, const char *call, int retval )
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 }
519 
520 /* Use a positive value of retval to simply print an error message */
521 void
522 test_warn( const char *file, int line, const char *call, int retval )
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 }
557 
558 void
559 test_skip( const char *file, int line, const char *call, int retval )
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 }
577 
578 
579 void
580 test_print_event_header( const char *call, int evset )
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 }
613 
614 int
615 add_two_events( int *num_events, int *papi_event, int *mask ) {
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 }
644 
645 int
646 add_two_nonderived_events( int *num_events, int *papi_event, int *mask ) {
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 }
681 
682 /* add native events to use all counters */
683 int
684 enum_add_native_events( int *num_events, int **evtcodes,
685  int need_interrupt, int no_software_events,
686  int cidx)
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 
699  s = PAPI_get_component_info( cidx );
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 
760  if ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cidx ) == PAPI_OK ) {
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  }
779  } while ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cidx ) == PAPI_OK
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 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
unsigned int count
Definition: papi.h:987
int PAPI_is_initialized(void)
Definition: papi.c:6463
#define PAPI_NATIVE_MASK
#define PAPI_TOT_IIS
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:796
char * getenv()
#define PAPI_VERB_ECONT
Definition: papi.h:389
#define PAPI_L2_TCH
void test_pass(const char *filename)
Definition: test_utils.c:432
#define PAPI_L2_TCM
#define MASK_BR_CN
Definition: papi_test.h:31
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
Hardware info structure.
Definition: papi.h:780
int is_event_derived(unsigned int event)
Definition: test_utils.c:81
#define PAPI_L1_DCM
#define PAPI_FP_OPS
#define GREEN
Definition: test_utils.c:414
int PAPI_remove_event(int EventSet, int EventCode)
Definition: papi.c:1758
char * stringify_granularity(int granularity)
Definition: test_utils.c:353
#define PAPI_L1_TCM
#define PAPI_NULL
Definition: papi.h:292
static int num_events
#define PAPI_DOM_KERNEL
Definition: papi.h:300
#define PAPI_DOM_MIN
Definition: papi.h:299
void test_print_event_header(const char *call, int evset)
Definition: test_utils.c:580
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:969
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
#define PAPI_TOT_INS
#define PAPI_DOM_ALL
Definition: papi.h:303
#define MAX_TEST_EVENTS
Definition: papi_test.h:42
char * stringify_all_granularities(int granularities)
Definition: test_utils.c:332
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
int count
Definition: iozone.c:22422
#define PAPI_L1_DCA
void validate_string(const char *name, char *s)
Definition: test_utils.c:23
static int TESTS_COLOR
Definition: test_utils.c:19
char filename[MAXNAMESIZE]
Definition: iozone.c:1360
#define PAPI_PRESET_MASK
#define PAPI_BR_MSP
#define PAPI_DOM_USER
Definition: papi.h:298
void
Definition: iozone.c:18627
#define MASK_L1_TCM
Definition: papi_test.h:37
void test_warn(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:522
void double value
Definition: iozone.c:18781
unsigned int cntr_umasks
Definition: papi.h:668
int int argc
Definition: iozone.c:1609
#define PAPI_HUGE_STR_LEN
Definition: papi.h:467
Return codes and api definitions.
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:835
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
char ** argv
Definition: iozone.c:1610
#define MASK_FP_INS
Definition: papi_test.h:38
#define PAPI_L1_DCR
#define PAPI_BR_CN
static int cidx
int i
Definition: fileop.c:140
char buf[200]
Definition: iozone.c:19609
int PAPI_num_hwctrs(void)
Definition: papi.c:3909
#define PAPI_L2_TCA
char * stringify_all_domains(int domains)
Definition: test_utils.c:293
void PAPI_shutdown(void)
Definition: papi.c:4461
#define PAPI_TOT_CYC
int PAPI_get_cmp_opt(int option, PAPI_option_t *ptr, int cidx)
Definition: papi.c:4335
FILE * file
Definition: pscanf.h:13
free(dummyfile[xx])
int k
Definition: iozone.c:19136
#define PAPI_ESYS
Definition: papi.h:255
#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
int add_two_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:615
s
Definition: iozone.c:20289
long long
Definition: iozone.c:19827
static void print_spaces(int count)
Definition: test_utils.c:418
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:70
int approx_equals(double a, double b)
Definition: test_utils.c:33
#define PAPI_ECMP
Definition: papi.h:256
#define PAPI_GRN_MAX
Definition: papi.h:368
#define PAPI_MAX_MPX_CTRS
Definition: papi.h:439
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1357
#define NORMAL
Definition: test_utils.c:415
#define PAPI_GRN_THR
Definition: papi.h:362
#define PAPI_GRN_SYS_CPU
Definition: papi.h:367
#define MASK_TOT_CYC
Definition: papi_test.h:40
double s2
Definition: byte_profile.c:36
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
#define PAPI_L1_ICM
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
#define MASK_FP_OPS
Definition: papi_test.h:24
#define TOLERANCE
Definition: test_utils.c:9
int num_tests
Definition: zero_fork.c:53
#define ONEHDR
Definition: papi_test.h:83
#define MASK_L1_DCR
Definition: papi_test.h:27
strcpy(filename, default_filename)
int enum_add_native_events(int *num_events, int **evtcodes, int need_interrupts, int no_software_events, int cidx)
Definition: test_utils.c:684
int PAPI_query_event(int EventCode)
Definition: papi.c:684
#define MASK_L1_DCA
Definition: papi_test.h:25
#define MASK_TOT_INS
Definition: papi_test.h:39
struct test_events_t test_events[]
Definition: test_utils.c:130
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
char * PAPI_strerror(int errorCode)
Definition: papi.c:4603
char * name
Definition: iozone.c:23648
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
#define PAPI_L1_DCW
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
#define MASK_TOT_IIS
Definition: papi_test.h:28
#define POTENTIAL_EVENTS
int
Definition: iozone.c:18528
#define YELLOW
Definition: test_utils.c:413
#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
add PAPI preset or native hardware event to an event set
static int TEST_WARN
Definition: test_utils.c:20
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:2014
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:646
char * stringify_domain(int domain)
Definition: test_utils.c:312
unsigned int event
Definition: papi_test.h:46
#define PAPI_GRN_PROCG
Definition: papi.h:365
#define MASK_L1_DCW
Definition: papi_test.h:26
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:790
int find_nonderived_event(void)
Definition: test_utils.c:98
#define RED
Definition: test_utils.c:412
#define PAPI_DOM_OTHER
Definition: papi.h:301
#define MASK_BR_MSP
Definition: papi_test.h:30
#define PAPI_DOM_SUPERVISOR
Definition: papi.h:302
#define PAPI_GRN_SYS
Definition: papi.h:366
unsigned int event_code
Definition: papi.h:964
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6185
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:995
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_GRN_MIN
Definition: papi.h:363
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:46
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28
#define PAPI_DOM_MAX
Definition: papi.h:305
void exit()
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:39
#define PAPI_BR_PRC
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201
int PAPI_set_debug(int level)
Definition: papi.c:3126
unsigned int mask
Definition: papi_test.h:45
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:152
#define PAPI_FP_INS
int PAPI_list_events(int EventSet, int *Events, int *number)
Definition: papi.c:6001
#define PAPI_GRN_PROC
Definition: papi.h:364