flops.c File Reference

Include dependency graph for flops.c:

Go to the source code of this file.

Defines

#define INDEX   1000

Functions

void dummy (void *)
int main (int argc, char **argv)

Variables

char format_string []
int TESTS_QUIET
float matrixa [INDEX][INDEX]
float matrixb [INDEX][INDEX]
float mresult [INDEX][INDEX]

Define Documentation

#define INDEX   1000

Definition at line 10 of file flops.c.


Function Documentation

void dummy ( void *   ) 

Definition at line 4 of file dummy.c.

00005 {
00006 /* Confuse the compiler so as not to optimize
00007    away the flops in the calling routine    */
00008 /* Cast the array as a void to eliminate unused argument warning */
00009     ( void ) array;
00010 }

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 20 of file flops.c.

00021 {
00022     float real_time, proc_time, mflops;
00023     long long flpins;
00024     int retval;
00025     int i, j, k, fip = 0;
00026 
00027     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00028 
00029     retval = PAPI_library_init( PAPI_VER_CURRENT );
00030     if ( retval != PAPI_VER_CURRENT )
00031         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00032 
00033     if ( PAPI_query_event( PAPI_FP_INS ) == PAPI_OK )
00034         fip = 1;
00035     else if ( PAPI_query_event( PAPI_FP_OPS ) == PAPI_OK )
00036         fip = 2;
00037     else {
00038         if ( !TESTS_QUIET )
00039             printf
00040                 ( "PAPI_FP_INS and PAPI_FP_OPS are not defined for this platform.\n" );
00041     }
00042 
00043     PAPI_shutdown(  );
00044 
00045     if ( fip > 0 ) {
00046         /* Initialize the Matrix arrays */
00047         for ( i = 0; i < INDEX; i++ ) {
00048           for ( j = 0; j < INDEX; j++) {
00049             mresult[j][i] = 0.0;
00050             matrixa[j][i] = matrixb[j][i] = ( float ) rand(  ) * ( float ) 1.1;
00051           }
00052         }
00053 
00054         /* Setup PAPI library and begin collecting data from the counters */
00055         if ( fip == 1 ) {
00056             if ( ( retval =
00057                    PAPI_flips( &real_time, &proc_time, &flpins,
00058                                &mflops ) ) < PAPI_OK )
00059                 test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
00060         } else {
00061             if ( ( retval =
00062                    PAPI_flops( &real_time, &proc_time, &flpins,
00063                                &mflops ) ) < PAPI_OK )
00064                 test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
00065         }
00066 
00067         /* Matrix-Matrix multiply */
00068         for ( i = 0; i < INDEX; i++ )
00069             for ( j = 0; j < INDEX; j++ )
00070                 for ( k = 0; k < INDEX; k++ )
00071                     mresult[i][j] =
00072                         mresult[i][j] + matrixa[i][k] * matrixb[k][j];
00073 
00074         /* Collect the data into the variables passed in */
00075         if ( fip == 1 ) {
00076             if ( ( retval =
00077                    PAPI_flips( &real_time, &proc_time, &flpins,
00078                                &mflops ) ) < PAPI_OK )
00079                 test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
00080         } else {
00081             if ( ( retval =
00082                    PAPI_flops( &real_time, &proc_time, &flpins,
00083                                &mflops ) ) < PAPI_OK )
00084                 test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
00085         }
00086         dummy( ( void * ) mresult );
00087 
00088         if ( !TESTS_QUIET ) {
00089             if ( fip == 1 ) {
00090                 printf( "Real_time: %f Proc_time: %f Total flpins: ", real_time,
00091                         proc_time );
00092             } else {
00093                 printf( "Real_time: %f Proc_time: %f Total flpops: ", real_time,
00094                         proc_time );
00095             }
00096             printf( LLDFMT, flpins );
00097             printf( " MFLOPS: %f\n", mflops );
00098         }
00099     }
00100     test_pass( __FILE__, NULL, 0 );
00101     exit( 1 );
00102 }

Here is the call graph for this function:


Variable Documentation

char format_string[]
Initial value:
    { "Real_time: %f Proc_time: %f Total flpins: %lld MFLOPS: %f\n" }

Definition at line 12 of file flops.c.

float matrixa[INDEX][INDEX]

Definition at line 18 of file flops.c.

float matrixb[INDEX][INDEX]

Definition at line 18 of file flops.c.

float mresult[INDEX][INDEX]

Definition at line 18 of file flops.c.

Definition at line 11 of file test_utils.c.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1