PAPI  5.0.1.0
mendes-alt.c File Reference
Include dependency graph for mendes-alt.c:

Go to the source code of this file.

Defines

#define MAX   10000
#define TIMES   1000
#define PAPI_MAX_EVENTS   2

Functions

int main (int argc, argv)
void funcX (a, b, int n)
void funcA (a, b, int n)

Variables

long long PAPI_values1 [2]
long long PAPI_values2 [2]
long long PAPI_values3 [2]
static int EventSet = PAPI_NULL
int TESTS_QUIET

Define Documentation

#define MAX   10000

Definition at line 9 of file mendes-alt.c.

#define PAPI_MAX_EVENTS   2

Definition at line 13 of file mendes-alt.c.

#define TIMES   1000

Definition at line 11 of file mendes-alt.c.


Function Documentation

void funcA ( a  ,
b  ,
int  n 
)

Definition at line 173 of file mendes-alt.c.

{
    int i, k;
    double t[MAX];
    for ( k = 0; k < TIMES; k++ )
        for ( i = 0; i < n; i++ ) {
            t[i] = b[n - i];
            b[i] = a[n - i];
            a[i] = t[i];
        }
}

Here is the caller graph for this function:

void funcX ( a  ,
b  ,
int  n 
)

Definition at line 162 of file mendes-alt.c.

{
    int i, k;
    for ( k = 0; k < TIMES; k++ )
        for ( i = 0; i < n; i++ )
            a[i] = a[i] * b[i] + 1.;
}

Here is the caller graph for this function:

int main ( int  argc,
argv   
)

Definition at line 22 of file mendes-alt.c.

{
    int i, retval;
    double a[MAX], b[MAX];
    void funcX(  ), funcA(  );

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

    for ( i = 0; i < MAX; i++ ) {
        a[i] = 0.0;
        b[i] = 0.;
    }

    for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
        PAPI_values1[i] = PAPI_values2[i] = 0;

    retval = PAPI_library_init( PAPI_VER_CURRENT );
    if ( retval != PAPI_VER_CURRENT )
        test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );

#ifdef MULTIPLEX
    if ( !TESTS_QUIET ) {
        printf( "Activating PAPI Multiplex\n" );
    }
    init_multiplex(  );
#endif

    retval = PAPI_create_eventset( &EventSet );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI set event fail\n", retval );

#ifdef MULTIPLEX
    /* In Component PAPI, EventSets must be assigned a component index
       before you can fiddle with their internals.
       0 is always the cpu component */
    retval = PAPI_assign_eventset_component( EventSet, 0 );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component",
                   retval );

    retval = PAPI_set_multiplex( EventSet );
        if (retval == PAPI_ENOSUPP) {
       test_skip( __FILE__, __LINE__, "Multiplex not supported", 1 );
    }
    else if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_set_multiplex fails \n", retval );
#endif

    retval = PAPI_add_event( EventSet, PAPI_FP_INS );
    if ( retval < PAPI_OK ) {
        retval = PAPI_add_event( EventSet, PAPI_TOT_INS );
        if ( retval < PAPI_OK )
            test_fail( __FILE__, __LINE__,
                       "PAPI add PAPI_FP_INS or PAPI_TOT_INS fail\n", retval );
        else if ( !TESTS_QUIET ) {
            printf( "PAPI_TOT_INS\n" );
        }
    } else if ( !TESTS_QUIET ) {
        printf( "PAPI_FP_INS\n" );
    }

    retval = PAPI_add_event( EventSet, PAPI_TOT_CYC );
    if ( retval < PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI add PAPI_TOT_CYC  fail\n",
                   retval );
    if ( !TESTS_QUIET ) {
        printf( "PAPI_TOT_CYC\n" );
    }

    retval = PAPI_start( EventSet );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI start fail\n", retval );

    funcX( a, b, MAX );

    retval = PAPI_read( EventSet, PAPI_values1 );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );

    funcX( a, b, MAX );

    retval = PAPI_read( EventSet, PAPI_values2 );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );

#ifdef RESET
    retval = PAPI_reset( EventSet );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );
#endif

    funcA( a, b, MAX );

    retval = PAPI_stop( EventSet, PAPI_values3 );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI read fail \n", retval );

    if ( !TESTS_QUIET ) {
        printf( "values1 is:\n" );
        for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
            printf( LLDFMT15, PAPI_values1[i] );

        printf( "\nvalues2 is:\n" );
        for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
            printf( LLDFMT15, PAPI_values2[i] );
        printf( "\nvalues3 is:\n" );
        for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
            printf( LLDFMT15, PAPI_values3[i] );

#ifndef RESET
        printf( "\nPAPI value (2-1) is : \n" );
        for ( i = 0; i < PAPI_MAX_EVENTS; i++ )
            printf( LLDFMT15, PAPI_values2[i] - PAPI_values1[i] );
        printf( "\nPAPI value (3-2) is : \n" );
        for ( i = 0; i < PAPI_MAX_EVENTS; i++ ) {
          long long diff;
                  diff = PAPI_values3[i] - PAPI_values2[i];
          printf( LLDFMT15, diff);
          if (diff<0) {
            test_fail( __FILE__, __LINE__, "Multiplexed counter decreased", 1 );
          }
        }
#endif

        printf( "\n\nVerification:\n" );
        printf( "From start to first PAPI_read %d fp operations are made.\n",
                2 * MAX * TIMES );
        printf( "Between 1st and 2nd PAPI_read %d fp operations are made.\n",
                2 * MAX * TIMES );
        printf( "Between 2nd and 3rd PAPI_read %d fp operations are made.\n",
                0 );
        printf( "\n" );
    }
    test_pass( __FILE__, NULL, 0 );
    exit( 1 );
}

Here is the call graph for this function:


Variable Documentation

int EventSet = PAPI_NULL [static]

Definition at line 17 of file mendes-alt.c.

long long PAPI_values1[2]

Definition at line 14 of file mendes-alt.c.

long long PAPI_values2[2]

Definition at line 15 of file mendes-alt.c.

long long PAPI_values3[2]

Definition at line 16 of file mendes-alt.c.

Definition at line 11 of file test_utils.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines