PAPI  5.0.1.0
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 [1000][1000]
float matrixb [1000][1000]
float mresult [1000][1000]

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.

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

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 20 of file flops.c.

{
    float real_time, proc_time, mflops;
    long long flpins;
    int retval;
    int i, j, k, fip = 0;

    tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */

    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 ) {
        /* Initialize the Matrix arrays */
        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;
          }
        }

        /* Setup PAPI library and begin collecting data from the counters */
        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 );
        }

        /* Matrix-Matrix multiply */
        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];

        /* Collect the data into the variables passed in */
        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 );
}

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[1000][1000]

Definition at line 18 of file flops.c.

float matrixb[1000][1000]

Definition at line 18 of file flops.c.

float mresult[1000][1000]

Definition at line 18 of file flops.c.

Definition at line 11 of file test_utils.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines