PAPI  5.0.1.0
high-level.c File Reference
Include dependency graph for high-level.c:

Go to the source code of this file.

Defines

#define NUM_EVENTS   2

Functions

int main (int argc, char **argv)

Variables

int TESTS_QUIET

Define Documentation

#define NUM_EVENTS   2

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 16 of file high-level.c.

{
#define NUM_EVENTS 2
    int retval;
    long long values[NUM_EVENTS], dummyvalues[NUM_EVENTS];
    long long myvalues[NUM_EVENTS];
    int Events[NUM_EVENTS];

    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 );

    /* query and set up the right events to monitor */
    if ( PAPI_query_event( PAPI_FP_INS ) == PAPI_OK ) {
        Events[0] = PAPI_FP_INS;
    } else {
        Events[0] = PAPI_TOT_INS;
    }
    Events[1] = PAPI_TOT_CYC;

    retval = PAPI_start_counters( ( int * ) Events, NUM_EVENTS );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_start_counters", retval );

    /* Loop 1 */
    do_flops( NUM_FLOPS );

    retval = PAPI_read_counters( values, NUM_EVENTS );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval );

    if ( !TESTS_QUIET )
        printf( TWO12, values[0], values[1], "(Counters continuing...)\n" );

    myvalues[0] = values[0];
    myvalues[1] = values[1];
    /* Loop 2 */
    do_flops( NUM_FLOPS );

    retval = PAPI_accum_counters( values, NUM_EVENTS );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_accum_counters", retval );

    if ( !TESTS_QUIET )
        printf( TWO12, values[0], values[1], "(Counters being ''held'')\n" );

    /* Loop 3 */
    /* Simulated code that should not be counted */
    do_flops( NUM_FLOPS );

    retval = PAPI_read_counters( dummyvalues, NUM_EVENTS );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval );
    if ( !TESTS_QUIET )
        printf( TWO12, dummyvalues[0], dummyvalues[1], "(Skipped counts)\n" );

    if ( !TESTS_QUIET )
        printf( "%12s %12s  (''Continuing'' counting)\n", "xxx", "xxx" );
    /* Loop 4 */
    do_flops( NUM_FLOPS );

    retval = PAPI_accum_counters( values, NUM_EVENTS );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_accum_counters", retval );

    if ( !TESTS_QUIET )
        printf( TWO12, values[0], values[1], "" );

    if ( !TESTS_QUIET ) {
        printf( "----------------------------------\n" );
        printf( "Verification: The last line in each experiment should be\n" );
        printf( "approximately three times the value of the first line.\n" );
    }

    {
        long long min, max;
        min = ( long long ) ( ( double ) myvalues[0] * .9 );
        max = ( long long ) ( ( double ) myvalues[0] * 1.1 );
        if ( values[0] < ( 3 * min ) || values[0] > ( 3 * max ) ) {
            retval = 1;
            if ( PAPI_query_event( PAPI_FP_INS ) == PAPI_OK ) {
                test_fail( __FILE__, __LINE__, "PAPI_FP_INS", 1 );
            } else {
                test_fail( __FILE__, __LINE__, "PAPI_TOT_INS", 1 );
            }
        }
        min = ( long long ) ( ( double ) myvalues[1] * .9 );
        max = ( long long ) ( ( double ) myvalues[1] * 1.1 );
        if ( values[1] < ( 3 * min ) || values[1] > ( 3 * max ) ) {
            retval = 1;
            test_fail( __FILE__, __LINE__, "PAPI_TOT_CYC", 1 );
        }
    }
    /* The values array is not allocated through allocate_test_space 
     * so we need to pass NULL here */
    test_pass( __FILE__, NULL, NUM_EVENTS );
    exit( 1 );
}

Here is the call graph for this function:


Variable Documentation

Definition at line 11 of file test_utils.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines