{
float real_time, proc_time, mflops;
long long flpins;
int retval;
int i, j, k, fip = 0;
tests_quiet( argc, argv );
retval = PAPI_library_init( PAPI_VER_CURRENT );
if ( retval != PAPI_VER_CURRENT )
test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
if ( PAPI_query_event( PAPI_FP_INS ) == PAPI_OK )
fip = 1;
else if ( PAPI_query_event( PAPI_FP_OPS ) == PAPI_OK )
fip = 2;
else {
if ( !TESTS_QUIET )
printf
( "PAPI_FP_INS and PAPI_FP_OPS are not defined for this platform.\n" );
}
PAPI_shutdown( );
if ( fip > 0 ) {
for ( i = 0; i < INDEX; i++ ) {
for ( j = 0; j < INDEX; j++) {
mresult[j][i] = 0.0;
matrixa[j][i] = matrixb[j][i] = ( float ) rand( ) * ( float ) 1.1;
}
}
if ( fip == 1 ) {
if ( ( retval =
PAPI_flips( &real_time, &proc_time, &flpins,
&mflops ) ) < PAPI_OK )
test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
} else {
if ( ( retval =
PAPI_flops( &real_time, &proc_time, &flpins,
&mflops ) ) < PAPI_OK )
test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
}
for ( i = 0; i < INDEX; i++ )
for ( j = 0; j < INDEX; j++ )
for ( k = 0; k < INDEX; k++ )
mresult[i][j] =
mresult[i][j] + matrixa[i][k] * matrixb[k][j];
if ( fip == 1 ) {
if ( ( retval =
PAPI_flips( &real_time, &proc_time, &flpins,
&mflops ) ) < PAPI_OK )
test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
} else {
if ( ( retval =
PAPI_flops( &real_time, &proc_time, &flpins,
&mflops ) ) < PAPI_OK )
test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
}
dummy( ( void * ) mresult );
if ( !TESTS_QUIET ) {
if ( fip == 1 ) {
printf( "Real_time: %f Proc_time: %f Total flpins: ", real_time,
proc_time );
} else {
printf( "Real_time: %f Proc_time: %f Total flpops: ", real_time,
proc_time );
}
printf( LLDFMT, flpins );
printf( " MFLOPS: %f\n", mflops );
}
}
test_pass( __FILE__, NULL, 0 );
exit( 1 );
}