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

Go to the source code of this file.

Macros

#define NUM_EVENTS   2
 

Functions

int main (int argc, char **argv)
 

Variables

int TESTS_QUIET
 

Macro Definition Documentation

#define NUM_EVENTS   2

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 16 of file high-level.c.

17 {
18 #define NUM_EVENTS 2
19  int retval;
21  long long myvalues[NUM_EVENTS];
22  int Events[NUM_EVENTS];
23 
24  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
25 
27  if ( retval != PAPI_VER_CURRENT )
28  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
29 
30  /* query and set up the right events to monitor */
31  if ( PAPI_query_event( PAPI_FP_INS ) == PAPI_OK ) {
32  Events[0] = PAPI_FP_INS;
33  } else {
34  Events[0] = PAPI_TOT_INS;
35  }
36  Events[1] = PAPI_TOT_CYC;
37 
38  retval = PAPI_start_counters( ( int * ) Events, NUM_EVENTS );
39  if ( retval != PAPI_OK )
40  test_fail( __FILE__, __LINE__, "PAPI_start_counters", retval );
41 
42  /* Loop 1 */
44 
45  retval = PAPI_read_counters( values, NUM_EVENTS );
46  if ( retval != PAPI_OK )
47  test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval );
48 
49  if ( !TESTS_QUIET )
50  printf( TWO12, values[0], values[1], "(Counters continuing...)\n" );
51 
52  myvalues[0] = values[0];
53  myvalues[1] = values[1];
54  /* Loop 2 */
56 
57  retval = PAPI_accum_counters( values, NUM_EVENTS );
58  if ( retval != PAPI_OK )
59  test_fail( __FILE__, __LINE__, "PAPI_accum_counters", retval );
60 
61  if ( !TESTS_QUIET )
62  printf( TWO12, values[0], values[1], "(Counters being ''held'')\n" );
63 
64  /* Loop 3 */
65  /* Simulated code that should not be counted */
67 
68  retval = PAPI_read_counters( dummyvalues, NUM_EVENTS );
69  if ( retval != PAPI_OK )
70  test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval );
71  if ( !TESTS_QUIET )
72  printf( TWO12, dummyvalues[0], dummyvalues[1], "(Skipped counts)\n" );
73 
74  if ( !TESTS_QUIET )
75  printf( "%12s %12s (''Continuing'' counting)\n", "xxx", "xxx" );
76  /* Loop 4 */
78 
79  retval = PAPI_accum_counters( values, NUM_EVENTS );
80  if ( retval != PAPI_OK )
81  test_fail( __FILE__, __LINE__, "PAPI_accum_counters", retval );
82 
83  if ( !TESTS_QUIET )
84  printf( TWO12, values[0], values[1], "" );
85 
86  if ( !TESTS_QUIET ) {
87  printf( "----------------------------------\n" );
88  printf( "Verification: The last line in each experiment should be\n" );
89  printf( "approximately three times the value of the first line.\n" );
90  }
91 
92  {
93  long long min, max;
94  min = ( long long ) ( ( double ) myvalues[0] * .9 );
95  max = ( long long ) ( ( double ) myvalues[0] * 1.1 );
96  if ( values[0] < ( 3 * min ) || values[0] > ( 3 * max ) ) {
97  retval = 1;
98  if ( PAPI_query_event( PAPI_FP_INS ) == PAPI_OK ) {
99  test_fail( __FILE__, __LINE__, "PAPI_FP_INS", 1 );
100  } else {
101  test_fail( __FILE__, __LINE__, "PAPI_TOT_INS", 1 );
102  }
103  }
104  min = ( long long ) ( ( double ) myvalues[1] * .9 );
105  max = ( long long ) ( ( double ) myvalues[1] * 1.1 );
106  if ( values[1] < ( 3 * min ) || values[1] > ( 3 * max ) ) {
107  retval = 1;
108  test_fail( __FILE__, __LINE__, "PAPI_TOT_CYC", 1 );
109  }
110  }
111  /* The values array is not allocated through allocate_test_space
112  * so we need to pass NULL here */
113  test_pass( __FILE__, NULL, NUM_EVENTS );
114  exit( 1 );
115 }
#define NUM_FLOPS
#define TWO12
Definition: papi_test.h:117
off64_t max
Definition: libasync.c:331
#define NUM_EVENTS
static int Events[NUM_EVENTS]
Definition: init_fini.c:8
int PAPI_accum_counters(long long *values, int array_len)
Definition: papi_hl.c:756
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
#define PAPI_TOT_CYC
long long dummyvalues[2]
long long
Definition: iozone.c:19827
#define min(x, y)
Definition: darwin-common.h:4
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_query_event(int EventCode)
Definition: papi.c:698
int PAPI_read_counters(long long *values, int array_len)
Definition: papi_hl.c:706
int PAPI_start_counters(int *events, int array_len)
Definition: papi_hl.c:593
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
void exit()
#define PAPI_FP_INS

Here is the call graph for this function:

Variable Documentation

int TESTS_QUIET

Definition at line 11 of file test_utils.c.