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

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 13 of file high-level2.c.

14 {
15  int retval;
16  int Events, fip = 0;
17  long long values, flpins;
18  float real_time, proc_time, mflops;
19  int quiet;
20 
21  /* Set TESTS_QUIET variable */
22  quiet=tests_quiet( argc, argv );
23 
24  /* Initialize PAPI library */
26  if ( retval != PAPI_VER_CURRENT ) {
27  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
28  }
29 
30  /* First see if we have PAPI_FP_INS event */
31  if ( PAPI_query_event( PAPI_FP_INS ) == PAPI_OK ) {
32  fip = 1;
33  Events = PAPI_FP_INS;
34  /* If not, look for PAPI_FP_OPS */
35  } else if ( PAPI_query_event( PAPI_FP_OPS ) == PAPI_OK ) {
36  fip = 2;
37  Events = PAPI_FP_OPS;
38  } else {
39  if ( !quiet ) {
40  printf( "PAPI_FP_INS and PAPI_FP_OPS are not defined for this platform.\n" );
41  }
42  test_skip( __FILE__, __LINE__, "FLOPS event not supported", 1);
43  }
44 
45  /* Start counting flips or flops event */
46  if ( fip == 1 ) {
47  retval = PAPI_flips( &real_time, &proc_time, &flpins, &mflops );
48  if (retval != PAPI_OK ) {
49  test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
50  }
51  } else {
52  retval = PAPI_flops( &real_time, &proc_time, &flpins, &mflops );
53  if (retval != PAPI_OK ) {
54  test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
55  }
56  }
57 
58  /* If we are flipsing/flopsing, then start_counters should fail */
59  retval = PAPI_start_counters( &Events, 1 );
60  if (retval == PAPI_OK) {
61  test_fail( __FILE__, __LINE__, "PAPI_start_counters", retval );
62  }
63 
64  /* Try flipsing/flopsing again, should work */
65  if ( fip == 1 ) {
66  retval = PAPI_flips( &real_time, &proc_time, &flpins, &mflops );
67  if (retval != PAPI_OK ) {
68  test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
69  }
70  } else {
71  retval = PAPI_flops( &real_time, &proc_time, &flpins, &mflops );
72  if (retval != PAPI_OK) {
73  test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
74  }
75  }
76 
77  /* If we are flipsing/flopsing, then read should fail */
78  if ( ( retval = PAPI_read_counters( &values, 1 ) ) == PAPI_OK ) {
79  test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval );
80  }
81 
82  /* Stop should still work then */
83  if ( ( retval = PAPI_stop_counters( &values, 1 ) ) != PAPI_OK ) {
84  test_fail( __FILE__, __LINE__, "PAPI_stop_counters", retval );
85  }
86 
87  /* Restart flips/flops */
88  if ( fip == 1 ) {
89  retval = PAPI_flips( &real_time, &proc_time, &flpins, &mflops );
90  if (retval != PAPI_OK) {
91  test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
92  }
93  } else {
94  retval = PAPI_flops( &real_time, &proc_time, &flpins, &mflops );
95  if (retval != PAPI_OK) {
96  test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
97  }
98  }
99 
100  /* Try reading again, should fail */
101  if ( ( retval = PAPI_read_counters( &values, 1 ) ) == PAPI_OK ) {
102  test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval );
103  }
104 
105  /* Stop */
106  if ( ( retval = PAPI_stop_counters( &values, 1 ) ) != PAPI_OK ) {
107  test_fail( __FILE__, __LINE__, "PAPI_stop_counters", retval );
108  }
109 
110  /* Now try starting, should work */
111  if ( ( retval = PAPI_start_counters( &Events, 1 ) ) != PAPI_OK ) {
112  test_fail( __FILE__, __LINE__, "PAPI_start_counters", retval );
113  }
114 
115  /* Read should work too */
116  if ( ( retval = PAPI_read_counters( &values, 1 ) ) != PAPI_OK ) {
117  test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval );
118  }
119 
120  /* flipsing/flopsing should fail */
121  if ( fip == 1 ) {
122  retval = PAPI_flips( &real_time, &proc_time, &flpins, &mflops );
123  if (retval == PAPI_OK ) {
124  test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
125  }
126  } else {
127  retval = PAPI_flops( &real_time, &proc_time, &flpins, &mflops );
128  if (retval == PAPI_OK ) {
129  test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
130  }
131  }
132 
133  /* Stop everything */
134  if ( ( retval = PAPI_stop_counters( &values, 1 ) ) != PAPI_OK ) {
135  test_fail( __FILE__, __LINE__, "PAPI_stop_counters", retval );
136  }
137 
138  test_pass( __FILE__ );
139 
140  return 0;
141 }
void test_pass(const char *filename)
Definition: test_utils.c:432
#define PAPI_FP_OPS
static int Events[NUM_EVENTS]
Definition: init_fini.c:8
int PAPI_flops(float *rtime, float *ptime, long long *flpops, float *mflops)
Definition: papi_hl.c:259
return PAPI_OK
Definition: linux-nvml.c:497
int int argc
Definition: iozone.c:1609
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
int PAPI_flips(float *rtime, float *ptime, long long *flpins, float *mflips)
Definition: papi_hl.c:204
int PAPI_library_init(int version)
Definition: papi.c:500
int PAPI_stop_counters(long long *values, int array_len)
Definition: papi_hl.c:803
int quiet
Definition: rapl_overflow.c:18
int PAPI_query_event(int EventCode)
Definition: papi.c:684
printf("\tTry: -i 0 -i 1 \n\n")
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
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:225
#define PAPI_FP_INS

Here is the call graph for this function: