PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
second.c File Reference
Include dependency graph for second.c:

Go to the source code of this file.

Macros

#define TAB_DOM   "%s%12lld%15lld%17lld\n"
 
#define CASE2   0
 
#define CREATE   1
 
#define ADD   2
 
#define MIDDLE   3
 
#define CHANGE   4
 
#define SUPERVISOR   5
 

Functions

void dump_and_verify (int test_case, long long **values)
 
void case1 (int num)
 
void case2 (int num, int domain, long long *values)
 
void case2_driver (void)
 
void case1_driver (void)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

#define ADD   2

Definition at line 24 of file second.c.

#define CASE2   0

Definition at line 22 of file second.c.

#define CHANGE   4

Definition at line 26 of file second.c.

#define CREATE   1

Definition at line 23 of file second.c.

#define MIDDLE   3

Definition at line 25 of file second.c.

#define SUPERVISOR   5

Definition at line 27 of file second.c.

#define TAB_DOM   "%s%12lld%15lld%17lld\n"

Definition at line 20 of file second.c.

Function Documentation

void case1 ( int  num)

Definition at line 135 of file second.c.

136 {
137  int retval, num_tests = 3;
138  long long **values;
139  int EventSet1 = PAPI_NULL, EventSet2 = PAPI_NULL, EventSet3 = PAPI_NULL;
141  const PAPI_component_info_t *cmpinfo;
142 
143  memset( &options, 0x0, sizeof ( options ) );
144 
146  if ( retval != PAPI_VER_CURRENT )
147  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
148 
149  /* get info from cpu component */
150  cmpinfo = PAPI_get_component_info( 0 );
151  if ( cmpinfo == NULL ) {
152  test_fail( __FILE__, __LINE__,"PAPI_get_component_info", PAPI_ECMP);
153  }
154 
155  if ( ( retval = PAPI_query_event( PAPI_TOT_INS ) ) != PAPI_OK )
156  test_skip( __FILE__, __LINE__, "PAPI_query_event", retval );
157 
158  if ( ( retval = PAPI_query_event( PAPI_TOT_CYC ) ) != PAPI_OK )
159  test_skip( __FILE__, __LINE__, "PAPI_query_event", retval );
160 
161  retval = PAPI_create_eventset( &EventSet1 );
162  if ( retval == PAPI_OK )
163  retval = PAPI_create_eventset( &EventSet2 );
164  if ( retval == PAPI_OK )
165  retval = PAPI_create_eventset( &EventSet3 );
166  if ( retval != PAPI_OK )
167  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
168 
169  /* In Component PAPI, EventSets must be assigned a component index
170  before you can fiddle with their internals. 0 is always the cpu component */
171  retval = PAPI_assign_eventset_component( EventSet1, 0 );
172  if ( retval == PAPI_OK )
173  retval = PAPI_assign_eventset_component( EventSet2, 0 );
174  if ( retval == PAPI_OK )
175  retval = PAPI_assign_eventset_component( EventSet3, 0 );
176  if ( retval != PAPI_OK )
177  test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component",
178  retval );
179 
180  if ( num == CREATE ) {
181  printf
182  ( "\nTest case CREATE: Call PAPI_set_opt(PAPI_DOMAIN) on EventSet before add\n" );
183  options.domain.eventset = EventSet1;
184  options.domain.domain = PAPI_DOM_ALL;
185 
186  retval = PAPI_set_opt( PAPI_DOMAIN, &options );
187  if ( retval != PAPI_OK )
188  test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval );
189 
190  options.domain.eventset = EventSet2;
191  options.domain.domain = PAPI_DOM_KERNEL;
192 
193  retval = PAPI_set_opt( PAPI_DOMAIN, &options );
194  if ( retval != PAPI_OK )
195  test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval );
196 
197  options.domain.eventset = EventSet3;
198  options.domain.domain = PAPI_DOM_USER;
199 
200  retval = PAPI_set_opt( PAPI_DOMAIN, &options );
201  if ( retval != PAPI_OK )
202  test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval );
203  }
204 
205  retval = PAPI_add_event( EventSet1, PAPI_TOT_INS );
206  if ( retval != PAPI_OK )
207  test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_INS)", retval );
208 
209  retval = PAPI_add_event( EventSet1, PAPI_TOT_CYC );
210  if ( retval != PAPI_OK )
211  test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_CYC)", retval );
212 
213  retval = PAPI_add_event( EventSet2, PAPI_TOT_INS );
214  if ( retval != PAPI_OK )
215  test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_INS)", retval );
216 
217  retval = PAPI_add_event( EventSet2, PAPI_TOT_CYC );
218  if ( retval != PAPI_OK )
219  test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_CYC)", retval );
220 
221  retval = PAPI_add_event( EventSet3, PAPI_TOT_INS );
222  if ( retval != PAPI_OK )
223  test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_INS)", retval );
224 
225  if ( num == MIDDLE ) {
226  printf
227  ( "\nTest case MIDDLE: Call PAPI_set_opt(PAPI_DOMAIN) on EventSet between adds\n" );
228  options.domain.eventset = EventSet1;
229  options.domain.domain = PAPI_DOM_ALL;
230 
231  retval = PAPI_set_opt( PAPI_DOMAIN, &options );
232  if ( retval != PAPI_OK && retval != PAPI_ECMP ) {
233  test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval );
234  }
235 
236  options.domain.eventset = EventSet2;
237  options.domain.domain = PAPI_DOM_KERNEL;
238 
239  retval = PAPI_set_opt( PAPI_DOMAIN, &options );
240  if ( retval != PAPI_OK )
241  test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval );
242 
243  options.domain.eventset = EventSet3;
244  options.domain.domain = PAPI_DOM_USER;
245 
246  retval = PAPI_set_opt( PAPI_DOMAIN, &options );
247  if ( retval != PAPI_OK )
248  test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval );
249  }
250 
251  retval = PAPI_add_event( EventSet3, PAPI_TOT_CYC );
252  if ( retval != PAPI_OK )
253  test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_CYC)", retval );
254 
255  if ( num == ADD ) {
256  printf
257  ( "\nTest case ADD: Call PAPI_set_opt(PAPI_DOMAIN) on EventSet after add\n" );
258  options.domain.eventset = EventSet1;
259  options.domain.domain = PAPI_DOM_ALL;
260 
261  retval = PAPI_set_opt( PAPI_DOMAIN, &options );
262  if ( retval != PAPI_OK && retval != PAPI_ECMP ) {
263  test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval );
264  }
265  options.domain.eventset = EventSet2;
266  options.domain.domain = PAPI_DOM_KERNEL;
267 
268  retval = PAPI_set_opt( PAPI_DOMAIN, &options );
269  if ( retval != PAPI_OK )
270  test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval );
271 
272  options.domain.eventset = EventSet3;
273  options.domain.domain = PAPI_DOM_USER;
274 
275  retval = PAPI_set_opt( PAPI_DOMAIN, &options );
276  if ( retval != PAPI_OK )
277  test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval );
278  }
279 
280  /* 2 events */
281 
282  values = allocate_test_space( num_tests, 2 );
283 
284  if ( num == CHANGE ) {
285  /* This testcase is dependent on the CREATE testcase running immediately before it, using
286  * domain settings of "All", "Kernel" and "User", on event sets 1, 2, and 3, respectively.
287  */
288  PAPI_option_t option;
289  printf
290  ( "\nTest case CHANGE 1: Change domain on EventSet between runs, using generic domain options:\n" );
291  PAPI_start( EventSet1 );
292  PAPI_stop( EventSet1, values[0] );
293 
294  // change EventSet1 domain from All to User
295  option.domain.domain = PAPI_DOM_USER;
296  option.domain.eventset = EventSet1;
297  retval = PAPI_set_opt( PAPI_DOMAIN, &option );
298  if ( retval != PAPI_OK )
299  test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
300 
301  PAPI_start( EventSet2 );
302  PAPI_stop( EventSet2, values[1] );
303 
304  // change EventSet2 domain from Kernel to All
305  option.domain.domain = PAPI_DOM_ALL;
306  option.domain.eventset = EventSet2;
307  retval = PAPI_set_opt( PAPI_DOMAIN, &option );
308  if ( retval != PAPI_OK )
309  test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
310 
311  PAPI_start( EventSet3 );
312  PAPI_stop( EventSet3, values[2] );
313 
314  // change EventSet3 domain from User to Kernel
315  option.domain.domain = PAPI_DOM_KERNEL;
316  option.domain.eventset = EventSet3;
317  retval = PAPI_set_opt( PAPI_DOMAIN, &option );
318  if ( retval != PAPI_OK )
319  test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
320 
321  free_test_space( values, num_tests );
322  values = allocate_test_space( num_tests, 2 );
323 
324  }
325 
326  if ( num == SUPERVISOR &&
327  ( cmpinfo->available_domains & PAPI_DOM_SUPERVISOR ) ) {
328  PAPI_option_t option;
329 
330  printf
331  ( "\nTest case CHANGE 2: Change domain on EventSets to include/exclude supervisor events:\n" );
332 
333  option.domain.domain = PAPI_DOM_ALL;
334  option.domain.eventset = EventSet1;
335  retval = PAPI_set_opt( PAPI_DOMAIN, &option );
336  if ( retval != PAPI_OK )
337  test_fail( __FILE__, __LINE__, "PAPI_set_domain ALL ", retval );
338 
340  option.domain.eventset = EventSet2;
341  retval = PAPI_set_opt( PAPI_DOMAIN, &option );
342  if ( retval != PAPI_OK ) {
343 
344  /* DOM_ALL is special-cased as domains_available */
345  /* in papi.c . Some machines don't like DOM_OTHER */
346  /* so try that if the above case fails. */
347  option.domain.domain ^= PAPI_DOM_OTHER;
348  option.domain.eventset = EventSet2;
349  retval = PAPI_set_opt( PAPI_DOMAIN, &option );
350 
351  if (retval != PAPI_OK) {
352  test_fail( __FILE__, __LINE__, "PAPI_set_domain ALL^SUPERVISOR ", retval );
353  }
354  }
355 
357  option.domain.eventset = EventSet3;
358  retval = PAPI_set_opt( PAPI_DOMAIN, &option );
359  if ( retval != PAPI_OK )
360  test_fail( __FILE__, __LINE__, "PAPI_set_domain SUPERVISOR ", retval );
361 
362  free_test_space( values, num_tests );
363  values = allocate_test_space( num_tests, 2 );
364  }
365  /* Warm it up dude */
366 
367  PAPI_start( EventSet1 );
368  do_flops( NUM_FLOPS );
369  PAPI_stop( EventSet1, NULL );
370 
371  retval = PAPI_start( EventSet1 );
372  if ( retval != PAPI_OK )
373  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
374 
375  do_flops( NUM_FLOPS );
376 
377  retval = PAPI_stop( EventSet1, values[0] );
378  if ( retval != PAPI_OK )
379  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
380 
381  retval = PAPI_start( EventSet2 );
382 
383  do_flops( NUM_FLOPS );
384 
385  if ( retval == PAPI_OK ) {
386  retval = PAPI_stop( EventSet2, values[1] );
387  if ( retval != PAPI_OK )
388  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
389  } else {
390  values[1][0] = retval;
391  values[1][1] = retval;
392  }
393 
394  retval = PAPI_start( EventSet3 );
395  if ( retval != PAPI_OK )
396  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
397 
398  do_flops( NUM_FLOPS );
399 
400  retval = PAPI_stop( EventSet3, values[2] );
401  if ( retval != PAPI_OK )
402  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
403 
404  retval = PAPI_cleanup_eventset( EventSet1 );
405  if ( retval != PAPI_OK )
406  test_fail( __FILE__, __LINE__, "PAPI_cleanup", retval );
407 
408  retval = PAPI_destroy_eventset( &EventSet1 );
409  if ( retval != PAPI_OK )
410  test_fail( __FILE__, __LINE__, "PAPI_destroy", retval );
411 
412  retval = PAPI_cleanup_eventset( EventSet2 );
413  if ( retval != PAPI_OK )
414  test_fail( __FILE__, __LINE__, "PAPI_cleanup", retval );
415 
416  retval = PAPI_destroy_eventset( &EventSet2 );
417  if ( retval != PAPI_OK )
418  test_fail( __FILE__, __LINE__, "PAPI_destroy", retval );
419 
420  retval = PAPI_cleanup_eventset( EventSet3 );
421  if ( retval != PAPI_OK )
422  test_fail( __FILE__, __LINE__, "PAPI_cleanup", retval );
423 
424  retval = PAPI_destroy_eventset( &EventSet3 );
425  if ( retval != PAPI_OK )
426  test_fail( __FILE__, __LINE__, "PAPI_destroy", retval );
427 
428  dump_and_verify( num, values );
429 
430  free(values);
431 
432  PAPI_shutdown( );
433 }
memset(eventId, 0, size)
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2258
#define NUM_FLOPS
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:807
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1622
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
#define PAPI_NULL
Definition: papi.h:290
#define PAPI_DOM_KERNEL
Definition: papi.h:298
#define PAPI_TOT_INS
#define PAPI_DOM_ALL
Definition: papi.h:301
return PAPI_OK
Definition: linux-nvml.c:458
#define CHANGE
Definition: second.c:26
#define PAPI_DOM_USER
Definition: papi.h:296
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
#define printf
Definition: papi_test.h:125
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3409
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
void PAPI_shutdown(void)
Definition: papi.c:4400
#define PAPI_TOT_CYC
free(dummyfile[xx])
void int num
Definition: iozone.c:22151
#define ADD
Definition: second.c:24
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:131
#define MIDDLE
Definition: second.c:25
#define PAPI_ECMP
Definition: papi.h:254
int EventSet2
Definition: rapl_overflow.c:12
#define SUPERVISOR
Definition: second.c:27
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2834
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1485
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
int num_tests
Definition: zero_fork.c:46
#define PAPI_DOMAIN
Definition: papi.h:431
void dump_and_verify(int test_case, long long **values)
Definition: second.c:30
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_query_event(int EventCode)
Definition: papi.c:698
#define CREATE
Definition: second.c:23
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1971
PAPI_domain_option_t domain
Definition: papi.h:852
#define PAPI_DOM_OTHER
Definition: papi.h:299
#define PAPI_DOM_SUPERVISOR
Definition: papi.h:300
int PAPI_start(int EventSet)
Definition: papi.c:2053
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:107
#define PAPI_VER_CURRENT
Definition: papi.h:223
static options_t options
int EventSet1
Definition: zero_fork.c:40

Here is the call graph for this function:

void case1_driver ( void  )

Definition at line 548 of file second.c.

549 {
550  case1( ADD );
551  case1( MIDDLE );
552  case1( CREATE );
553  case1( CHANGE );
554  case1( SUPERVISOR );
555 }
int case1()
Definition: multiplex1.c:90
#define CHANGE
Definition: second.c:26
#define ADD
Definition: second.c:24
#define MIDDLE
Definition: second.c:25
#define SUPERVISOR
Definition: second.c:27
#define CREATE
Definition: second.c:23

Here is the call graph for this function:

Here is the caller graph for this function:

void case2 ( int  num,
int  domain,
long long values 
)

Definition at line 436 of file second.c.

437 {
438  int retval;
439  int EventSet1 = PAPI_NULL;
441 
442  memset( &options, 0x0, sizeof ( options ) );
443 
445  if ( retval != PAPI_VER_CURRENT )
446  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
447 
448  if ( ( retval = PAPI_query_event( PAPI_TOT_INS ) ) != PAPI_OK )
449  test_skip( __FILE__, __LINE__, "PAPI_query_event", retval );
450 
451  if ( ( retval = PAPI_query_event( PAPI_TOT_CYC ) ) != PAPI_OK )
452  test_skip( __FILE__, __LINE__, "PAPI_query_event", retval );
453 
454  if ( num == CREATE ) {
455  printf
456  ( "\nTest case 2, CREATE: Call PAPI_set_domain(%s) before create\n",
457  stringify_domain( domain ) );
458  printf
459  ( "This should override the domain setting for this EventSet.\n" );
460 
461  retval = PAPI_set_domain( domain );
462  if ( retval != PAPI_OK )
463  test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
464  }
465 
466  retval = PAPI_create_eventset( &EventSet1 );
467  if ( retval != PAPI_OK )
468  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
469 
470  if ( num == ADD ) {
471  printf( "\nTest case 2, ADD: Call PAPI_set_domain(%s) before add\n",
472  stringify_domain( domain ) );
473  printf
474  ( "This should have no effect on the domain setting for this EventSet.\n" );
475 
476  retval = PAPI_set_domain( domain );
477  if ( retval != PAPI_OK )
478  test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
479  }
480 
481  retval = PAPI_add_event( EventSet1, PAPI_TOT_INS );
482  if ( retval != PAPI_OK )
483  test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_INS)", retval );
484 
485  if ( num == MIDDLE ) {
486  printf
487  ( "\nTest case 2, MIDDLE: Call PAPI_set_domain(%s) between adds\n",
488  stringify_domain( domain ) );
489  printf
490  ( "This should have no effect on the domain setting for this EventSet.\n" );
491 
492  retval = PAPI_set_domain( domain );
493  if ( retval != PAPI_OK )
494  test_fail( __FILE__, __LINE__, "PAPI_set_domain", retval );
495  }
496 
497  retval = PAPI_add_event( EventSet1, PAPI_TOT_CYC );
498  if ( retval != PAPI_OK )
499  test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_CYC)", retval );
500 
501 
502  /* Warm it up dude */
503 
504  PAPI_start( EventSet1 );
505  do_flops( NUM_FLOPS );
506  PAPI_stop( EventSet1, NULL );
507 
508  retval = PAPI_start( EventSet1 );
509  if ( retval != PAPI_OK )
510  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
511 
512  do_flops( NUM_FLOPS );
513 
514  retval = PAPI_stop( EventSet1, values );
515  if ( retval != PAPI_OK )
516  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
517 
518  retval = PAPI_cleanup_eventset( EventSet1 );
519  if ( retval != PAPI_OK )
520  test_fail( __FILE__, __LINE__, "PAPI_cleanup", retval );
521 
522  retval = PAPI_destroy_eventset( &EventSet1 );
523  if ( retval != PAPI_OK )
524  test_fail( __FILE__, __LINE__, "PAPI_destroy", retval );
525 
526  PAPI_shutdown( );
527 }
memset(eventId, 0, size)
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2258
#define NUM_FLOPS
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1622
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
#define PAPI_NULL
Definition: papi.h:290
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:458
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
#define printf
Definition: papi_test.h:125
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
void PAPI_shutdown(void)
Definition: papi.c:4400
#define PAPI_TOT_CYC
void int num
Definition: iozone.c:22151
#define ADD
Definition: second.c:24
#define MIDDLE
Definition: second.c:25
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2834
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_query_event(int EventCode)
Definition: papi.c:698
#define CREATE
Definition: second.c:23
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1971
char * stringify_domain(int domain)
Definition: test_utils.c:388
int PAPI_set_domain(int domain)
Definition: papi.c:5614
int PAPI_start(int EventSet)
Definition: papi.c:2053
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
static options_t options
int EventSet1
Definition: zero_fork.c:40

Here is the call graph for this function:

void case2_driver ( void  )

Definition at line 530 of file second.c.

531 {
532  long long **values;
533 
534  /* 3 tests, 2 events */
535 
536  values = allocate_test_space( 3, 2 );
537 
538  case2( CREATE, PAPI_DOM_KERNEL, values[0] );
539  case2( ADD, PAPI_DOM_KERNEL, values[1] );
540  case2( MIDDLE, PAPI_DOM_KERNEL, values[2] );
541 
542  dump_and_verify( CASE2, values );
543 
544  free(values);
545 }
#define CASE2
Definition: second.c:22
#define PAPI_DOM_KERNEL
Definition: papi.h:298
int case2()
Definition: multiplex1.c:139
free(dummyfile[xx])
#define ADD
Definition: second.c:24
#define MIDDLE
Definition: second.c:25
void dump_and_verify(int test_case, long long **values)
Definition: second.c:30
#define CREATE
Definition: second.c:23
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:107

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_and_verify ( int  test_case,
long long **  values 
)

Definition at line 30 of file second.c.

31 {
32  long long min, max, min2, max2;
33 
34  printf
35  ( "-----------------------------------------------------------------\n" );
36  printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
37  printf( "-------------------------------------------------------------\n" );
38 
39  if ( test_case == CASE2 ) {
40  printf
41  ( "Test type : Before Create Before Add Between Adds\n" );
42  printf( TAB_DOM, "PAPI_TOT_INS: ", ( values[0] )[0], ( values[1] )[0],
43  ( values[2] )[0] );
44  printf( TAB_DOM, "PAPI_TOT_CYC: ", ( values[0] )[1], ( values[1] )[1],
45  ( values[2] )[1] );
46  printf
47  ( "-------------------------------------------------------------\n" );
48  printf( "Verification:\n" );
49  printf( "Both rows equal 'n N N' where n << N\n" );
50  return;
51  } else if ( test_case == CHANGE ) {
52  min = ( long long ) ( ( double ) values[0][0] * ( 1 - TOLERANCE ) );
53  max = ( long long ) ( ( double ) values[0][0] * ( 1 + TOLERANCE ) );
54  if ( values[1][0] > max || values[1][0] < min )
55  test_fail( __FILE__, __LINE__, "PAPI_TOT_INS", 1 );
56 
57  min = ( long long ) ( ( double ) values[1][1] * ( 1 - TOLERANCE ) );
58  max = ( long long ) ( ( double ) values[1][1] * ( 1 + TOLERANCE ) );
59  if ( ( values[2][1] + values[0][1] ) > max ||
60  ( values[2][1] + values[0][1] ) < min )
61  test_fail( __FILE__, __LINE__, "PAPI_TOT_CYC", 1 );
62 
63  printf
64  ( "Test type : PAPI_DOM_ALL PAPI_DOM_KERNEL PAPI_DOM_USER\n" );
65  printf( TAB_DOM, "PAPI_TOT_INS: ", ( values[1] )[0], ( values[2] )[0],
66  ( values[0] )[0] );
67  printf( TAB_DOM, "PAPI_TOT_CYC: ", ( values[1] )[1], ( values[2] )[1],
68  ( values[0] )[1] );
69  printf
70  ( "-------------------------------------------------------------\n" );
71 
72  printf( "Verification:\n" );
73  printf( "Both rows approximately equal '(N+n) n N', where n << N\n" );
74  printf( "Column 1 approximately equals column 2 plus column 3\n" );
75  } else if ( test_case == SUPERVISOR ) {
76  printf
77  ( "Test type : PAPI_DOM_ALL All-minus-supervisor Supervisor-only\n" );
78  printf( TAB_DOM, "PAPI_TOT_INS: ", ( values[0] )[0], ( values[1] )[0],
79  ( values[2] )[0] );
80  printf( TAB_DOM, "PAPI_TOT_CYC: ", ( values[0] )[1], ( values[1] )[1],
81  ( values[2] )[1] );
82  printf
83  ( "-------------------------------------------------------------\n" );
84  printf( "Verification:\n" );
85  printf( "Both rows approximately equal '(N+n) n N', where n << N\n" );
86  printf( "Column 1 approximately equals column 2 plus column 3\n" );
87  } else {
88  min = ( long long ) ( ( double ) values[2][0] * ( 1 - TOLERANCE ) );
89  max = ( long long ) ( ( double ) values[2][0] * ( 1 + TOLERANCE ) );
90 
91  min2 = ( long long ) ( ( double ) values[0][1] * ( 1 - TOLERANCE ) );
92  max2 =
93  ( long long ) ( ( double ) ( double ) values[0][1] *
94  ( 1 + TOLERANCE ) );
95 
96  printf
97  ( "Test type : PAPI_DOM_ALL PAPI_DOM_KERNEL PAPI_DOM_USER\n" );
98  printf( TAB_DOM, "PAPI_TOT_INS: ", ( values[0] )[0], ( values[1] )[0],
99  ( values[2] )[0] );
100  printf( TAB_DOM, "PAPI_TOT_CYC: ", ( values[0] )[1], ( values[1] )[1],
101  ( values[2] )[1] );
102  printf
103  ( "-------------------------------------------------------------\n" );
104  printf( "Verification:\n" );
105  printf( "Both rows approximately equal '(N+n) n N', where n << N\n" );
106  printf( "Column 1 approximately equals column 2 plus column 3\n" );
107 
108  if ( values[0][0] > max || values[0][0] < min )
109  test_fail( __FILE__, __LINE__, "PAPI_TOT_INS", 1 );
110 
111  if ( ( values[1][1] + values[2][1] ) > max2 ||
112  ( values[1][1] + values[2][1] ) < min2 )
113  test_fail( __FILE__, __LINE__, "PAPI_TOT_CYC", 1 );
114  }
115 
116  if ( values[0][0] == 0 || values[0][1] == 0 ||
117  values[1][0] == 0 || values[1][1] == 0 )
118  test_fail( __FILE__, __LINE__,
119  "Verify non-zero count for all domain types", 1 );
120 
121  if ( values[2][0] == 0 || values[2][1] == 0 ) {
122  if ( test_case == SUPERVISOR ) {
123  printf
124  ( "WARNING: No events counted in supervisor context. This is expected in a non-virtualized environment.\n" );
125  } else {
126  test_fail( __FILE__, __LINE__,
127  "Verify non-zero count for all domain types", 1 );
128  }
129  }
130 }
#define NUM_FLOPS
off64_t max
Definition: libasync.c:331
#define TOLERANCE
Definition: test_utils.h:13
#define CASE2
Definition: second.c:22
#define CHANGE
Definition: second.c:26
#define printf
Definition: papi_test.h:125
static double
Definition: fileop.c:1281
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
long long
Definition: iozone.c:19827
#define min(x, y)
Definition: darwin-common.h:4
#define SUPERVISOR
Definition: second.c:27
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
#define TAB_DOM
Definition: second.c:20

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 558 of file second.c.

