198{
199 extern void dummy(
void * );
200
201 float aa, *
a=NULL, *
b=NULL, *
c=NULL, *
x=NULL, *
y=NULL;
202 double aad, *ad=NULL, *bd=NULL, *cd=NULL, *xd=NULL, *yd=NULL;
204 int inner = 0;
205 int vector = 0;
206 int matrix = 0;
207 int double_precision = 0;
208 int fail = 1;
211 int papi_event;
214
215
216 for (
i = 0;
i < argc;
i++ ) {
217 if ( strstr( argv[
i],
"-i" ) )
218 inner = 1;
219 else if ( strstr( argv[
i],
"-f" ) )
220 fail = 0;
221 else if ( strstr( argv[
i],
"-v" ) )
222 vector = 1;
223 else if ( strstr( argv[
i],
"-m" ) )
224 matrix = 1;
225 else if ( strstr( argv[
i],
"-e" ) ) {
226 if ( ( argv[
i + 1] == NULL ) || ( strlen( argv[
i + 1] ) == 0 ) ) {
228 exit( 1 );
229 }
230 strncpy( papi_event_str, argv[
i + 1],
sizeof ( papi_event_str ) - 1);
231 papi_event_str[sizeof ( papi_event_str )-1] = '\0';
233 }
else if ( strstr( argv[
i],
"-d" ) )
234 double_precision = 1;
235 else if ( strstr( argv[
i],
"-h" ) ) {
237 exit( 1 );
238 }
239 }
240
241
242 if ( inner + vector + matrix == 0 )
243 inner = vector = matrix = 1;
244
245
246
248
250 printf( "Initializing..." );
251 }
252
253
257 }
258
259
263 }
264
267 }
268
271 }
272
275 }
276
277 if (!
quiet) printf(
"\n" );
278
280
281
282 if ( inner ) {
283
284 if (double_precision) {
285 xd = malloc(
INDEX5 *
sizeof(
double) );
286 yd = malloc(
INDEX5 *
sizeof(
double) );
287 if ( !( xd && yd ) )
289 }
290 else {
291 x = malloc(
INDEX5 *
sizeof(
float) );
292 y = malloc(
INDEX5 *
sizeof(
float) );
295 }
296
299
300
301 for ( n = 0; n <
INDEX5; n++ ) {
302 if ( n <
INDEX1 || ( ( n + 1 ) % 50 ) == 0 ) {
303
304
305 if ( double_precision ) {
306 for (
i = 0;
i <= n;
i++ ) {
307 xd[
i] = ( double ) rand( ) * ( double ) 1.1;
308 yd[
i] = ( double ) rand( ) * ( double ) 1.1;
309 }
310 } else {
311 for (
i = 0;
i <= n;
i++ ) {
312 x[
i] = ( float ) rand( ) * ( float ) 1.1;
313 y[
i] = ( float ) rand( ) * ( float ) 1.1;
314 }
315 }
316
317
319
320
321 if ( double_precision ) {
323 dummy( (
void * ) &aad );
324 } else {
327 }
329 }
330 }
331 }
332 if (double_precision) {
333 free( xd );
334 free( yd );
335 } else {
338 }
339 }
340
341
343
344 if (double_precision) {
346 xd = malloc(
INDEX5 *
sizeof(
double) );
347 yd = malloc(
INDEX5 *
sizeof(
double) );
348 if ( !( ad && xd && yd ) )
350 } else {
352 x = malloc(
INDEX5 *
sizeof(
float) );
353 y = malloc(
INDEX5 *
sizeof(
float) );
354 if ( !(
a &&
x &&
y ) )
356 }
357
360
361
362 for ( n = 0; n <
INDEX5; n++ ) {
363 if ( n <
INDEX1 || ( ( n + 1 ) % 50 ) == 0 ) {
364
365
366 if ( double_precision ) {
367 for (
i = 0;
i <= n;
i++ ) {
369 xd[
i] = ( double ) rand( ) * ( double ) 1.1;
370 for ( j = 0; j <= n; j++ )
372 ( double ) rand( ) * ( double ) 1.1;
373 }
374 } else {
375 for (
i = 0;
i <= n;
i++ ) {
377 x[
i] = ( float ) rand( ) * ( float ) 1.1;
378 for ( j = 0; j <= n; j++ )
380 ( float ) rand( ) * ( float ) 1.1;
381 }
382 }
383
384
386
387
388 if ( double_precision ) {
390 dummy( (
void * ) yd );
391 } else {
394 }
396 }
397 }
398 }
399 if (double_precision) {
400 free( ad );
401 free( xd );
402 free( yd );
403 } else {
407 }
408 }
409
410
412
413 if (double_precision) {
417 if ( !( ad && bd && cd ) )
419 } else {
423 if ( !(
a &&
b &&
c ) )
425 }
426
427
430
431
432 for ( n = 0; n <
INDEX5; n++ ) {
433 if ( n <
INDEX1 || ( ( n + 1 ) % 50 ) == 0 ) {
434
435
436 if ( double_precision ) {
437 for (
i = 0;
i <= n * n + n;
i++ ) {
439 ad[
i] = ( double ) rand( ) * ( double ) 1.1;
440 bd[
i] = ( double ) rand( ) * ( double ) 1.1;
441 }
442 } else {
443 for (
i = 0;
i <= n * n + n;
i++ ) {
445 a[
i] = ( float ) rand( ) * ( float ) 1.1;
446 b[
i] = ( float ) rand( ) * ( float ) 1.1;
447 }
448 }
449
450
452
453
454 if ( double_precision ) {
457 } else {
460 }
462 }
463 }
464 }
465 if (double_precision) {
466 free( ad );
467 free( bd );
468 free( cd );
469 } else {
473 }
474 }
475
476
479 }
480
482
483 return 0;
484}
static void reset_flops(const char *title, int EventSet)
static void matrix_single(int n, float *c, float *a, float *b)
static void matrix_double(int n, double *c, double *a, double *b)
static void resultline(int i, int j, int EventSet, int fail, int quiet)
static float inner_single(int n, float *x, float *y)
static void headerlines(const char *title, int quiet)
static double inner_double(int n, double *x, double *y)
static void vector_single(int n, float *a, float *x, float *y)
static void vector_double(int n, double *a, double *x, double *y)
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Convert a name to a numeric hardware event code.
initialize the PAPI library.
Query if PAPI event exists.
static double a[MATRIX_SIZE][MATRIX_SIZE]
static double b[MATRIX_SIZE][MATRIX_SIZE]
static double c[MATRIX_SIZE][MATRIX_SIZE]
static void print_help(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)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)