zero_smp.c File Reference

Include dependency graph for zero_smp.c:

Go to the source code of this file.

Functions

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

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 103 of file zero_smp.c.

00104 {
00105     int i, retval;
00106     long long elapsed_us, elapsed_cyc;
00107 
00108     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00109 
00110     retval = PAPI_library_init( PAPI_VER_CURRENT );
00111     if ( retval != PAPI_VER_CURRENT )
00112         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00113 
00114     elapsed_us = PAPI_get_real_usec(  );
00115 
00116     elapsed_cyc = PAPI_get_real_cyc(  );
00117 
00118 #if defined(_AIX)
00119     retval =
00120         PAPI_thread_init( ( unsigned long ( * )( void ) ) ( pthread_self ) );
00121     if ( retval != PAPI_OK ) {
00122         if ( retval == PAPI_ECMP )
00123             test_skip( __FILE__, __LINE__, "PAPI_thread_init", retval );
00124         else
00125             test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
00126     }
00127 #pragma ibm parallel_loop
00128 #elif defined(sgi) && defined(mips)
00129     retval =
00130         PAPI_thread_init( ( unsigned long ( * )( void ) ) ( mp_my_threadnum ) );
00131     if ( retval != PAPI_OK ) {
00132         test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
00133     }
00134 #pragma parallel
00135 #pragma local(i)
00136 #pragma pfor
00137 #elif defined(sun) && defined(sparc)
00138     retval = PAPI_thread_init( ( unsigned long ( * )( void ) ) ( thr_self ) );
00139     if ( retval != PAPI_OK ) {
00140         test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
00141     }
00142 #pragma MP taskloop private(i)
00143 #else
00144     test_skip(__FILE__, __LINE__, "Architecture not included in this test file yet.", 0);
00145 #endif
00146     for ( i = 1; i < 3; i++ )
00147         Thread( i, 10000000 * i );
00148 
00149     elapsed_cyc = PAPI_get_real_cyc(  ) - elapsed_cyc;
00150 
00151     elapsed_us = PAPI_get_real_usec(  ) - elapsed_us;
00152 
00153     if ( !TESTS_QUIET ) {
00154         printf( "Master real usec   : \t%lld\n", elapsed_us );
00155         printf( "Master real cycles : \t%lld\n", elapsed_cyc );
00156     }
00157     test_pass( __FILE__, NULL, 0 );
00158     exit( 1 );
00159 }

Here is the call graph for this function:

void Thread ( int  t,
int  n 
)

Definition at line 46 of file zero_smp.c.

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

Here is the call graph for this function:


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1