PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
overflow3_pthreads.c File Reference
Include dependency graph for overflow3_pthreads.c:

Go to the source code of this file.

Functions

voidthread_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.

32 {
33  ( void ) overflow_vector;
34  ( void ) context;
35  if ( !TESTS_QUIET ) {
36  fprintf( stderr, "handler(%d ) Overflow at %p, thread 0x%lux!\n",
37  EventSet, address, PAPI_thread_id( ) );
38  }
39  total++;
40 }
unsigned long PAPI_thread_id(void)
Definition: papi.c:157
void
Definition: iozone.c:18627
int TESTS_QUIET
Definition: test_utils.c:11
int EventSet
static int total
Definition: rapl_overflow.c:5

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 112 of file overflow3_pthreads.c.

113 {
114  int i, rc, retval;
116  pthread_attr_t attr;
117 
118  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
119 
120  printf( "%s: Using %d threads\n\n", argv[0], NUM_THREADS );
121  printf
122  ( "Does non-threaded overflow work with extraneous threads present?\n" );
123 
124  pthread_attr_init( &attr );
125 #ifdef PTHREAD_CREATE_UNDETACHED
126  pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_UNDETACHED );
127 #endif
128 #ifdef PTHREAD_SCOPE_SYSTEM
129  retval = pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM );
130  if ( retval != 0 )
131  test_skip( __FILE__, __LINE__, "pthread_attr_setscope", retval );
132 #endif
133 
134  for ( i = 0; i < NUM_THREADS; i++ ) {
135  rc = pthread_create( &id[i], &attr, thread_fn, NULL );
136  if ( rc )
137  test_fail( __FILE__, __LINE__, "pthread_create", rc );
138  }
139  pthread_attr_destroy( &attr );
140 
141  mainloop( NUM_ITERS );
142 
143  test_pass( __FILE__, NULL, 0 );
144  exit( 1 );
145 }
void mainloop(int arg)
#define NUM_ITERS
Definition: multiplex.c:19
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
char ** argv
Definition: iozone.c:1610
void * thread_fn(void *dummy)
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int i
Definition: fileop.c:140
#define NUM_THREADS
Definition: test_utils.h:8
pthread_t
Definition: iozone.c:18557
int rc
Definition: iozone.c:20281
ssize_t retval
Definition: libasync.c:338
void exit()
pthread_attr_t attr
Definition: iozone.c:18466

Here is the call graph for this function:

void mainloop ( int  arg)

Definition at line 43 of file overflow3_pthreads.c.

44 {
45  int retval, num_tests = 1;
46  int EventSet1 = PAPI_NULL;
47  int mask1 = 0x0;
48  int num_events1;
49  long long **values;
50  int PAPI_event;
52 
53  ( void ) arg;
54 
55  if ( ( retval =
57  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
58 
59 
60  /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or
61  PAPI_TOT_INS, depending on the availability of the event on the
62  platform */
63  EventSet1 =
64  add_two_nonderived_events( &num_events1, &PAPI_event, &mask1 );
65 
66  values = allocate_test_space( num_tests, num_events1 );
67 
68  if ( ( retval =
69  PAPI_overflow( EventSet1, PAPI_event, THRESHOLD, 0,
70  handler ) ) != PAPI_OK )
71  test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
72 
73  do_stuff( );
74 
75  if ( ( retval = PAPI_start( EventSet1 ) ) != PAPI_OK )
76  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
77 
78  do_stuff( );
79 
80  if ( ( retval = PAPI_stop( EventSet1, values[0] ) ) != PAPI_OK )
81  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
82 
83  /* clear the papi_overflow event */
84  if ( ( retval =
85  PAPI_overflow( EventSet1, PAPI_event, 0, 0, NULL ) ) != PAPI_OK )
86  test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
87 
88  if ( ( retval =
89  PAPI_event_code_to_name( PAPI_event, event_name ) ) != PAPI_OK )
90  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
91 
92  if ( !TESTS_QUIET ) {
93  printf( "Thread %#x %s : \t%lld\n", ( int ) pthread_self( ),
94  event_name, ( values[0] )[0] );
95  printf( "Thread %#x PAPI_TOT_CYC: \t%lld\n", ( int ) pthread_self( ),
96  ( values[0] )[1] );
97  }
98 
99  retval = PAPI_cleanup_eventset( EventSet1 );
100  if ( retval != PAPI_OK )
101  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
102 
103  retval = PAPI_destroy_eventset( &EventSet1 );
104  if ( retval != PAPI_OK )
105  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
106 
107  free_test_space( values, num_tests );
108  PAPI_shutdown( );
109 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2225
int mask1
Definition: zero_fork.c:41
int PAPI_event[2]
Definition: data_range.c:24
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
int num_events1
Definition: zero_fork.c:42
void do_stuff(void)
Definition: do_loops.c:249
return PAPI_OK
Definition: linux-nvml.c:458
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
Definition: papi.c:4655
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int TESTS_QUIET
Definition: test_utils.c:11
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
void PAPI_shutdown(void)
Definition: papi.c:4344
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:131
void handler(int EventSet, void *address, long long overflow_vector, void *context)
Definition: rapl_overflow.c:16
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2795
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:920
int num_tests
Definition: zero_fork.c:46
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1937
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:723
int PAPI_start(int EventSet)
Definition: papi.c:2019
#define THRESHOLD
Definition: earprofile.c:31
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:107
int EventSet1
Definition: zero_fork.c:40

Here is the call graph for this function:

void* thread_fn ( void dummy)

Definition at line 21 of file overflow3_pthreads.c.

22 {
23  ( void ) dummy;
24  while ( 1 ) {
25  do_stuff( );
26  }
27  return ( NULL );
28 }
void do_stuff(void)
Definition: do_loops.c:249
void
Definition: iozone.c:18627
int dummy
Definition: iozone.c:19741

Here is the call graph for this function:

Variable Documentation

int total = 0

Definition at line 18 of file overflow3_pthreads.c.