PAPI 7.1.0.0
Loading...
Searching...
No Matches
overflow_index.c File Reference
Include dependency graph for overflow_index.c:

Go to the source code of this file.

Data Structures

struct  ocount_t
 

Macros

#define OVER_FMT   "handler(%d) Overflow at %p! vector=%#llx\n"
 
#define OUT_FMT   "%-12s : %16lld%16lld\n"
 
#define INDEX_FMT   "Overflows vector %#llx: \n"
 

Functions

static void handler (int EventSet, void *address, long long overflow_vector, void *context)
 
int main (int argc, char **argv)
 

Variables

static ocount_t overflow_counts [3] = { {0, 0}, {0, 0}, {0, 0} }
 
static int total_unknown = 0
 

Macro Definition Documentation

◆ INDEX_FMT

#define INDEX_FMT   "Overflows vector %#llx: \n"

Definition at line 19 of file overflow_index.c.

◆ OUT_FMT

#define OUT_FMT   "%-12s : %16lld%16lld\n"

Definition at line 18 of file overflow_index.c.

◆ OVER_FMT

#define OVER_FMT   "handler(%d) Overflow at %p! vector=%#llx\n"

Definition at line 17 of file overflow_index.c.

Function Documentation

◆ handler()

static void handler ( int  EventSet,
void *  address,
long long  overflow_vector,
void *  context 
)
static

Definition at line 33 of file overflow_index.c.

34{
35 int i;
36
37 ( void ) context;
38
39 if ( !TESTS_QUIET ) {
40 fprintf( stderr, OVER_FMT, EventSet, address, overflow_vector );
41 }
42
43 /* Look for the overflow_vector entry */
44
45 for ( i = 0; i < 3; i++ ) {
46 if ( overflow_counts[i].mask == overflow_vector ) {
48 return;
49 }
50 }
51
52 /* Didn't find it so add it. */
53
54 for ( i = 0; i < 3; i++ ) {
55 if ( overflow_counts[i].mask == ( long long ) 0 ) {
56 overflow_counts[i].mask = overflow_vector;
58 return;
59 }
60 }
61
62 /* Unknown entry!?! */
63
65}
int i
static int EventSet
Definition: init_fini.c:8
int TESTS_QUIET
Definition: test_utils.c:18
#define OVER_FMT
static int total_unknown
static ocount_t overflow_counts[3]
FILE * stderr
long long mask
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file overflow_index.c.

69{
70 int EventSet = PAPI_NULL;
71 long long ( values[3] )[2];
72 int retval;
73 int PAPI_event, k, i;
75 int index_array[2], number;
76 int num_events1, mask1;
77 int quiet;
78
79 /* Set TESTS_QUIET variable */
80 quiet = tests_quiet( argc, argv );
81
83 if ( retval != PAPI_VER_CURRENT ) {
84 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
85 }
86
87 /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or
88 PAPI_TOT_INS, depends on the availability of the event on the
89 platform */
91
92 if (num_events1==0) {
93 if (!quiet) printf("Trouble adding events\n");
94 test_skip(__FILE__,__LINE__,"Adding events",0);
95 }
96
98 if ( retval != PAPI_OK )
99 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
100
102
104 if ( retval != PAPI_OK )
105 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
106
108 if ( retval != PAPI_OK )
109 test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
111 if ( retval != PAPI_OK )
112 test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
113
115 if ( retval != PAPI_OK )
116 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
117
119
121 if ( retval != PAPI_OK )
122 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
123
125 if (retval != PAPI_OK ) {
126 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
127 }
128
129 if (!quiet) {
130 printf( "Test case: Overflow dispatch of 2nd event in set with 2 events.\n" );
131 printf( "---------------------------------------------------------------\n" );
132 printf( "Threshold for overflow is: %d\n", THRESHOLD );
133 printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
134 printf( "-----------------------------------------------\n" );
135
136 printf( "Test type : %16d%16d\n", 1, 2 );
137 printf( OUT_FMT, "PAPI_TOT_CYC", ( values[0] )[0], ( values[1] )[0] );
138 printf( OUT_FMT, event_name, ( values[0] )[1], ( values[1] )[1] );
139 }
140
141 if ( overflow_counts[0].count == 0 && overflow_counts[1].count == 0 ) {
142 test_fail( __FILE__, __LINE__,
143 "one counter had no overflows", 1 );
144 }
145
146 for ( k = 0; k < 3; k++ ) {
147 if ( overflow_counts[k].mask ) {
148 number = 2;
150 overflow_counts[k].mask,
151 index_array, &number );
152 if ( retval != PAPI_OK ) {
153 test_fail( __FILE__, __LINE__,
154 "PAPI_get_overflow_event_index", retval );
155 }
156 if (!quiet) {
157 printf( INDEX_FMT, ( long long ) overflow_counts[k].mask );
158 printf( " counts: %d ", overflow_counts[k].count );
159 for ( i = 0; i < number; i++ )
160 printf( " Event Index %d ", index_array[i] );
161 printf( "\n" );
162 }
163 }
164 }
165
166 if (!quiet) {
167 printf( "Case 2 %s Overflows: %d\n", "Unknown", total_unknown );
168 printf( "-----------------------------------------------\n" );
169 }
170
171 if ( total_unknown > 0 ) {
172 test_fail( __FILE__, __LINE__, "Unknown counter had overflows", 1 );
173 }
174
176 if ( retval != PAPI_OK ) {
177 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
178 }
179
180 test_pass( __FILE__ );
181
182 return 0;
183}
static long count
Empty and destroy an EventSet.
Convert a numeric hardware event code to a name.
converts an overflow vector into an array of indexes to overflowing events
initialize the PAPI library.
Set up an event set to begin registering overflows.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
int PAPI_event[2]
Definition: data_range.c:30
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define THRESHOLD
Definition: earprofile.c:37
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_TOT_CYC
Definition: f90papi.h:308
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void do_flops(int n)
Definition: multiplex.c:23
static void handler(int EventSet, void *address, long long overflow_vector, void *context)
#define INDEX_FMT
#define OUT_FMT
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:671
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int quiet
Definition: rapl_overflow.c:19
long long int long long
Definition: sde_internal.h:85
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
int num_events1
Definition: zero_fork.c:49
int mask1
Definition: zero_fork.c:48
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

Variable Documentation

◆ overflow_counts

ocount_t overflow_counts[3] = { {0, 0}, {0, 0}, {0, 0} }
static

Definition at line 29 of file overflow_index.c.

◆ total_unknown

int total_unknown = 0
static

Definition at line 30 of file overflow_index.c.