PAPI 7.1.0.0
Loading...
Searching...
No Matches
papi_test.h File Reference

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 PAPI_NORETURN
 
#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"
 

Functions

void validate_string (const char *name, char *s)
 
void * get_overflow_address (void *context)
 
void free_test_space (long long **values, int num_tests)
 
long long ** allocate_test_space (int num_tests, int num_events)
 
int add_test_events (int *number, int *mask, int allow_derived)
 
int add_two_events (int *num_events, int *papi_event, int *mask)
 
int add_two_nonderived_events (int *num_events, int *papi_event, int *mask)
 
int add_test_events_r (int *number, int *mask, void *handle)
 
int find_nonderived_event (void)
 
int enum_add_native_events (int *num_events, int **evtcodes, int need_interrupts, int no_software_events, int cidx)
 
int remove_test_events (int *EventSet, int mask)
 
char * stringify_domain (int domain)
 
char * stringify_all_domains (int domains)
 
char * stringify_granularity (int granularity)
 
char * stringify_all_granularities (int granularities)
 
int tests_quiet (int argc, char **argv)
 
void PAPI_NORETURN test_pass (const char *filename)
 
void PAPI_NORETURN test_hl_pass (const char *filename)
 
void PAPI_NORETURN test_fail (const char *file, int line, const char *call, int retval)
 
void PAPI_NORETURN test_skip (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_print_event_header (const char *call, int evset)
 
int approx_equals (double a, double b)
 

Variables

struct test_events_t test_events []
 
int TESTS_QUIET
 

Macro Definition Documentation

◆ LLDFMT

#define LLDFMT   "%lld"

Definition at line 104 of file papi_test.h.

◆ LLDFMT10

#define LLDFMT10   "%10lld"

Definition at line 105 of file papi_test.h.

◆ LLDFMT12

#define LLDFMT12   "%12lld"

Definition at line 106 of file papi_test.h.

◆ LLDFMT15

#define LLDFMT15   "%15lld"

Definition at line 107 of file papi_test.h.

◆ MASK_BR_CN

#define MASK_BR_CN   0x00800

Definition at line 31 of file papi_test.h.

◆ MASK_BR_MSP

#define MASK_BR_MSP   0x01000

Definition at line 30 of file papi_test.h.

◆ MASK_BR_PRC

#define MASK_BR_PRC   0x02000

Definition at line 29 of file papi_test.h.

◆ MASK_FP_INS

#define MASK_FP_INS   0x00004

Definition at line 38 of file papi_test.h.

◆ MASK_FP_OPS

#define MASK_FP_OPS   0x80000

Definition at line 24 of file papi_test.h.

◆ MASK_L1_DCA

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

Definition at line 25 of file papi_test.h.

◆ MASK_L1_DCM

#define MASK_L1_DCM   0x00040

Definition at line 35 of file papi_test.h.

◆ MASK_L1_DCR

#define MASK_L1_DCR   0x10000

Definition at line 27 of file papi_test.h.

◆ MASK_L1_DCW

#define MASK_L1_DCW   0x20000

Definition at line 26 of file papi_test.h.

◆ MASK_L1_ICM

#define MASK_L1_ICM   0x00020

Definition at line 36 of file papi_test.h.

◆ MASK_L1_TCM

#define MASK_L1_TCM   0x00010

Definition at line 37 of file papi_test.h.

◆ MASK_L2_TCA

#define MASK_L2_TCA   0x00200

Definition at line 33 of file papi_test.h.

◆ MASK_L2_TCH

#define MASK_L2_TCH   0x00400

Definition at line 32 of file papi_test.h.

◆ MASK_L2_TCM

#define MASK_L2_TCM   0x00100

Definition at line 34 of file papi_test.h.

◆ MASK_TOT_CYC

#define MASK_TOT_CYC   0x00001

Definition at line 40 of file papi_test.h.

◆ MASK_TOT_IIS

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

Definition at line 28 of file papi_test.h.

◆ MASK_TOT_INS

#define MASK_TOT_INS   0x00002

Definition at line 39 of file papi_test.h.

◆ MAX_TEST_EVENTS

#define MAX_TEST_EVENTS   18

Definition at line 42 of file papi_test.h.

◆ ONEHDR

#define ONEHDR   " %12s"

Definition at line 93 of file papi_test.h.

◆ ONENUM

#define ONENUM   " %12lld"

Definition at line 97 of file papi_test.h.

◆ PAPI_NORETURN

#define PAPI_NORETURN

Definition at line 55 of file papi_test.h.

◆ TAB1

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

Definition at line 98 of file papi_test.h.

◆ TAB2

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

Definition at line 99 of file papi_test.h.

◆ TAB2HDR

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

Definition at line 94 of file papi_test.h.

◆ TAB3

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

Definition at line 100 of file papi_test.h.

◆ TAB3HDR

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

Definition at line 95 of file papi_test.h.

◆ TAB4

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

Definition at line 101 of file papi_test.h.

◆ TAB4HDR

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

Definition at line 96 of file papi_test.h.

◆ TAB5

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

Definition at line 102 of file papi_test.h.

◆ TWO12

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

Definition at line 103 of file papi_test.h.

Function Documentation

◆ add_test_events()

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 */
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
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 i
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Convert a numeric hardware event code to a name.
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
static int EventSet
Definition: init_fini.c:8
FILE * stdout
#define MAX_TEST_EVENTS
Definition: papi_test.h:42
unsigned int mask
Definition: papi_test.h:45
struct test_events_t test_events[MAX_TEST_EVENTS]
Definition: test_utils.c:130
int TESTS_QUIET
Definition: test_utils.c:18
int is_event_derived(unsigned int event)
Definition: test_utils.c:81
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_test_events_r()

int add_test_events_r ( int number,
int mask,
void *  handle 
)

◆ add_two_events()

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

Definition at line 640 of file test_utils.c.

640 {
641
642 int retval;
643 int EventSet = PAPI_NULL;
644
645 *num_events=2;
646 *papi_event=PAPI_TOT_INS;
647 (void)mask;
648
649 /* create the eventset */
651 if ( retval != PAPI_OK ) {
652 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
653 }
654
655 retval = PAPI_add_named_event( EventSet, "PAPI_TOT_CYC");
656 if ( retval != PAPI_OK ) {
657 if (!TESTS_QUIET) printf("Couldn't add PAPI_TOT_CYC\n");
658 test_skip(__FILE__,__LINE__,"Couldn't add PAPI_TOT_CYC",0);
659 }
660
661 retval = PAPI_add_named_event( EventSet, "PAPI_TOT_INS");
662 if ( retval != PAPI_OK ) {
663 if (!TESTS_QUIET) printf("Couldn't add PAPI_TOT_CYC\n");
664 test_skip(__FILE__,__LINE__,"Couldn't add PAPI_TOT_CYC",0);
665 }
666
667 return EventSet;
668}
add PAPI preset or native hardware event by name to an EventSet
#define PAPI_TOT_INS
Definition: f90papi.h:317
static int num_events
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_two_nonderived_events()

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

Definition at line 671 of file test_utils.c.

671 {
672
673 /* query and set up the right event to monitor */
674 int EventSet = PAPI_NULL;
675 int retval;
676
677 *num_events=0;
678
679#define POTENTIAL_EVENTS 3
680
681 unsigned int potential_evt_to_add[POTENTIAL_EVENTS][2] =
682 { {( unsigned int ) PAPI_FP_INS, MASK_FP_INS},
683 {( unsigned int ) PAPI_FP_OPS, MASK_FP_OPS},
684 {( unsigned int ) PAPI_TOT_INS, MASK_TOT_INS}
685 };
686
687 int i;
688
689 *mask = 0;
690
691 /* could leak up to two event sets. */
692 for(i=0;i<POTENTIAL_EVENTS;i++) {
693 retval = PAPI_query_event( ( int ) potential_evt_to_add[i][0] );
694 if (retval == PAPI_OK ) {
695 if ( !is_event_derived(potential_evt_to_add[i][0])) {
696 *papi_event = ( int ) potential_evt_to_add[i][0];
697 *mask = ( int ) potential_evt_to_add[i][1] | MASK_TOT_CYC;
698 EventSet = add_test_events( num_events, mask, 0 );
699 if ( *num_events == 2 ) break;
700 }
701 }
702 }
703
704 return EventSet;
705}
Query if PAPI event exists.
#define PAPI_FP_INS
Definition: f90papi.h:366
#define PAPI_FP_OPS
Definition: f90papi.h:319
#define MASK_FP_OPS
Definition: papi_test.h:24
#define MASK_FP_INS
Definition: papi_test.h:38
#define MASK_TOT_CYC
Definition: papi_test.h:40
#define MASK_TOT_INS
Definition: papi_test.h:39
int
Definition: sde_internal.h:89
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:152
#define POTENTIAL_EVENTS
Here is the call graph for this function:
Here is the caller graph for this function:

◆ allocate_test_space()

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 long long values[NUM_EVENTS]
Definition: init_fini.c:10
long long int long long
Definition: sde_internal.h:85
int num_tests
Definition: zero_fork.c:53
Here is the caller graph for this function:

◆ approx_equals()

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}
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:39
#define TOLERANCE
Definition: test_utils.c:9
Here is the caller graph for this function:

