PAPI  5.0.1.0
zero_omp.c File Reference
Include dependency graph for zero_omp.c:

Go to the source code of this file.

Functions

void Thread (int n)
int main (int argc, char **argv)

Variables

const PAPI_hw_info_thw_info = NULL

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 116 of file zero_omp.c.

{
    int maxthr, retval;
    long long elapsed_us, elapsed_cyc;

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

    hw_info = PAPI_get_hardware_info(  );
    if ( hw_info == NULL )
        test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );

    elapsed_us = PAPI_get_real_usec(  );

    elapsed_cyc = PAPI_get_real_cyc(  );


    retval =
        PAPI_thread_init( ( unsigned
                            long ( * )( void ) ) ( omp_get_thread_num ) );
    if ( retval != PAPI_OK ) {
        if ( retval == PAPI_ECMP )
            test_skip( __FILE__, __LINE__, "PAPI_thread_init", retval );
        else
            test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
    }
#pragma omp parallel private(maxthr)
    {
        maxthr = omp_get_num_threads(  );
        Thread( 1000000 * ( omp_get_thread_num(  ) + 1 ) );
    }
    omp_set_num_threads( 1 );
    Thread( 1000000 * ( omp_get_thread_num(  ) + 1 ) );
    omp_set_num_threads( omp_get_max_threads(  ) );
#pragma omp parallel private(maxthr)
    {
        maxthr = omp_get_num_threads(  );
        Thread( 1000000 * ( omp_get_thread_num(  ) + 1 ) );
    }

    elapsed_cyc = PAPI_get_real_cyc(  ) - elapsed_cyc;

    elapsed_us = PAPI_get_real_usec(  ) - elapsed_us;

    if ( !TESTS_QUIET ) {
        printf( "Master real usec   : \t%lld\n", elapsed_us );
        printf( "Master real cycles : \t%lld\n", elapsed_cyc );
    }

    test_pass( __FILE__, NULL, 0 );
    exit( 0 );
}

Here is the call graph for this function:

void Thread ( int  n)

Definition at line 51 of file zero_omp.c.

{
    int retval, num_tests = 1;
    int EventSet1 = PAPI_NULL;
    int PAPI_event, mask1;
    int num_events1;
    long long **values;
    long long elapsed_us, elapsed_cyc;
    char event_name[PAPI_MAX_STR_LEN];

    printf( "Thread 0x%x started\n", omp_get_thread_num(  ) );
    num_events1 = 2;

    /* add PAPI_TOT_CYC and one of the events in 
       PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS, 
       depending on the availability of the event 
       on the platform */
    EventSet1 = add_two_events( &num_events1, &PAPI_event, &mask1 );

    retval = PAPI_event_code_to_name( PAPI_event, event_name );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );

    values = allocate_test_space( num_tests, num_events1 );

    elapsed_us = PAPI_get_real_usec(  );

    elapsed_cyc = PAPI_get_real_cyc(  );

    retval = PAPI_start( EventSet1 );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_start", retval );

    do_flops( n );

    retval = PAPI_stop( EventSet1, values[0] );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_stop", retval );

    elapsed_us = PAPI_get_real_usec(  ) - elapsed_us;

    elapsed_cyc = PAPI_get_real_cyc(  ) - elapsed_cyc;

    remove_test_events( &EventSet1, mask1 );

    if ( !TESTS_QUIET ) {
        printf( "Thread 0x%x %-12s : \t%lld\n", omp_get_thread_num(  ),
                event_name, values[0][1] );
        printf( "Thread 0x%x PAPI_TOT_CYC: \t%lld\n", omp_get_thread_num(  ),
                values[0][0] );
        printf( "Thread 0x%x Real usec   : \t%lld\n", omp_get_thread_num(  ),
                elapsed_us );
        printf( "Thread 0x%x Real cycles : \t%lld\n", omp_get_thread_num(  ),
                elapsed_cyc );
    }

    /* It is illegal for the threads to exit in OpenMP */
    /* test_pass(__FILE__,0,0); */
    free_test_space( values, num_tests );

    PAPI_unregister_thread(  );
    printf( "Thread 0x%x finished\n", omp_get_thread_num(  ) );
}

Here is the call graph for this function:


Variable Documentation

const PAPI_hw_info_t* hw_info = NULL

Definition at line 48 of file zero_omp.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines