PAPI 7.1.0.0
Loading...
Searching...
No Matches
overflow_twoevents.c File Reference
Include dependency graph for overflow_twoevents.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 : %18lld%18lld%18lld\n"
 
#define VEC_FMT   " at vector %#llx, event %-12s : %6d\n"
 

Functions

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

Variables

static ocount_t overflow_counts [2][3]
 
static int total_unknown = 0
 

Macro Definition Documentation

◆ OUT_FMT

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

Definition at line 21 of file overflow_twoevents.c.

◆ OVER_FMT

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

Definition at line 20 of file overflow_twoevents.c.

◆ VEC_FMT

#define VEC_FMT   " at vector %#llx, event %-12s : %6d\n"

Definition at line 22 of file overflow_twoevents.c.

Function Documentation

◆ handler()

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

Definition at line 38 of file overflow_twoevents.c.

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

◆ handler_batch()

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

Definition at line 72 of file overflow_twoevents.c.

74{
75 ( void ) EventSet; /*unused */
76 handler( 0, address, overflow_vector, context );
77}
static int EventSet
Definition: init_fini.c:8
static void handler(int mode, void *address, long long overflow_vector, void *context)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handler_interleaf()

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

Definition at line 80 of file overflow_twoevents.c.

82{
83 ( void ) EventSet; /*unused */
84 handler( 1, address, overflow_vector, context );
85}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 89 of file overflow_twoevents.c.

90{
91 int EventSet = PAPI_NULL;
92 long long ( values[3] )[2];
93 int retval;
94 int PAPI_event, k, idx[4];
96 int num_events1;
97 int threshold = THRESHOLD;
98 int quiet;
99
100 /* Set TESTS_QUIET variable */
101 quiet=tests_quiet( argc, argv );
102
104 if (retval != PAPI_VER_CURRENT ) {
105 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
106 }
107
109 if (retval != PAPI_OK ) {
110 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
111 }
112
113 /* decide which of PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS to add,
114 depending on the availability and derived status of the event on
115 this platform */
116 if ( ( PAPI_event = find_nonderived_event( ) ) == 0 ) {
117 if (!quiet) printf("No events found!\n");
118 test_skip( __FILE__, __LINE__, "no PAPI_event", 0 );
119 }
120
122 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
124 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
125
127 if ( retval != PAPI_OK )
128 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
129
131
132 if ( ( retval = PAPI_stop( EventSet, values[0] ) ) != PAPI_OK )
133 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
134
135 /* Set both overflows after adding both events (batch) */
138 if (retval != PAPI_OK ) {
139 test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
140 }
141
144 if (retval != PAPI_OK ) {
145 test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
146 }
147
148 if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
149 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
150
152
154 if ( retval != PAPI_OK )
155 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
156
157 num_events1 = 1;
158 retval =
160 if ( retval != PAPI_OK ) {
161 printf( "PAPI_get_overflow_event_index error: %s\n",
163 }
164
165 num_events1 = 1;
166 retval =
168 if ( retval != PAPI_OK ) {
169 printf( "PAPI_get_overflow_event_index error: %s\n",
171 }
172
174 test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
175
176 /* Add each event and set its overflow (interleaved) */
178 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
179 if ( ( retval =
182 test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
184 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
185 if ( ( retval =
188 test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
189
190 if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
191 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
192
194
195 if ( ( retval = PAPI_stop( EventSet, values[2] ) ) != PAPI_OK )
196 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
197
198 num_events1 = 1;
199 retval =
201 if ( retval != PAPI_OK ) {
202 printf( "PAPI_get_overflow_event_index error: %s\n",
204 }
205
206 num_events1 = 1;
208 &num_events1 );
209 if ( retval != PAPI_OK ) {
210 printf( "PAPI_get_overflow_event_index error: %s\n",
212 }
213
215 test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
216
218 if (retval != PAPI_OK ) {
219 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
220 }
221
223 if (retval != PAPI_OK ) {
224 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
225 }
226
227 strcpy( event_name[2], "Unknown" );
228
229 if (!TESTS_QUIET) {
230 printf( "Test case: Overflow dispatch of both events in set with 2 events.\n" );
231 printf( "---------------------------------------------------------------\n" );
232 printf( "Threshold for overflow is: %d\n", threshold );
233 printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
234 printf( "-----------------------------------------------\n" );
235
236 printf( "Test type : %18s%18s%18s\n", "1 (no overflow)", "2 (batch)",
237 "3 (interleaf)" );
238 printf( OUT_FMT, event_name[0], ( values[0] )[0], ( values[1] )[0],
239 ( values[2] )[0] );
240 printf( OUT_FMT, event_name[1], ( values[0] )[1], ( values[1] )[1],
241 ( values[2] )[1] );
242 printf( "\n" );
243
244 printf( "Predicted overflows at event %-12s : %6d\n", event_name[0],
245 ( int ) ( ( values[0] )[0] / threshold ) );
246 printf( "Predicted overflows at event %-12s : %6d\n", event_name[1],
247 ( int ) ( ( values[0] )[1] / threshold ) );
248
249 printf( "\nBatch overflows (add, add, over, over):\n" );
250 for ( k = 0; k < 2; k++ ) {
251 if ( overflow_counts[0][k].mask ) {
252 printf( VEC_FMT, ( long long ) overflow_counts[0][k].mask,
253 event_name[idx[k]], overflow_counts[0][k].count );
254 }
255 }
256
257 printf( "\nInterleaved overflows (add, over, add, over):\n" );
258 for ( k = 0; k < 2; k++ ) {
259 if ( overflow_counts[1][k].mask )
260 printf( VEC_FMT,
261 ( long long ) overflow_counts[1][k].mask,
262 event_name[idx[k + 2]],
263 overflow_counts[1][k].count );
264 }
265
266 printf( "\nCases 2+3 Unknown overflows: %d\n", total_unknown );
267 printf( "-----------------------------------------------\n" );
268 }
269
270 if ( overflow_counts[0][0].count == 0 || overflow_counts[0][1].count == 0 )
271 test_fail( __FILE__, __LINE__, "a batch counter had no overflows", 1 );
272
273 if ( overflow_counts[1][0].count == 0 || overflow_counts[1][1].count == 0 )
274 test_fail( __FILE__, __LINE__,
275 "an interleaved counter had no overflows", 1 );
276
277 if ( total_unknown > 0 )
278 test_fail( __FILE__, __LINE__, "Unknown counter had overflows", 1 );
279
280 test_pass( __FILE__ );
281
282 return 0;
283}
static long count
add PAPI preset or native hardware event to an event set
Empty and destroy an EventSet.
Create a new empty PAPI 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.
Returns a string describing the PAPI error code.
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
static int threshold
void do_flops(int n)
Definition: multiplex.c:23
#define VEC_FMT
#define OUT_FMT
static void handler_interleaf(int EventSet, void *address, long long overflow_vector, void *context)
static void handler_batch(int EventSet, void *address, long long overflow_vector, void *context)
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
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
int find_nonderived_event(void)
Definition: test_utils.c:98
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 retval
Definition: zero_fork.c:53
Here is the call graph for this function:

Variable Documentation

◆ overflow_counts

ocount_t overflow_counts[2][3]
static
Initial value:
=
{ {{0, 0}, {0, 0}, {0, 0}}, {{0, 0}, {0, 0}, {0, 0}} }

Definition at line 33 of file overflow_twoevents.c.

◆ total_unknown

int total_unknown = 0
static

Definition at line 35 of file overflow_twoevents.c.