overflow3_pthreads.c File Reference

Include dependency graph for overflow3_pthreads.c:

Go to the source code of this file.

Functions

void * thread_fn (void *dummy)
void handler (int EventSet, void *address, long long overflow_vector, void *context)
void mainloop (int arg)
int main (int argc, char **argv)

Variables

int total = 0

Function Documentation

void handler ( int  EventSet,
void *  address,
long long  overflow_vector,
void *  context 
)

Definition at line 31 of file overflow3_pthreads.c.

00032 {
00033     ( void ) overflow_vector;
00034     ( void ) context;
00035     if ( !TESTS_QUIET ) {
00036         fprintf( stderr, "handler(%d ) Overflow at %p, thread %#lx!\n",
00037                  EventSet, address, PAPI_thread_id(  ) );
00038     }
00039     total++;
00040 }

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 112 of file overflow3_pthreads.c.

00113 {
00114     int i, rc, retval;
00115     pthread_t id[NUM_THREADS];
00116     pthread_attr_t attr;
00117 
00118     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00119 
00120     printf( "%s: Using %d threads\n\n", argv[0], NUM_THREADS );
00121     printf
00122         ( "Does non-threaded overflow work with extraneous threads present?\n" );
00123 
00124     pthread_attr_init( &attr );
00125 #ifdef PTHREAD_CREATE_UNDETACHED
00126     pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_UNDETACHED );
00127 #endif
00128 #ifdef PTHREAD_SCOPE_SYSTEM
00129     retval = pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM );
00130     if ( retval != 0 )
00131         test_skip( __FILE__, __LINE__, "pthread_attr_setscope", retval );
00132 #endif
00133 
00134     for ( i = 0; i < NUM_THREADS; i++ ) {
00135         rc = pthread_create( &id[i], &attr, thread_fn, NULL );
00136         if ( rc )
00137             test_fail( __FILE__, __LINE__, "pthread_create", rc );
00138     }
00139     pthread_attr_destroy( &attr );
00140 
00141     mainloop( NUM_ITERS );
00142 
00143     test_pass( __FILE__, NULL, 0 );
00144     exit( 1 );
00145 }

Here is the call graph for this function:

void mainloop ( int  arg  ) 

Definition at line 43 of file overflow3_pthreads.c.

00044 {
00045     int retval, num_tests = 1;
00046     int EventSet1 = PAPI_NULL;
00047     int mask1 = 0x0;
00048     int num_events1;
00049     long long **values;
00050     int PAPI_event;
00051     char event_name[PAPI_MAX_STR_LEN];
00052 
00053     ( void ) arg;
00054 
00055     if ( ( retval =
00056            PAPI_library_init( PAPI_VER_CURRENT ) ) != PAPI_VER_CURRENT )
00057         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00058 
00059 
00060     /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or
00061        PAPI_TOT_INS, depending on the availability of the event on the
00062        platform */
00063     EventSet1 =
00064         add_two_nonderived_events( &num_events1, &PAPI_event, &mask1 );
00065 
00066     values = allocate_test_space( num_tests, num_events1 );
00067 
00068     if ( ( retval =
00069            PAPI_overflow( EventSet1, PAPI_event, THRESHOLD, 0,
00070                           handler ) ) != PAPI_OK )
00071         test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
00072 
00073     do_stuff(  );
00074 
00075     if ( ( retval = PAPI_start( EventSet1 ) ) != PAPI_OK )
00076         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00077 
00078     do_stuff(  );
00079 
00080     if ( ( retval = PAPI_stop( EventSet1, values[0] ) ) != PAPI_OK )
00081         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00082 
00083     /* clear the papi_overflow event */
00084     if ( ( retval =
00085            PAPI_overflow( EventSet1, PAPI_event, 0, 0, NULL ) ) != PAPI_OK )
00086         test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
00087 
00088     if ( ( retval =
00089            PAPI_event_code_to_name( PAPI_event, event_name ) ) != PAPI_OK )
00090         test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
00091 
00092     if ( !TESTS_QUIET ) {
00093         printf( "Thread %#x %s : \t%lld\n", ( int ) pthread_self(  ),
00094                 event_name, ( values[0] )[0] );
00095         printf( "Thread %#x PAPI_TOT_CYC: \t%lld\n", ( int ) pthread_self(  ),
00096                 ( values[0] )[1] );
00097     }
00098 
00099     retval = PAPI_cleanup_eventset( EventSet1 );
00100     if ( retval != PAPI_OK )
00101         test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
00102 
00103     retval = PAPI_destroy_eventset( &EventSet1 );
00104     if ( retval != PAPI_OK )
00105         test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
00106 
00107     free_test_space( values, num_tests );
00108     PAPI_shutdown(  );
00109 }

Here is the call graph for this function:

void* thread_fn ( void *  dummy  ) 

Definition at line 21 of file overflow3_pthreads.c.

00022 {
00023     ( void ) dummy;
00024     while ( 1 ) {
00025         do_stuff(  );
00026     }
00027     return ( NULL );
00028 }

Here is the call graph for this function:


Variable Documentation

int total = 0

Definition at line 18 of file overflow3_pthreads.c.


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1