◆ enum_add_native_events()

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

Definition at line 709 of file test_utils.c.

712{
713 /* query and set up the right event to monitor */
714
715 int EventSet = PAPI_NULL;
716 int i = 0, k, event_code, retval;
717 int counters, event_found = 0;
719 const PAPI_component_info_t *s = NULL;
720 const PAPI_hw_info_t *hw_info = NULL;
721
722 *num_events=0;
723
725 if ( s == NULL ) {
726 test_fail( __FILE__, __LINE__,
727 "PAPI_get_component_info", PAPI_ECMP );
728 }
729
731 if ( hw_info == NULL ) {
732 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
733 }
734
735 counters = PAPI_num_hwctrs( );
736 if (counters<1) {
737 if (!TESTS_QUIET) printf("No counters available\n");
738 return EventSet;
739 }
740
741 if (!TESTS_QUIET) {
742 printf("Trying to fill %d hardware counters...\n", counters);
743 }
744
745 if (need_interrupt) {
746 if ( (!strcmp(hw_info->model_string,"POWER6")) ||
747 (!strcmp(hw_info->model_string,"POWER5")) ) {
748
749 test_warn(__FILE__, __LINE__,
750 "Limiting num_counters because of "
751 "LIMITED_PMC on Power5 and Power6",1);
752 counters=4;
753 }
754 }
755
756 ( *evtcodes ) = ( int * ) calloc( counters, sizeof ( int ) );
757
759 if ( retval != PAPI_OK ) {
760 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
761 }
762
763 /* For platform independence, always ASK FOR the first event */
764 /* Don't just assume it'll be the first numeric value */
765 i = 0 | PAPI_NATIVE_MASK;
767 if ( retval != PAPI_OK ) {
768 test_fail( __FILE__, __LINE__, "PAPI_enum_cmp_event", retval );
769 }
770
771 do {
772 retval = PAPI_get_event_info( i, &info );
773
774 /* HACK! FIXME */
775 if (no_software_events && ( strstr(info.symbol,"PERF_COUNT_SW") || strstr(info.long_descr, "PERF_COUNT_SW") ) ) {
776 if (!TESTS_QUIET) {
777 printf("Blocking event %s as a SW event\n", info.symbol);
778 }
779 continue;
780 }
781
782 if ( s->cntr_umasks ) {
783 k = i;
784
786 do {
787 retval = PAPI_get_event_info( k, &info );
788 event_code = ( int ) info.event_code;
789
790 retval = PAPI_add_event( EventSet, event_code );
791 if ( retval == PAPI_OK ) {
792 ( *evtcodes )[event_found] = event_code;
793 if ( !TESTS_QUIET ) {
794 printf( "event_code[%d] = %#x (%s)\n",
795 event_found, event_code, info.symbol );
796 }
797 event_found++;
798 } else {
799 if ( !TESTS_QUIET ) {
800 printf( "%#x (%s) can't be added to the EventSet.\n",
801 event_code, info.symbol );
802 }
803 }
805 && event_found < counters );
806 } else {
807 event_code = ( int ) info.event_code;
808 retval = PAPI_add_event( EventSet, event_code );
809 if ( retval == PAPI_OK ) {
810 ( *evtcodes )[event_found] = event_code;
811 if ( !TESTS_QUIET ) {
812 printf( "event_code[%d] = %#x (%s)\n",
813 event_found, event_code, info.symbol );
814 }
815 event_found++;
816 }
817 }
818 if ( !TESTS_QUIET && retval == PAPI_OK ) {
819 /* */
820 }
821 } else {
822 event_code = ( int ) info.event_code;
823 retval = PAPI_add_event( EventSet, event_code );
824 if ( retval == PAPI_OK ) {
825 ( *evtcodes )[event_found] = event_code;
826 event_found++;
827 } else {
828 if ( !TESTS_QUIET )
829 fprintf( stdout, "%#x is not available.\n", event_code );
830 }
831 }
832 }
834 event_found < counters );
835
836 *num_events = ( int ) event_found;
837
838 if (!TESTS_QUIET) printf("Tried to fill %d counters with events, "
839 "found %d\n",counters,event_found);
840
841 return EventSet;
842}
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:28
double s
Definition: byte_profile.c:36
Enumerate PAPI preset or native events for a given component.
get information about a specific software component
Get the event's name and description info.
get information about the system hardware
Return the number of hardware counters on the cpu.
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_NTV_ENUM_UMASKS
Definition: f90papi.h:66
#define PAPI_ECMP
Definition: f90papi.h:214
#define PAPI_NATIVE_MASK
static int cidx
unsigned int event_code
Definition: papi.h:958
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
Hardware info structure.
Definition: papi.h:774
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:784
void test_warn(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:547
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_nonderived_event()

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 */
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:981
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:989
Here is the caller graph for this function:

◆ free_test_space()

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}
Here is the caller graph for this function:

◆ get_overflow_address()

void * get_overflow_address ( void *  context)

◆ remove_test_events()

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 ) {
207 if ( retval < PAPI_OK )
208 return ( retval );
209 }
210
211 if ( mask & MASK_L1_DCW ) {
213 if ( retval < PAPI_OK )
214 return ( retval );
215 }
216
217 if ( mask & MASK_L1_DCR ) {
219 if ( retval < PAPI_OK )
220 return ( retval );
221 }
222
223 if ( mask & MASK_L2_TCH ) {
225 if ( retval < PAPI_OK )
226 return ( retval );
227 }
228
229 if ( mask & MASK_L2_TCA ) {
231 if ( retval < PAPI_OK )
232 return ( retval );
233 }
234
235 if ( mask & MASK_L2_TCM ) {
237 if ( retval < PAPI_OK )
238 return ( retval );
239 }
240
241 if ( mask & MASK_L1_DCM ) {
243 if ( retval < PAPI_OK )
244 return ( retval );
245 }
246
247 if ( mask & MASK_L1_ICM ) {
249 if ( retval < PAPI_OK )
250 return ( retval );
251 }
252
253 if ( mask & MASK_L1_TCM ) {
255 if ( retval < PAPI_OK )
256 return ( retval );
257 }
258
259 if ( mask & MASK_FP_OPS ) {
261 if ( retval < PAPI_OK )
262 return ( retval );
263 }
264
265 if ( mask & MASK_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}
Empty and destroy an EventSet.
removes a hardware event from a PAPI event set.
#define PAPI_L1_DCA
Definition: f90papi.h:367
#define PAPI_L2_TCH
Definition: f90papi.h:291
#define PAPI_TOT_CYC
Definition: f90papi.h:308
#define PAPI_L1_DCM
Definition: f90papi.h:364
#define PAPI_L2_TCM
Definition: f90papi.h:320
#define PAPI_L1_DCW
Definition: f90papi.h:372
#define PAPI_L1_DCR
Definition: f90papi.h:298
#define PAPI_TOT_IIS
Definition: f90papi.h:379
#define PAPI_L1_ICM
Definition: f90papi.h:392
#define PAPI_L2_TCA
Definition: f90papi.h:318
#define PAPI_L1_TCM
Definition: f90papi.h:347
#define MASK_L2_TCA
Definition: papi_test.h:33
#define MASK_L1_TCM
Definition: papi_test.h:37
#define MASK_L1_DCA
Definition: papi_test.h:25
#define MASK_L2_TCM
Definition: papi_test.h:34
#define MASK_TOT_IIS
Definition: papi_test.h:28
#define MASK_L1_DCM
Definition: papi_test.h:35
#define MASK_L1_DCR
Definition: papi_test.h:27
#define MASK_L1_DCW
Definition: papi_test.h:26
#define MASK_L2_TCH
Definition: papi_test.h:32
#define MASK_L1_ICM
Definition: papi_test.h:36
Here is the caller graph for this function:

◆ stringify_all_domains()

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}
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
Definition: do_loops.c:12
#define PAPI_DOM_MAX
Definition: f90papi.h:196
#define PAPI_DOM_MIN
Definition: f90papi.h:88
#define PAPI_HUGE_STR_LEN
Definition: f90papi.h:120
char * stringify_domain(int domain)
Definition: test_utils.c:312
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stringify_all_granularities()

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}
#define PAPI_GRN_MIN
Definition: f90papi.h:111
#define PAPI_GRN_MAX
Definition: f90papi.h:238
char * stringify_granularity(int granularity)
Definition: test_utils.c:353
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stringify_domain()

char * stringify_domain ( int  domain)

Definition at line 312 of file test_utils.c.

313{
314 switch ( domain ) {
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_USER
Definition: f90papi.h:174
#define PAPI_DOM_OTHER
Definition: f90papi.h:21
#define PAPI_DOM_KERNEL
Definition: f90papi.h:254
#define PAPI_DOM_SUPERVISOR
Definition: f90papi.h:109
#define PAPI_DOM_ALL
Definition: f90papi.h:261
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stringify_granularity()

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_PROCG
Definition: f90papi.h:202
#define PAPI_GRN_SYS
Definition: f90papi.h:43
#define PAPI_GRN_SYS_CPU
Definition: f90papi.h:100
#define PAPI_GRN_PROC
Definition: f90papi.h:266
#define PAPI_GRN_THR
Definition: f90papi.h:265
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_fail()

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

Definition at line 491 of file test_utils.c.

492{
493// int line_pad;
494 char buf[128];
495
496 (void)file;
497
498// line_pad=(60-strlen(file));
499// if (line_pad<0) line_pad=0;
500
501// fprintf(stdout,"%s",file);
502// print_spaces(line_pad);
503
504 memset( buf, '\0', sizeof ( buf ) );
505
506 if (TESTS_COLOR) fprintf(stdout,"%s",RED);
507 fprintf( stdout, "FAILED!!!");
508 if (TESTS_COLOR) fprintf(stdout,"%s",NORMAL);
509 fprintf( stdout, "\nLine # %d ", line );
510
511 if ( retval == PAPI_ESYS ) {
512 sprintf( buf, "System error in %s", call );
513 perror( buf );
514 } else if ( retval > 0 ) {
515 fprintf( stdout, "Error: %s\n", call );
516 } else if ( retval == 0 ) {
517#if defined(sgi)
518 fprintf( stdout, "SGI requires root permissions for this test\n" );
519#else
520 fprintf( stdout, "Error: %s\n", call );
521#endif
522 } else {
523 fprintf( stdout, "Error in %s: %s\n", call, PAPI_strerror( retval ) );
524 }
525
526 fprintf(stdout, "Some tests require special hardware, permissions, OS, compilers\n"
527 "or library versions. PAPI may still function perfectly on your \n"
528 "system without the particular feature being tested here. \n");
529
530 /* NOTE: Because test_fail is called from thread functions,
531 calling PAPI_shutdown here could prevent some threads
532 from being able to free memory they have allocated.
533 */
534 if ( PAPI_is_initialized( ) ) {
535 PAPI_shutdown( );
536 }
537
538 /* This is stupid. Threads are the rare case */
539 /* and in any case an exit() should clear everything out */
540 /* adding back the exit() call */
541
542 exit(1);
543}
check for initialization
Finish using PAPI and free all related resources.
Returns a string describing the PAPI error code.
#define PAPI_ESYS
Definition: f90papi.h:136
const char FILE * file
Definition: pscanf.h:13
#define NORMAL
Definition: test_utils.c:415
#define RED
Definition: test_utils.c:412
static int TESTS_COLOR
Definition: test_utils.c:19

◆ test_hl_pass()

void PAPI_NORETURN test_hl_pass ( const char *  filename)

Definition at line 467 of file test_utils.c.

468{
469 (void)filename;
470
471 if ( TEST_WARN ) {
472 print_spaces(59);
473 if (TESTS_COLOR) fprintf( stdout, "%s", YELLOW);
474 fprintf( stdout, "PASSED with WARNING");
475 if (TESTS_COLOR) fprintf( stdout, "%s", NORMAL);
476 fprintf( stdout, "\n");
477 }
478 else {
479 if (TESTS_COLOR) fprintf( stdout, "%s",GREEN);
480 fprintf( stdout, "PASSED");
481 if (TESTS_COLOR) fprintf( stdout, "%s",NORMAL);
482 fprintf( stdout, "\n");
483 }
484
485 exit( 0 );
486
487}
static int TEST_WARN
Definition: test_utils.c:20
static void print_spaces(int count)
Definition: test_utils.c:418
#define YELLOW
Definition: test_utils.c:413
#define GREEN
Definition: test_utils.c:414
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_pass()

void PAPI_NORETURN 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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_print_event_header()

void test_print_event_header ( const char *  call,
int  evset 
)

Definition at line 605 of file test_utils.c.

606{
607 int *ev_ids;
608 int i, nev;
609 int retval;
610 char evname[PAPI_MAX_STR_LEN];
611
612 if ( *call )
613 fprintf( stdout, "%s", call );
614
615 if ((nev = PAPI_get_cmp_opt(PAPI_MAX_MPX_CTRS,NULL,0)) <= 0) {
616 fprintf( stdout, "Can not list event names.\n" );
617 return;
618 }
619
620 if ((ev_ids = calloc(nev,sizeof(int))) == NULL) {
621 fprintf( stdout, "Can not list event names.\n" );
622 return;
623 }
624
625 retval = PAPI_list_events( evset, ev_ids, &nev );
626
627 if ( retval == PAPI_OK ) {
628 for ( i = 0; i < nev; i++ ) {
629 PAPI_event_code_to_name( ev_ids[i], evname );
630 printf( ONEHDR, evname );
631 }
632 } else {
633 fprintf( stdout, "Can not list event names." );
634 }
635 fprintf( stdout, "\n" );
636 free(ev_ids);
637}
Get component specific PAPI options.
list the events in an event set
#define PAPI_MAX_MPX_CTRS
Definition: f90papi.h:172
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define ONEHDR
Definition: papi_test.h:93
Here is the caller graph for this function:

◆ test_skip()

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

Definition at line 584 of file test_utils.c.

585{
586// int line_pad;
587
588 (void)file;
589 (void)line;
590 (void)call;
591 (void)retval;
592
593// line_pad=(60-strlen(file));
594
595// fprintf(stdout,"%s",file);
596// print_spaces(line_pad);
597
598 fprintf( stdout, "SKIPPED\n");
599
600 exit( 0 );
601}
Here is the caller graph for this function:

◆ test_warn()

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

Definition at line 547 of file test_utils.c.

548{
549
550 (void)file;
551
552// int line_pad;
553
554// line_pad=60-strlen(file);
555// if (line_pad<0) line_pad=0;
556
557 char buf[128];
558 memset( buf, '\0', sizeof ( buf ) );
559
560// fprintf(stdout,"%s",file);
561// print_spaces(line_pad);
562
563 if (TEST_WARN==0) fprintf(stdout,"\n");
564 if (TESTS_COLOR) fprintf( stdout, "%s", YELLOW);
565 fprintf( stdout, "WARNING ");
566 if (TESTS_COLOR) fprintf( stdout, "%s", NORMAL);
567 fprintf( stdout, "Line # %d ", line );
568
569 if ( retval == PAPI_ESYS ) {
570 sprintf( buf, "System warning in %s", call );
571 perror( buf );
572 } else if ( retval > 0 ) {
573 fprintf( stdout, "Warning: %s\n", call );
574 } else if ( retval == 0 ) {
575 fprintf( stdout, "Warning: %s\n", call );
576 } else {
577 fprintf( stdout, "Warning in %s: %s\n", call, PAPI_strerror( retval ));
578 }
579
580 TEST_WARN++;
581}
Here is the caller graph for this function:

◆ tests_quiet()

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 */
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}
Set the current debug level for error output from PAPI.
#define PAPI_VERB_ECONT
Definition: f90papi.h:164
Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_string()

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}
double s2
Definition: byte_profile.c:36
const char * name
Definition: rocs.c:225
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ test_events

struct test_events_t test_events[]
extern

Definition at line 130 of file test_utils.c.

◆ TESTS_QUIET

int TESTS_QUIET
extern

Definition at line 18 of file test_utils.c.