PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hl_rates.c File Reference
Include dependency graph for hl_rates.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 33 of file hl_rates.c.

34 {
35  int retval, event = 0;
36  float rtime, ptime, mflips, mflops, ipc, epc;
37  long long flpins, flpops, ins, ref, core, evt;
38 
39  double mflips_classic,mflips_swapped;
40  double mflops_classic,mflops_swapped;
41  double ipc_classic,ipc_swapped;
42  double epc_classic,epc_swapped;
43 
44  int quiet;
45 
46  /* Set TESTS_QUIET variable */
47  quiet=tests_quiet( argc, argv );
48 
49  /* Initialize the test matrix */
51 
52  /************************/
53  /* FLIPS */
54  /************************/
55 
56  if (!quiet) {
57  printf( "\n----------------------------------\n" );
58  printf( "PAPI_flips\n");
59  }
60 
61  /* Run flips at start */
62  retval=PAPI_flips(&rtime, &ptime, &flpins, &mflips);
63  if (retval!=PAPI_OK) {
64  if (!quiet) PAPI_perror( "PAPI_flips" );
65  if (retval==PAPI_ENOEVNT) {
66  test_skip(__FILE__,__LINE__,"Could not add event",0);
67  }
68  }
69 
70  if (!quiet) {
71  printf( "\nStart\n");
72  printf( "real time: %f\n", rtime);
73  printf( "process time: %f\n", ptime);
74  printf( "FP Instructions: %lld\n", flpins);
75  printf( "MFLIPS %f\n", mflips);
76  }
77 
78  /* Be sure we are all zero at beginning */
79  if ((rtime!=0) || (ptime!=0) || (flpins!=0) || (mflips!=0)) {
80  test_fail(__FILE__,__LINE__,"Not initialized to zero",0);
81  }
82 
83  // Flips classic
85  if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips) != PAPI_OK )
86  PAPI_perror( "PAPI_flips" );
87 
88  if (!quiet) {
89  printf( "\nClassic\n");
90  printf( "real time: %f\n", rtime);
91  printf( "process time: %f\n", ptime);
92  printf( "FP Instructions: %lld\n", flpins);
93  printf( "MFLIPS %f\n", mflips);
94  }
95  mflips_classic=mflips;
96 
97  // Flips swapped
99  if ( PAPI_flips(&rtime, &ptime, &flpins, &mflips) != PAPI_OK )
100  PAPI_perror( "PAPI_flips" );
101 
102  if (!quiet) {
103  printf( "\nSwapped\n");
104  printf( "real time: %f\n", rtime);
105  printf( "process time: %f\n", ptime);
106  printf( "FP Instructions: %lld\n", flpins);
107  printf( "MFLIPS %f\n", mflips);
108  }
109  mflips_swapped=mflips;
110 
111  // turn off flips
112  if ( PAPI_stop_counters(NULL, 0) != PAPI_OK ) {
113  PAPI_perror( "PAPI_stop_counters" );
114  }
115 
116 
117  /************************/
118  /* FLOPS */
119  /************************/
120 
121  if (!quiet) {
122  printf( "\n----------------------------------\n" );
123  printf( "PAPI_flops\n");
124  }
125 
126  // Start flops
127  if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops) != PAPI_OK ) {
128  PAPI_perror( "PAPI_flops" );
129  }
130 
131  if (!quiet) {
132  printf( "\nStart\n");
133  printf( "real time: %f\n", rtime);
134  printf( "process time: %f\n", ptime);
135  printf( "FP Operations: %lld\n", flpops);
136  printf( "MFLOPS %f\n", mflops);
137  }
138 
139  /* Be sure we are all zero at beginning */
140  if ((rtime!=0) || (ptime!=0) || (flpops!=0) || (mflops!=0)) {
141  test_fail(__FILE__,__LINE__,"Not initialized to zero",0);
142  }
143 
144  // Classic flops
146  if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops) != PAPI_OK )
147  PAPI_perror( "PAPI_flops" );
148 
149  if (!quiet) {
150  printf( "\nClassic\n");
151  printf( "real time: %f\n", rtime);
152  printf( "process time: %f\n", ptime);
153  printf( "FP Operations: %lld\n", flpops);
154  printf( "MFLOPS %f\n", mflops);
155  }
156  mflops_classic=mflops;
157 
158  // Swapped flops
160  if ( PAPI_flops(&rtime, &ptime, &flpops, &mflops) != PAPI_OK )
161  PAPI_perror( "PAPI_flops" );
162 
163  if (!quiet) {
164  printf( "\nSwapped\n");
165  printf( "real time: %f\n", rtime);
166  printf( "process time: %f\n", ptime);
167  printf( "FP Operations: %lld\n", flpops);
168  printf( "MFLOPS %f\n", mflops);
169  }
170  mflops_swapped=mflops;
171 
172  // turn off flops
173  if ( PAPI_stop_counters(NULL, 0) != PAPI_OK ) {
174  PAPI_perror( "PAPI_stop_counters" );
175  }
176 
177 
178  /************************/
179  /* IPC */
180  /************************/
181 
182  if (!quiet) {
183  printf( "\n----------------------------------\n" );
184  printf( "PAPI_ipc\n");
185  }
186 
187  // Start ipc
188  if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc) != PAPI_OK )
189  PAPI_perror( "PAPI_ipc" );
190 
191  if (!quiet) {
192  printf( "\nStart\n");
193  printf( "real time: %f\n", rtime);
194  printf( "process time: %f\n", ptime);
195  printf( "Instructions: %lld\n", ins);
196  printf( "IPC %f\n", ipc);
197  }
198 
199  /* Be sure we are all zero at beginning */
200  if ((rtime!=0) || (ptime!=0) || (ins!=0) || (ipc!=0)) {
201  test_fail(__FILE__,__LINE__,"Not initialized to zero",0);
202  }
203 
204  // Classic ipc
206  if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc) != PAPI_OK )
207  PAPI_perror( "PAPI_ipc" );
208 
209  if (!quiet) {
210  printf( "\nClassic\n");
211  printf( "real time: %f\n", rtime);
212  printf( "process time: %f\n", ptime);
213  printf( "Instructions: %lld\n", ins);
214  printf( "IPC %f\n", ipc);
215  }
216  ipc_classic=ipc;
217 
218  // Swapped ipc
220  if ( PAPI_ipc(&rtime, &ptime, &ins, &ipc) != PAPI_OK )
221  PAPI_perror( "PAPI_ipc" );
222 
223  if (!quiet) {
224  printf( "\nSwapped\n");
225  printf( "real time: %f\n", rtime);
226  printf( "process time: %f\n", ptime);
227  printf( "Instructions: %lld\n", ins);
228  printf( "IPC %f\n", ipc);
229  }
230  ipc_swapped=ipc;
231 
232  // turn off ipc
233  if ( PAPI_stop_counters(NULL, 0) != PAPI_OK ) {
234  PAPI_perror( "PAPI_stop_counters" );
235  }
236 
237 
238  /************************/
239  /* EPC */
240  /************************/
241 
242  if (!quiet) {
243  printf( "\n----------------------------------\n" );
244  printf( "PAPI_epc\n");
245  }
246 
247  /* This unfortunately conflicts a bit with the TESTS_QUIET */
248  /* command line paramater nonsense. */
249 
250  if ( argc >= 2) {
251  retval = PAPI_event_name_to_code( argv[1], &event );
252  if (retval != PAPI_OK) {
253  if (!quiet) printf("Can't find %s; Using PAPI_TOT_INS\n", argv[1]);
254  event = PAPI_TOT_INS;
255  } else {
256  if (!quiet) printf("Using event %s\n", argv[1]);
257  }
258  }
259 
260  // Start epc
261  if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc) != PAPI_OK )
262  PAPI_perror( "PAPI_epc" );
263 
264  if (!quiet) {
265  printf( "\nStart\n");
266  printf( "real time: %f\n", rtime);
267  printf( "process time: %f\n", ptime);
268  printf( "Ref Cycles: %lld\n", ref);
269  printf( "Core Cycles: %lld\n", core);
270  printf( "Events: %lld\n", evt);
271  printf( "EPC: %f\n", epc);
272  }
273 
274  /* Be sure we are all zero at beginning */
275  if ((rtime!=0) || (ptime!=0) || (ref!=0) || (core!=0)
276  || (evt!=0) || (epc!=0)) {
277  test_fail(__FILE__,__LINE__,"Not initialized to zero",0);
278  }
279 
280  // Classic epc
282  if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc) != PAPI_OK )
283  PAPI_perror( "PAPI_epc" );
284 
285  if (!quiet) {
286  printf( "\nClassic\n");
287  printf( "real time: %f\n", rtime);
288  printf( "process time: %f\n", ptime);
289  printf( "Ref Cycles: %lld\n", ref);
290  printf( "Core Cycles: %lld\n", core);
291  printf( "Events: %lld\n", evt);
292  printf( "EPC: %f\n", epc);
293  }
294  epc_classic=epc;
295 
296  // Swapped epc
298  if ( PAPI_epc(event, &rtime, &ptime, &ref, &core, &evt, &epc) != PAPI_OK ) {
299  PAPI_perror( "PAPI_epc" );
300  }
301 
302  if (!quiet) {
303  printf( "\nSwapped\n");
304  printf( "real time: %f\n", rtime);
305  printf( "process time: %f\n", ptime);
306  printf( "Ref Cycles: %lld\n", ref);
307  printf( "Core Cycles: %lld\n", core);
308  printf( "Events: %lld\n", evt);
309  printf( "EPC: %f\n", epc);
310  }
311  epc_swapped=epc;
312 
313  // turn off epc
314  if ( PAPI_stop_counters(NULL, 0) != PAPI_OK ) {
315  PAPI_perror( "PAPI_stop_counters" );
316  }
317 
318  if (!quiet) {
319  printf( "\n----------------------------------\n" );
320  }
321 
322  /* Validate */
323  if (mflips_swapped<mflips_classic) {
324  test_fail(__FILE__,__LINE__,"FLIPS should be better when swapped",0);
325  }
326  if (mflops_swapped<mflops_classic) {
327  test_fail(__FILE__,__LINE__,"FLOPS should be better when swapped",0);
328  }
329  if (ipc_swapped<ipc_classic) {
330  test_fail(__FILE__,__LINE__,"IPC should be better when swapped",0);
331  }
332  if (epc_swapped<epc_classic) {
333  test_fail(__FILE__,__LINE__,"EPC should be better when swapped",0);
334  }
335 
336  test_pass( __FILE__ );
337 
338  return 0;
339 }
#define PAPI_ENOEVNT
Definition: papi.h:260
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_ipc(float *rtime, float *ptime, long long *ins, float *ipc)
Definition: papi_hl.c:316
int PAPI_flops(float *rtime, float *ptime, long long *flpops, float *mflops)
Definition: papi_hl.c:259
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:497
int PAPI_event_name_to_code(const char *in, int *out)
Definition: papi.c:1004
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_epc(int event, float *rtime, float *ptime, long long *ref, long long *core, long long *evt, float *epc)
Definition: papi_hl.c:383
float flops_float_swapped_matrix_matrix_multiply(void)
int PAPI_stop_counters(long long *values, int array_len)
Definition: papi_hl.c:803
int quiet
Definition: rapl_overflow.c:18
int flops_float_init_matrix(void)
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
void PAPI_perror(const char *msg)
Definition: papi.c:4653
float flops_float_matrix_matrix_multiply(void)
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function: