PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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

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

Variables

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

Macro Definition Documentation

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

Definition at line 15 of file overflow_twoevents.c.

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

Definition at line 14 of file overflow_twoevents.c.

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

Definition at line 16 of file overflow_twoevents.c.

Function Documentation

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

Definition at line 32 of file overflow_twoevents.c.

33 {
34  ( void ) context; /*unused */
35  int i;
36 
37  if ( !TESTS_QUIET ) {
38  fprintf( stderr, OVER_FMT, mode, address, overflow_vector );
39  }
40 
41  /* Look for the overflow_vector entry */
42 
43  for ( i = 0; i < 3; i++ ) {
44  if ( overflow_counts[mode][i].mask == overflow_vector ) {
45  overflow_counts[mode][i].count++;
46  return;
47  }
48  }
49 
50  /* Didn't find it so add it. */
51 
52  for ( i = 0; i < 3; i++ ) {
53  if ( overflow_counts[mode][i].mask == ( long long ) 0 ) {
54  overflow_counts[mode][i].mask = overflow_vector;
55  overflow_counts[mode][i].count = 1;
56  return;
57  }
58  }
59 
60  /* Unknown entry!?! */
61 
62  total_unknown++;
63 }
void
Definition: iozone.c:18627
#define OVER_FMT
int TESTS_QUIET
Definition: test_utils.c:11
int i
Definition: fileop.c:140
long long mask
int total_unknown
ocount_t overflow_counts[3]
void handler_batch ( int  EventSet,
void address,
long long  overflow_vector,
void context 
)

Definition at line 66 of file overflow_twoevents.c.

68 {
69  ( void ) EventSet; /*unused */
70  handler( 0, address, overflow_vector, context );
71 }
void
Definition: iozone.c:18627
void handler(int EventSet, void *address, long long overflow_vector, void *context)
Definition: rapl_overflow.c:16
int EventSet

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 74 of file overflow_twoevents.c.

76 {
77  ( void ) EventSet; /*unused */
78  handler( 1, address, overflow_vector, context );
79 }
void
Definition: iozone.c:18627
void handler(int EventSet, void *address, long long overflow_vector, void *context)
Definition: rapl_overflow.c:16
int EventSet

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 83 of file overflow_twoevents.c.

84 {
85  int EventSet = PAPI_NULL;
86  long long ( values[3] )[2];
87  int retval;
88  int PAPI_event, k, idx[4];
90  int num_events1;
91  int threshold = THRESHOLD;
92 
93  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
94 
95  if ( ( retval =
97  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
98 
99  if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
100  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
101 
102  /* decide which of PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS to add,
103  depending on the availability and derived status of the event on
104  this platform */
105  if ( ( PAPI_event = find_nonderived_event( ) ) == 0 )
106  test_fail( __FILE__, __LINE__, "no PAPI_event", 0 );
107 
108  if ( ( retval = PAPI_add_event( EventSet, PAPI_event ) ) != PAPI_OK )
109  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
110  if ( ( retval = PAPI_add_event( EventSet, PAPI_TOT_CYC ) ) != PAPI_OK )
111  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
112 
113  retval = PAPI_start( EventSet );
114  if ( retval != PAPI_OK )
115  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
116 
117  do_flops( NUM_FLOPS );
118 
119  if ( ( retval = PAPI_stop( EventSet, values[0] ) ) != PAPI_OK )
120  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
121 
122  /* Set both overflows after adding both events (batch) */
123  if ( ( retval =
124  PAPI_overflow( EventSet, PAPI_event, threshold, 0,
125  handler_batch ) ) != PAPI_OK )
126  test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
127  if ( ( retval =
128  PAPI_overflow( EventSet, PAPI_TOT_CYC, threshold, 0,
129  handler_batch ) ) != PAPI_OK )
130  test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
131 
132  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
133  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
134 
135  do_flops( NUM_FLOPS );
136 
137  retval = PAPI_stop( EventSet, values[1] );
138  if ( retval != PAPI_OK )
139  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
140 
141  num_events1 = 1;
142  retval =
143  PAPI_get_overflow_event_index( EventSet, 1, &idx[0], &num_events1 );
144  if ( retval != PAPI_OK )
145  printf( "PAPI_get_overflow_event_index error: %s\n",
146  PAPI_strerror( retval ) );
147 
148  num_events1 = 1;
149  retval =
150  PAPI_get_overflow_event_index( EventSet, 2, &idx[1], &num_events1 );
151  if ( retval != PAPI_OK )
152  printf( "PAPI_get_overflow_event_index error: %s\n",
153  PAPI_strerror( retval ) );
154 
155  if ( ( retval = PAPI_cleanup_eventset( EventSet ) ) != PAPI_OK )
156  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
157 
158  /* Add each event and set its overflow (interleaved) */
159  if ( ( retval = PAPI_add_event( EventSet, PAPI_event ) ) != PAPI_OK )
160  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
161  if ( ( retval =
162  PAPI_overflow( EventSet, PAPI_event, threshold, 0,
163  handler_interleaf ) ) != PAPI_OK )
164  test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
165  if ( ( retval = PAPI_add_event( EventSet, PAPI_TOT_CYC ) ) != PAPI_OK )
166  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
167  if ( ( retval =
168  PAPI_overflow( EventSet, PAPI_TOT_CYC, threshold, 0,
169  handler_interleaf ) ) != PAPI_OK )
170  test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
171 
172  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
173  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
174 
175  do_flops( NUM_FLOPS );
176 
177  if ( ( retval = PAPI_stop( EventSet, values[2] ) ) != PAPI_OK )
178  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
179 
180  num_events1 = 1;
181  retval =
182  PAPI_get_overflow_event_index( EventSet, 1, &idx[2], &num_events1 );
183  if ( retval != PAPI_OK )
184  printf( "PAPI_get_overflow_event_index error: %s\n",
185  PAPI_strerror( retval ) );
186 
187  num_events1 = 1;
188  retval =
189  PAPI_get_overflow_event_index( EventSet, 2, &idx[3], &num_events1 );
190  if ( retval != PAPI_OK )
191  printf( "PAPI_get_overflow_event_index error: %s\n",
192  PAPI_strerror( retval ) );
193 
194  if ( ( retval = PAPI_cleanup_eventset( EventSet ) ) != PAPI_OK )
195  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
196 
197  if ( ( retval =
198  PAPI_event_code_to_name( PAPI_event, event_name[0] ) ) != PAPI_OK )
199  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
200 
201  if ( ( retval =
202  PAPI_event_code_to_name( PAPI_TOT_CYC, event_name[1] ) ) != PAPI_OK )
203  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
204 
205  strcpy( event_name[2], "Unknown" );
206 
207  printf
208  ( "Test case: Overflow dispatch of both events in set with 2 events.\n" );
209  printf
210  ( "---------------------------------------------------------------\n" );
211  printf( "Threshold for overflow is: %d\n", threshold );
212  printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
213  printf( "-----------------------------------------------\n" );
214 
215  printf( "Test type : %18s%18s%18s\n", "1 (no overflow)", "2 (batch)",
216  "3 (interleaf)" );
217  printf( OUT_FMT, event_name[0], ( values[0] )[0], ( values[1] )[0],
218  ( values[2] )[0] );
219  printf( OUT_FMT, event_name[1], ( values[0] )[1], ( values[1] )[1],
220  ( values[2] )[1] );
221  printf( "\n" );
222 
223  printf( "Predicted overflows at event %-12s : %6d\n", event_name[0],
224  ( int ) ( ( values[0] )[0] / threshold ) );
225  printf( "Predicted overflows at event %-12s : %6d\n", event_name[1],
226  ( int ) ( ( values[0] )[1] / threshold ) );
227 
228  printf( "\nBatch overflows (add, add, over, over):\n" );
229  for ( k = 0; k < 2; k++ ) {
230  if ( overflow_counts[0][k].mask ) {
231  printf( VEC_FMT, ( long long ) overflow_counts[0][k].mask,
232  event_name[idx[k]], overflow_counts[0][k].count );
233  }
234  }
235 
236  printf( "\nInterleaved overflows (add, over, add, over):\n" );
237  for ( k = 0; k < 2; k++ ) {
238  if ( overflow_counts[1][k].mask )
239  printf( VEC_FMT,
240  ( long long ) overflow_counts[1][k].mask,
241  event_name[idx[k + 2]],
242  overflow_counts[1][k].count );
243  }
244 
245  printf( "\nCases 2+3 Unknown overflows: %d\n", total_unknown );
246  printf( "-----------------------------------------------\n" );
247 
248  if ( overflow_counts[0][0].count == 0 || overflow_counts[0][1].count == 0 )
249  test_fail( __FILE__, __LINE__, "a batch counter had no overflows", 1 );
250 
251  if ( overflow_counts[1][0].count == 0 || overflow_counts[1][1].count == 0 )
252  test_fail( __FILE__, __LINE__,
253  "an interleaved counter had no overflows", 1 );
254 
255  if ( total_unknown > 0 )
256  test_fail( __FILE__, __LINE__, "Unknown counter had overflows", 1 );
257 
258  test_pass( __FILE__, NULL, 0 );
259  exit( 1 );
260 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
#define NUM_FLOPS
void handler_batch(int EventSet, void *address, long long overflow_vector, void *context)
int PAPI_event[2]
Definition: data_range.c:24
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
int num_events1
Definition: zero_fork.c:42
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
tests_quiet(argc, argv)
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
Definition: papi.c:4668
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
#define VEC_FMT
#define PAPI_TOT_CYC
Definition: fpapi.h:194
void handler_interleaf(int EventSet, void *address, long long overflow_vector, void *context)
int k
Definition: iozone.c:19136
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
long long
Definition: iozone.c:19827
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
#define OUT_FMT
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
int threshold
strcpy(filename, default_filename)
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_get_overflow_event_index(int EventSet, long long overflow_vector, int *array, int *number)
Definition: papi.c:6391
int EventSet
int total_unknown
char * PAPI_strerror(int errorCode)
Definition: papi.c:4483
int find_nonderived_event(void)
Definition: test_utils.c:159
int PAPI_start(int EventSet)
Definition: papi.c:2026
#define THRESHOLD
Definition: earprofile.c:31
ocount_t overflow_counts[3]
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
void exit()

Here is the call graph for this function:

Variable Documentation

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

Definition at line 27 of file overflow_twoevents.c.

int total_unknown = 0

Definition at line 29 of file overflow_twoevents.c.