18{
20 double rtime, ptime, mflips, mflops, ipc;
21 long long flips=0, flops=0, ins[2];
22
23 double rtime_start,rtime_end;
24 double ptime_start,ptime_end;
25
26 double rtime_classic,rtime_swapped;
27 double mflips_classic,mflips_swapped;
28 double mflops_classic,mflops_swapped;
29 double ipc_classic,ipc_swapped;
30
31 int quiet,event_added_flips,event_added_flops,event_added_ipc;
32
34
35
37
38
39
43 }
44
45
49 }
50
51
53
54
55
56
57
59 printf( "\n----------------------------------\n" );
60 printf( "PAPI_flips\n");
61 }
62
63
66 if (!
quiet) fprintf(
stderr,
"PAPI_FP_INS not available!\n");
67 event_added_flips=0;
68 }
69 else {
70 event_added_flips=1;
71 }
72
73 if (event_added_flips) {
75 }
76
79
80
82
85
86 if (event_added_flips) {
88 }
89
90 rtime=rtime_end-rtime_start;
91 ptime=ptime_end-ptime_start;
92
93 mflips=flips/rtime;
94
96 printf( "\nClassic\n");
97 printf( "real time: %lf\n", rtime);
98 printf( "process time: %lf\n", ptime);
99 printf( "FP Instructions: %lld\n", flips);
100 printf( "MFLIPS %lf\n", mflips);
101 }
102 mflips_classic=mflips;
103
104
105
108
109 if (event_added_flips) {
112 }
113
115
118
119 if (event_added_flips) {
121 }
122
123 rtime=rtime_end-rtime_start;
124 ptime=ptime_end-ptime_start;
125
126 mflips=flips/rtime;
127
129 printf( "\nSwapped\n");
130 printf( "real time: %f\n", rtime);
131 printf( "process time: %f\n", ptime);
132 printf( "FP Instructions: %lld\n", flips);
133 printf( "MFLIPS %f\n", mflips);
134 }
135 mflips_swapped=mflips;
136
137
138 if (event_added_flips) {
142 "PAPI_remove_named_event",
retval );
143 }
144 }
145
146
147
148
149
151 printf( "\n----------------------------------\n" );
152 printf( "PAPI_flops\n");
153 }
154
155
158 if (!
quiet) fprintf(
stderr,
"PAPI_FP_OPS not available!\n");
159 event_added_flops=0;
160 }
161 else {
162 event_added_flops=1;
163 }
164
165 if (event_added_flops) {
167 }
168
171
172
174
177
178 if (event_added_flops) {
180 }
181
182 rtime=rtime_end-rtime_start;
183 ptime=ptime_end-ptime_start;
184
185 mflops=flops/rtime;
186
188 printf( "\nClassic\n");
189 printf( "real time: %f\n", rtime);
190 printf( "process time: %f\n", ptime);
191 printf( "FP Operations: %lld\n", flops);
192 printf( "MFLOPS %f\n", mflops);
193 }
194 mflops_classic=mflops;
195
196
197
200
201 if (event_added_flops) {
204 }
205
207
210
211 if (event_added_flops) {
213 }
214
215 rtime=rtime_end-rtime_start;
216 ptime=ptime_end-ptime_start;
217
218 mflops=flops/rtime;
219
221 printf( "\nSwapped\n");
222 printf( "real time: %f\n", rtime);
223 printf( "process time: %f\n", ptime);
224 printf( "FP Operations: %lld\n", flops);
225 printf( "MFLOPS %f\n", mflops);
226 }
227 mflops_swapped=mflops;
228
229
230 if (event_added_flops) {
234 "PAPI_remove_named_event",
retval );
235 }
236 }
237
238
239
240
241
243 printf( "\n----------------------------------\n" );
244 printf( "PAPI_ipc\n");
245 }
246
247
250 if (!
quiet) fprintf(
stderr,
"PAPI_TOT_INS not available!\n");
251 event_added_ipc=0;
252 }
253 else {
254 event_added_ipc=1;
255 }
256
257 if (event_added_ipc) {
258
261 if (!
quiet) fprintf(
stderr,
"PAPI_TOT_CYC not available!\n");
262 event_added_ipc=0;
263 }
264 else {
265 event_added_ipc=1;
266 }
267 }
268
269 if (event_added_ipc) {
271 }
272
275
276
278
281
282 if (event_added_ipc) {
284 }
285
286 rtime=rtime_end-rtime_start;
287 ptime=ptime_end-ptime_start;
288
289 ipc=(double)ins[0]/(double)ins[1];
290
292 printf( "\nClassic\n");
293 printf( "real time: %lf\n", rtime);
294 printf( "process time: %lf\n", ptime);
295 printf( "Instructions: %lld\n", ins[0]);
296 printf( "Cycles: %lld\n", ins[1]);
297 printf( "IPC %lf\n", ipc);
298 }
299 ipc_classic=ipc;
300 rtime_classic=rtime;
301
302
303
304 if (event_added_ipc) {
307 }
308
311
312
314
317
318 if (event_added_ipc) {
320 }
321
322 rtime=rtime_end-rtime_start;
323 ptime=ptime_end-ptime_start;
324
325 ipc=(double)ins[0]/(double)ins[1];
326
328 printf( "\nSwapped\n");
329 printf( "real time: %lf\n", rtime);
330 printf( "process time: %lf\n", ptime);
331 printf( "Instructions: %lld\n", ins[0]);
332 printf( "Cycles: %lld\n", ins[1]);
333 printf( "IPC %lf\n", ipc);
334 }
335 ipc_swapped=ipc;
336 rtime_swapped=rtime;
337
338
339
340 if (event_added_flips) {
341 if (mflips_swapped<mflips_classic) {
343 "FLIPS should be better when swapped",0);
344 }
345 }
346
347 if (event_added_flops) {
348 if (mflops_swapped<mflops_classic) {
350 "FLOPS should be better when swapped",0);
351 }
352 }
353
354 if (event_added_ipc) {
355 if (ipc_swapped<ipc_classic) {
357 "IPC should be better when swapped",0);
358 }
359 }
360
361 if (rtime_swapped>rtime_classic) {
363 "time should be better when swapped",0);
364 }
365
367
368 return 0;
369}
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI EventSet.
get real time counter value in microseconds
get virtual time counter values in microseconds
initialize the PAPI library.
removes a named hardware event from a PAPI event set.
Reset the hardware event counts in an event set.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
float flops_float_swapped_matrix_matrix_multiply(void)
float flops_float_matrix_matrix_multiply(void)
int flops_float_init_matrix(void)
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)