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.

00117 {
00118     int retval;
00119     long long elapsed_us, elapsed_cyc;
00120 
00121     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00122 
00123     retval = PAPI_library_init( PAPI_VER_CURRENT );
00124     if ( retval != PAPI_VER_CURRENT )
00125         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00126 
00127     hw_info = PAPI_get_hardware_info(  );
00128     if ( hw_info == NULL )
00129         test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
00130 
00131     elapsed_us = PAPI_get_real_usec(  );
00132 
00133     elapsed_cyc = PAPI_get_real_cyc(  );
00134 
00135 
00136     retval =
00137         PAPI_thread_init( ( unsigned
00138                             long ( * )( void ) ) ( omp_get_thread_num ) );
00139     if ( retval != PAPI_OK ) {
00140         if ( retval == PAPI_ECMP )
00141             test_skip( __FILE__, __LINE__, "PAPI_thread_init", retval );
00142         else
00143             test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
00144     }
00145 #pragma omp parallel
00146     {
00147         Thread( 1000000 * ( omp_get_thread_num(  ) + 1 ) );
00148     }
00149     omp_set_num_threads( 1 );
00150     Thread( 1000000 * ( omp_get_thread_num(  ) + 1 ) );
00151     omp_set_num_threads( omp_get_max_threads(  ) );
00152 #pragma omp parallel
00153     {
00154         Thread( 1000000 * ( omp_get_thread_num(  ) + 1 ) );
00155     }
00156 
00157     elapsed_cyc = PAPI_get_real_cyc(  ) - elapsed_cyc;
00158 
00159     elapsed_us = PAPI_get_real_usec(  ) - elapsed_us;
00160 
00161     if ( !TESTS_QUIET ) {
00162         printf( "Master real usec   : \t%lld\n", elapsed_us );
00163         printf( "Master real cycles : \t%lld\n", elapsed_cyc );
00164     }
00165 
00166     test_pass( __FILE__, NULL, 0 );
00167     exit( 0 );
00168 }

Here is the call graph for this function:

void Thread ( int  n  ) 

Definition at line 51 of file zero_omp.c.

00052 {
00053     int retval, num_tests = 1;
00054     int EventSet1 = PAPI_NULL;
00055     int PAPI_event, mask1;
00056     int num_events1;
00057     long long **values;
00058     long long elapsed_us, elapsed_cyc;
00059     char event_name[PAPI_MAX_STR_LEN];
00060 
00061     printf( "Thread %#x started\n", omp_get_thread_num(  ) );
00062     num_events1 = 2;
00063 
00064     /* add PAPI_TOT_CYC and one of the events in 
00065        PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS, 
00066        depending on the availability of the event 
00067        on the platform */
00068     EventSet1 = add_two_events( &num_events1, &PAPI_event, &mask1 );
00069 
00070     retval = PAPI_event_code_to_name( PAPI_event, event_name );
00071     if ( retval != PAPI_OK )
00072         test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
00073 
00074     values = allocate_test_space( num_tests, num_events1 );
00075 
00076     elapsed_us = PAPI_get_real_usec(  );
00077 
00078     elapsed_cyc = PAPI_get_real_cyc(  );
00079 
00080     retval = PAPI_start( EventSet1 );
00081     if ( retval != PAPI_OK )
00082         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00083 
00084     do_flops( n );
00085 
00086     retval = PAPI_stop( EventSet1, values[0] );
00087     if ( retval != PAPI_OK )
00088         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00089 
00090     elapsed_us = PAPI_get_real_usec(  ) - elapsed_us;
00091 
00092     elapsed_cyc = PAPI_get_real_cyc(  ) - elapsed_cyc;
00093 
00094     remove_test_events( &EventSet1, mask1 );
00095 
00096     if ( !TESTS_QUIET ) {
00097         printf( "Thread %#x %-12s : \t%lld\n", omp_get_thread_num(  ),
00098                 event_name, values[0][1] );
00099         printf( "Thread %#x PAPI_TOT_CYC: \t%lld\n", omp_get_thread_num(  ),
00100                 values[0][0] );
00101         printf( "Thread %#x Real usec   : \t%lld\n", omp_get_thread_num(  ),
00102                 elapsed_us );
00103         printf( "Thread %#x Real cycles : \t%lld\n", omp_get_thread_num(  ),
00104                 elapsed_cyc );
00105     }
00106 
00107     /* It is illegal for the threads to exit in OpenMP */
00108     /* test_pass(__FILE__,0,0); */
00109     free_test_space( values, num_tests );
00110 
00111     PAPI_unregister_thread(  );
00112     printf( "Thread %#x finished\n", omp_get_thread_num(  ) );
00113 }

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.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1