PAPI  5.6.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 34 of file overflow3_pthreads.c.

35 {
36  ( void ) overflow_vector;
37  ( void ) context;
38  if ( !TESTS_QUIET ) {
39  fprintf( stderr, "handler(%d ) Overflow at %p, thread %#lx!\n",
40  EventSet, address, PAPI_thread_id( ) );
41  }
42  total++;
43 }
unsigned long PAPI_thread_id(void)
Definition: papi.c:162
int EventSet
void
Definition: iozone.c:18627
int TESTS_QUIET
Definition: test_utils.c:18
static int total
Definition: rapl_overflow.c:9

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 120 of file overflow3_pthreads.c.

121 {
122  int i, rc, retval;
124  pthread_attr_t attr;
125  int quiet;
126 
127  /* Set TESTS_QUIET variable */
128  quiet=tests_quiet( argc, argv );
129 
130  if (!quiet) {
131  printf( "%s: Using %d threads\n\n", argv[0], NUM_THREADS );
132  printf( "Does non-threaded overflow work "
133  "with extraneous threads present?\n" );
134  }
135 
136  pthread_attr_init( &attr );
137 #ifdef PTHREAD_CREATE_UNDETACHED
138  pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_UNDETACHED );
139 #endif
140 #ifdef PTHREAD_SCOPE_SYSTEM
141  retval = pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM );
142  if ( retval != 0 )
143  test_skip( __FILE__, __LINE__, "pthread_attr_setscope", retval );
144 #endif
145 
146  for ( i = 0; i < NUM_THREADS; i++ ) {
147  rc = pthread_create( &id[i], &attr, thread_fn, NULL );
148  if ( rc )
149  test_fail( __FILE__, __LINE__, "pthread_create", rc );
150  }
151  pthread_attr_destroy( &attr );
152 
153  mainloop( NUM_ITERS );
154 
155  test_pass( __FILE__ );
156 
157  return 0;
158 }
#define NUM_THREADS
Definition: do_loops.h:8
void test_pass(const char *filename)
Definition: test_utils.c:432
#define NUM_ITERS
Definition: multiplex.c:19
int int argc
Definition: iozone.c:1609
int rc
Definition: iozone.c:20281
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
void * thread_fn(void *dummy)
int i
Definition: fileop.c:140
int quiet
Definition: rapl_overflow.c:18
pthread_t
Definition: iozone.c:18557
printf("\tTry: -i 0 -i 1 \n\n")
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
ssize_t retval
Definition: libasync.c:338
void mainloop(int arg)
pthread_attr_t attr
Definition: iozone.c:18466

Here is the call graph for this function:

void mainloop ( int  arg)

Definition at line 46 of file overflow3_pthreads.c.

47 {
48  int retval, num_tests = 1;
49  int EventSet1 = PAPI_NULL;
50  int mask1 = 0x0;
51  int num_events1;
52  long long **values;
53  int PAPI_event;
55 
56  ( void ) arg;
57 
59  if (retval != PAPI_VER_CURRENT ) {
60  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
61  }
62 
63  /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or
64  PAPI_TOT_INS, depending on the availability of the event on the
65  platform */
66  EventSet1 = add_two_nonderived_events( &num_events1,
67  &PAPI_event, &mask1 );
68 
69  if (num_events1==0) {
70  if (!TESTS_QUIET) printf("Trouble creating events\n");
71  test_skip(__FILE__,__LINE__,"Creating events",0);
72  }
73 
74  values = allocate_test_space( num_tests, num_events1 );
75 
76  if ( ( retval =
77  PAPI_overflow( EventSet1, PAPI_event, THRESHOLD, 0,
78  handler ) ) != PAPI_OK )
79  test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
80 
81  do_stuff( );
82 
83  if ( ( retval = PAPI_start( EventSet1 ) ) != PAPI_OK )
84  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
85 
86  do_stuff( );
87 
88  if ( ( retval = PAPI_stop( EventSet1, values[0] ) ) != PAPI_OK )
89  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
90 
91  /* clear the papi_overflow event */
92  if ( ( retval =
93  PAPI_overflow( EventSet1, PAPI_event, 0, 0, NULL ) ) != PAPI_OK )
94  test_fail( __FILE__, __LINE__, "PAPI_overflow", retval );
95 
96  if ( ( retval =
97  PAPI_event_code_to_name( PAPI_event, event_name ) ) != PAPI_OK )
98  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
99 
100  if ( !TESTS_QUIET ) {
101  printf( "Thread %#x %s : \t%lld\n", ( int ) pthread_self( ),
102  event_name, ( values[0] )[0] );
103  printf( "Thread %#x PAPI_TOT_CYC: \t%lld\n", ( int ) pthread_self( ),
104  ( values[0] )[1] );
105  }
106 
107  retval = PAPI_cleanup_eventset( EventSet1 );
108  if ( retval != PAPI_OK )
109  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
110 
111  retval = PAPI_destroy_eventset( &EventSet1 );
112  if ( retval != PAPI_OK )
113  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
114 
115  free_test_space( values, num_tests );
116  PAPI_shutdown( );
117 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int mask1
Definition: zero_fork.c:48
int PAPI_event[2]
Definition: data_range.c:30
#define PAPI_NULL
Definition: papi.h:292
int num_events1
Definition: zero_fork.c:49
void do_stuff(void)
Definition: do_loops.c:256
return PAPI_OK
Definition: linux-nvml.c:497
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
Definition: papi.c:4788
void
Definition: iozone.c:18627
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
int PAPI_library_init(int version)
Definition: papi.c:500
void PAPI_shutdown(void)
Definition: papi.c:4461
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:70
void handler(int EventSet, void *address, long long overflow_vector, void *context)
Definition: rapl_overflow.c:20
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2890
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
int num_tests
Definition: zero_fork.c:53
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:2014
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:646
int PAPI_start(int EventSet)
Definition: papi.c:2096
#define THRESHOLD
Definition: earprofile.c:37
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:46
#define PAPI_VER_CURRENT
Definition: papi.h:225
int EventSet1
Definition: zero_fork.c:47

Here is the call graph for this function:

Here is the caller graph for this function:

void* thread_fn ( void dummy)

Definition at line 24 of file overflow3_pthreads.c.

25 {
26  ( void ) dummy;
27  while ( 1 ) {
28  do_stuff( );
29  }
30  return ( NULL );
31 }
void do_stuff(void)
Definition: do_loops.c:256
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 21 of file overflow3_pthreads.c.