559 {
560  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
561 
562 #if defined(sgi) && defined(host_mips)
563  uid_t id;
564  id = getuid( );
565  if ( id != 0 ) {
566  printf( "IRIX requires root for PAPI_DOM_KERNEL and PAPI_DOM_ALL.\n" );
567  test_skip( __FILE__, __LINE__, "", 1 );
568  }
569 #endif
570 
571  printf
572  ( "Test second.c: set domain of eventset via PAPI_set_domain and PAPI_set_opt.\n\n" );
573  printf
574  ( "* PAPI_set_domain(DOMAIN) sets the default domain \napplied to subsequently created EventSets.\n" );
575  printf( "It should have no effect on existing EventSets.\n\n" );
576  printf
577  ( "* PAPI_set_opt(DOMAIN,xxx) sets the domain for a specific EventSet.\n" );
578  printf
579  ( "It should always override the default setting for that EventSet.\n" );
580  case2_driver( );
581  case1_driver( );
582 
583  test_pass( __FILE__, NULL, 0 );
584  exit( 1 );
585 }
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
tests_quiet(argc, argv)
#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
uint32_t id
Definition: linux-cuda.c:293
void case2_driver(void)
Definition: second.c:530
void case1_driver(void)
Definition: second.c:548
void exit()

Here is the call graph for this function: