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

Go to the source code of this file.

Macros

#define TOTAL_EVENTS   10
 
#define CPP_TEST_FAIL(string, retval)   test_fail(__FILE__, __LINE__, string, retval)
 

Functions

void init_papi_pthreads (int *out_events, int *len)
 
int do_pthreads (void *(*fn)(void *))
 
voidcase1_pthreads (void *arg)
 
voidcase2_pthreads (void *arg)
 
voidcase3_pthreads (void *arg)
 
voidcase4_pthreads (void *arg)
 
int case1 (void)
 
int case2 (void)
 
int case3 (void)
 
int case4 (void)
 
int main (int argc, char **argv)
 

Variables

int solaris_preset_PAPI_events [TOTAL_EVENTS]
 
int power6_preset_PAPI_events [TOTAL_EVENTS]
 
int preset_PAPI_events [TOTAL_EVENTS]
 
static int PAPI_events [TOTAL_EVENTS] = { 0, }
 
static int PAPI_events_len = 0
 

Macro Definition Documentation

#define CPP_TEST_FAIL (   string,
  retval 
)    test_fail(__FILE__, __LINE__, string, retval)

Definition at line 28 of file multiplex1_pthreads.c.

#define TOTAL_EVENTS   10

Definition at line 14 of file multiplex1_pthreads.c.

Function Documentation

int case1 ( void  )

Definition at line 379 of file multiplex1_pthreads.c.

380 {
381  int retval;
382 
383  PAPI_events_len = 2;
385 
386  retval = do_pthreads( case1_pthreads );
387 
388  PAPI_shutdown( );
389 
390  return ( retval );
391 }
static int PAPI_events_len
void init_papi_pthreads(int *out_events, int *len)
void PAPI_shutdown(void)
Definition: papi.c:4357
void * case1_pthreads(void *arg)
int do_pthreads(void *(*fn)(void *))
unsigned int PAPI_events[EVENTSLEN]
Definition: derived.c:20
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

void* case1_pthreads ( void arg)

Definition at line 129 of file multiplex1_pthreads.c.

130 {
131  ( void ) arg; /*unused */
132  int retval, i, EventSet = PAPI_NULL;
133  long long values[2];
134 
135  if ( ( retval = PAPI_register_thread( ) ) != PAPI_OK )
136  test_fail( __FILE__, __LINE__, "PAPI_register_thread", retval );
137 
138  if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
139  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
140 
141  for ( i = 0; i < PAPI_events_len; i++ ) {
142  char out[PAPI_MAX_STR_LEN];
143 
144  retval = PAPI_add_event( EventSet, PAPI_events[i] );
145  if ( retval != PAPI_OK )
146  CPP_TEST_FAIL( "PAPI_add_event", retval );
148  if ( !TESTS_QUIET )
149  printf( "Added %s\n", out );
150  }
151 
152  do_stuff( );
153 
154  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
155  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
156 
157  do_stuff( );
158 
159  if ( ( retval = PAPI_stop( EventSet, values ) ) != PAPI_OK )
160  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
161 
162  if ( !TESTS_QUIET ) {
163  printf( "case1 thread %4x:", ( unsigned ) pthread_self( ) );
164  test_print_event_header( "", EventSet );
165  printf( "case1 thread %4x:", ( unsigned ) pthread_self( ) );
166  printf( TAB2, "", values[0], values[1] );
167  }
168 
169  if ( ( retval = PAPI_cleanup_eventset( EventSet ) ) != PAPI_OK ) /* JT */
170  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
171 
172  if ( ( retval = PAPI_destroy_eventset( &EventSet) ) != PAPI_OK )
173  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
174 
175  if ( ( retval = PAPI_unregister_thread( ) ) != PAPI_OK )
176  test_fail( __FILE__, __LINE__, "PAPI_unregister_thread", retval );
177 
178  return ( ( void * ) SUCCESS );
179 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
static int PAPI_events_len
void do_stuff(void)
Definition: do_loops.c:249
int PAPI_register_thread(void)
Definition: papi.c:203
return PAPI_OK
Definition: linux-nvml.c:458
#define SUCCESS
Definition: test_utils.h:5
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 i
Definition: fileop.c:140
#define TAB2
Definition: papi_test.h:113
#define CPP_TEST_FAIL(string, retval)
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
int EventSet
int PAPI_unregister_thread(void)
Definition: papi.c:239
unsigned int PAPI_events[EVENTSLEN]
Definition: derived.c:20
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
void test_print_event_header(char *call, int evset)
Definition: test_utils.c:645
int PAPI_start(int EventSet)
Definition: papi.c:2026
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int case2 ( void  )

Definition at line 394 of file multiplex1_pthreads.c.

395 {
396  int retval;
397 
398  PAPI_events_len = 2;
400 
401  retval = do_pthreads( case2_pthreads );
402 
403  PAPI_shutdown( );
404 
405  return ( retval );
406 }
static int PAPI_events_len
void init_papi_pthreads(int *out_events, int *len)
void PAPI_shutdown(void)
Definition: papi.c:4357
int do_pthreads(void *(*fn)(void *))
void * case2_pthreads(void *arg)
unsigned int PAPI_events[EVENTSLEN]
Definition: derived.c:20
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

void* case2_pthreads ( void arg)

Definition at line 184 of file multiplex1_pthreads.c.

185 {
186  ( void ) arg; /*unused */
187  int retval, i, EventSet = PAPI_NULL;
188  long long values[2];
189 
190  if ( ( retval = PAPI_register_thread( ) ) != PAPI_OK )
191  test_fail( __FILE__, __LINE__, "PAPI_register_thread", retval );
192 
193  if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
194  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
195 
196  /* In Component PAPI, EventSets must be assigned a component index
197  before you can fiddle with their internals.
198  0 is always the cpu component */
199  retval = PAPI_assign_eventset_component( EventSet, 0 );
200  if ( retval != PAPI_OK )
201  CPP_TEST_FAIL( "PAPI_assign_eventset_component", retval );
202 
203  if ( ( retval = PAPI_set_multiplex( EventSet ) ) != PAPI_OK ) {
204  if ( retval == PAPI_ENOSUPP) {
205  test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
206  }
207  test_fail( __FILE__, __LINE__, "PAPI_set_multiplex", retval );
208  }
209  printf( "++case2 thread %4x:", ( unsigned ) pthread_self( ) );
210 
211  for ( i = 0; i < PAPI_events_len; i++ ) {
212  char out[PAPI_MAX_STR_LEN];
213 
214  retval = PAPI_add_event( EventSet, PAPI_events[i] );
215  if ( retval != PAPI_OK )
216  CPP_TEST_FAIL( "PAPI_add_event", retval );
218  if ( !TESTS_QUIET )
219  printf( "Added %s\n", out );
220  }
221 
222  do_stuff( );
223 
224  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
225  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
226 
227  do_stuff( );
228 
229  if ( ( retval = PAPI_stop( EventSet, values ) ) != PAPI_OK )
230  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
231 
232  if ( !TESTS_QUIET ) {
233  printf( "case2 thread %4x:", ( unsigned ) pthread_self( ) );
234  test_print_event_header( "", EventSet );
235  printf( "case2 thread %4x:", ( unsigned ) pthread_self( ) );
236  printf( TAB2, "", values[0], values[1] );
237  }
238 
239  if ( ( retval = PAPI_cleanup_eventset( EventSet ) ) != PAPI_OK ) /* JT */
240  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
241 
242  if ( ( retval = PAPI_destroy_eventset( &EventSet) ) != PAPI_OK )
243  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
244 
245  if ( ( retval = PAPI_unregister_thread( ) ) != PAPI_OK )
246  test_fail( __FILE__, __LINE__, "PAPI_unregister_thread", retval );
247 
248  return ( ( void * ) SUCCESS );
249 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
static int PAPI_events_len
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
void do_stuff(void)
Definition: do_loops.c:249
int PAPI_register_thread(void)
Definition: papi.c:203
return PAPI_OK
Definition: linux-nvml.c:458
#define SUCCESS
Definition: test_utils.h:5
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 i
Definition: fileop.c:140
#define PAPI_ENOSUPP
Definition: fpapi.h:123
#define TAB2
Definition: papi_test.h:113
#define CPP_TEST_FAIL(string, retval)
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1467
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
int EventSet
int PAPI_unregister_thread(void)
Definition: papi.c:239
unsigned int PAPI_events[EVENTSLEN]
Definition: derived.c:20
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3241
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
void test_print_event_header(char *call, int evset)
Definition: test_utils.c:645
int PAPI_start(int EventSet)
Definition: papi.c:2026
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int case3 ( void  )

Definition at line 409 of file multiplex1_pthreads.c.

410 {
411  int retval;
412 
413  PAPI_events_len = 2;
415 
416  retval = do_pthreads( case3_pthreads );
417 
418  PAPI_shutdown( );
419 
420  return ( retval );
421 }
static int PAPI_events_len
void init_papi_pthreads(int *out_events, int *len)
void PAPI_shutdown(void)
Definition: papi.c:4357
int do_pthreads(void *(*fn)(void *))
unsigned int PAPI_events[EVENTSLEN]
Definition: derived.c:20
void * case3_pthreads(void *arg)
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

void* case3_pthreads ( void arg)

Definition at line 254 of file multiplex1_pthreads.c.

255 {
256  ( void ) arg; /*unused */
257  int retval, i, EventSet = PAPI_NULL;
258  long long values[2];
259 
260  if ( ( retval = PAPI_register_thread( ) ) != PAPI_OK )
261  test_fail( __FILE__, __LINE__, "PAPI_register_thread", retval );
262 
263  if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
264  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
265 
266  for ( i = 0; i < PAPI_events_len; i++ ) {
267  char out[PAPI_MAX_STR_LEN];
268 
269  retval = PAPI_add_event( EventSet, PAPI_events[i] );
270  if ( retval != PAPI_OK )
271  CPP_TEST_FAIL( "PAPI_add_event", retval );
273  if ( !TESTS_QUIET )
274  printf( "Added %s\n", out );
275  }
276 
277  if ( ( retval = PAPI_set_multiplex( EventSet ) ) != PAPI_OK ) {
278  if ( retval == PAPI_ENOSUPP) {
279  test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
280  }
281  test_fail( __FILE__, __LINE__, "PAPI_set_multiplex", retval );
282  }
283  do_stuff( );
284 
285  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
286  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
287 
288  do_stuff( );
289 
290  if ( ( retval = PAPI_stop( EventSet, values ) ) != PAPI_OK )
291  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
292 
293  if ( !TESTS_QUIET ) {
294  printf( "case3 thread %4x:", ( unsigned ) pthread_self( ) );
295  test_print_event_header( "", EventSet );
296  printf( "case3 thread %4x:", ( unsigned ) pthread_self( ) );
297  printf( TAB2, "", values[0], values[1] );
298  }
299 
300  if ( ( retval = PAPI_cleanup_eventset( EventSet ) ) != PAPI_OK ) /* JT */
301  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
302 
303  if ( ( retval = PAPI_destroy_eventset( &EventSet) ) != PAPI_OK )
304  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
305 
306  if ( ( retval = PAPI_unregister_thread( ) ) != PAPI_OK )
307  test_fail( __FILE__, __LINE__, "PAPI_unregister_thread", retval );
308 
309  return ( ( void * ) SUCCESS );
310 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
static int PAPI_events_len
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
void do_stuff(void)
Definition: do_loops.c:249
int PAPI_register_thread(void)
Definition: papi.c:203
return PAPI_OK
Definition: linux-nvml.c:458
#define SUCCESS
Definition: test_utils.h:5
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 i
Definition: fileop.c:140
#define PAPI_ENOSUPP
Definition: fpapi.h:123
#define TAB2
Definition: papi_test.h:113
#define CPP_TEST_FAIL(string, retval)
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
int EventSet
int PAPI_unregister_thread(void)
Definition: papi.c:239
unsigned int PAPI_events[EVENTSLEN]
Definition: derived.c:20
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3241
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
void test_print_event_header(char *call, int evset)
Definition: test_utils.c:645
int PAPI_start(int EventSet)
Definition: papi.c:2026
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int case4 ( void  )

Definition at line 424 of file multiplex1_pthreads.c.

425 {
426  int retval;
427 
428  PAPI_events_len = 2;
430 
431  retval = do_pthreads( case4_pthreads );
432 
433  PAPI_shutdown( );
434 
435  return ( retval );
436 }
static int PAPI_events_len
void * case4_pthreads(void *arg)
void init_papi_pthreads(int *out_events, int *len)
void PAPI_shutdown(void)
Definition: papi.c:4357
int do_pthreads(void *(*fn)(void *))
unsigned int PAPI_events[EVENTSLEN]
Definition: derived.c:20
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

void* case4_pthreads ( void arg)

Definition at line 315 of file multiplex1_pthreads.c.

316 {
317  ( void ) arg; /*unused */
318  int retval, i, EventSet = PAPI_NULL;
319  long long values[4];
320  char out[PAPI_MAX_STR_LEN];
321 
322  if ( ( retval = PAPI_register_thread( ) ) != PAPI_OK )
323  test_fail( __FILE__, __LINE__, "PAPI_register_thread", retval );
324 
325  if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
326  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
327 
328  i = 0;
329  retval = PAPI_add_event( EventSet, PAPI_events[i] );
330  if ( retval != PAPI_OK )
331  CPP_TEST_FAIL( "PAPI_add_event", retval );
333  printf( "Added %s\n", out );
334 
335  if ( ( retval = PAPI_set_multiplex( EventSet ) ) != PAPI_OK ) {
336  if ( retval == PAPI_ENOSUPP) {
337  test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
338  }
339 
340  test_fail( __FILE__, __LINE__, "PAPI_set_multiplex", retval );
341  }
342  i = 1;
343  retval = PAPI_add_event( EventSet, PAPI_events[i] );
344  if ( retval != PAPI_OK )
345  CPP_TEST_FAIL( "PAPI_add_event", retval );
347  printf( "Added %s\n", out );
348 
349  do_stuff( );
350 
351  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
352  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
353 
354  do_stuff( );
355 
356  if ( ( retval = PAPI_stop( EventSet, values ) ) != PAPI_OK )
357  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
358 
359  if ( !TESTS_QUIET ) {
360  printf( "case4 thread %4x:", ( unsigned ) pthread_self( ) );
361  test_print_event_header( "", EventSet );
362  printf( "case4 thread %4x:", ( unsigned ) pthread_self( ) );
363  printf( TAB2, "", values[0], values[1] );
364  }
365 
366  if ( ( retval = PAPI_cleanup_eventset( EventSet ) ) != PAPI_OK ) /* JT */
367  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
368 
369  if ( ( retval = PAPI_destroy_eventset( &EventSet) ) != PAPI_OK )
370  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
371 
372  if ( ( retval = PAPI_unregister_thread( ) ) != PAPI_OK )
373  test_fail( __FILE__, __LINE__, "PAPI_unregister_thread", retval );
374 
375  return ( ( void * ) SUCCESS );
376 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
void do_stuff(void)
Definition: do_loops.c:249
int PAPI_register_thread(void)
Definition: papi.c:203
return PAPI_OK
Definition: linux-nvml.c:458
#define SUCCESS
Definition: test_utils.h:5
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 i
Definition: fileop.c:140
#define PAPI_ENOSUPP
Definition: fpapi.h:123
#define TAB2
Definition: papi_test.h:113
#define CPP_TEST_FAIL(string, retval)
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
int EventSet
int PAPI_unregister_thread(void)
Definition: papi.c:239
unsigned int PAPI_events[EVENTSLEN]
Definition: derived.c:20
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3241
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
void test_print_event_header(char *call, int evset)
Definition: test_utils.c:645
int PAPI_start(int EventSet)
Definition: papi.c:2026
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int do_pthreads ( void *(*)(void *)  fn)

Definition at line 97 of file multiplex1_pthreads.c.

98 {
99  int i, rc, retval;
100  pthread_attr_t attr;
102 
103  pthread_attr_init( &attr );
104 #ifdef PTHREAD_CREATE_UNDETACHED
105  pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_UNDETACHED );
106 #endif
107 #ifdef PTHREAD_SCOPE_SYSTEM
108  retval = pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM );
109  if ( retval != 0 )
110  test_skip( __FILE__, __LINE__, "pthread_attr_setscope", retval );
111 #endif
112 
113  for ( i = 0; i < NUM_THREADS; i++ ) {
114  rc = pthread_create( &id[i], &attr, fn, NULL );
115  if ( rc )
116  return ( FAILURE );
117  }
118  for ( i = 0; i < NUM_THREADS; i++ )
119  pthread_join( id[i], NULL );
120 
121  pthread_attr_destroy( &attr );
122 
123  return ( SUCCESS );
124 }
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
#define SUCCESS
Definition: test_utils.h:5
int i
Definition: fileop.c:140
#define NUM_THREADS
Definition: test_utils.h:8
#define FAILURE
Definition: test_utils.h:6
pthread_t
Definition: iozone.c:18557
int rc
Definition: iozone.c:20281
ssize_t retval
Definition: libasync.c:338
pthread_attr_t attr
Definition: iozone.c:18466

Here is the call graph for this function:

Here is the caller graph for this function:

void init_papi_pthreads ( int out_events,
int len 
)

Definition at line 31 of file multiplex1_pthreads.c.

32 {
33  int retval;
34  int i, real_len = 0;
35  int *in_events = preset_PAPI_events;
36  const PAPI_hw_info_t *hw_info;
37 
38  /* Initialize the library */
40  if ( retval != PAPI_VER_CURRENT )
41  CPP_TEST_FAIL( "PAPI_library_init", retval );
42 
43  hw_info = PAPI_get_hardware_info( );
44  if ( hw_info == NULL )
45  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
46 
47  if ( strstr( hw_info->model_string, "UltraSPARC" ) ) {
48  in_events = solaris_preset_PAPI_events;
49  }
50 
51  if ( strcmp( hw_info->model_string, "POWER6" ) == 0 ) {
52  in_events = power6_preset_PAPI_events;
53  retval = PAPI_set_domain( PAPI_DOM_ALL );
54  if ( retval != PAPI_OK )
55  CPP_TEST_FAIL( "PAPI_set_domain", retval );
56  }
57 
58  retval = PAPI_multiplex_init( );
59  if ( retval == PAPI_ENOSUPP) {
60  test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
61  }
62  else if ( retval != PAPI_OK ) {
63  CPP_TEST_FAIL( "PAPI_multiplex_init", retval );
64  }
65 
66  if ( ( retval =
67  PAPI_thread_init( ( unsigned
68  long ( * )( void ) ) ( pthread_self ) ) ) !=
69  PAPI_OK ) {
70  if ( retval == PAPI_ECMP )
71  test_skip( __FILE__, __LINE__, "PAPI_thread_init", retval );
72  else
73  test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
74  }
75 
76  for ( i = 0; in_events[i] != 0; i++ ) {
77  char out[PAPI_MAX_STR_LEN];
78  /* query and set up the right instruction to monitor */
79  retval = PAPI_query_event( in_events[i] );
80  if ( retval == PAPI_OK ) {
81  out_events[real_len++] = in_events[i];
82  PAPI_event_code_to_name( in_events[i], out );
83  if ( real_len == *len )
84  break;
85  } else {
86  PAPI_event_code_to_name( in_events[i], out );
87  if ( !TESTS_QUIET )
88  printf( "%s does not exist\n", out );
89  }
90  }
91  if ( real_len < 1 )
92  CPP_TEST_FAIL( "No counters available", 0 );
93  *len = real_len;
94 }
Hardware info structure.
Definition: papi.h:775
int preset_PAPI_events[TOTAL_EVENTS]
Definition: multiplex1.c:24
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
#define PAPI_DOM_ALL
Definition: fpapi.h:25
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
return PAPI_OK
Definition: linux-nvml.c:458
int power6_preset_PAPI_events[TOTAL_EVENTS]
Definition: multiplex1.c:21
#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_thread_init(unsigned long int(*id_fn)(void))
Definition: papi.c:118
int PAPI_library_init(int version)
Definition: papi.c:495
int i
Definition: fileop.c:140
#define PAPI_ENOSUPP
Definition: fpapi.h:123
int solaris_preset_PAPI_events[TOTAL_EVENTS]
Definition: multiplex1.c:18
#define PAPI_ECMP
Definition: fpapi.h:109
#define CPP_TEST_FAIL(string, retval)
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
int PAPI_query_event(int EventCode)
Definition: papi.c:696
int PAPI_multiplex_init(void)
Definition: papi.c:2897
int PAPI_set_domain(int domain)
Definition: papi.c:5565
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:785
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6059
ssize_t retval
Definition: libasync.c:338
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:23

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 439 of file multiplex1_pthreads.c.

440 {
441  int retval;
442 
443  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
444 
445  printf( "%s: Using %d threads\n\n", argv[0], NUM_THREADS );
446 
447  printf
448  ( "case1: Does PAPI_multiplex_init() not break regular operation?\n" );
449  if ( case1( ) != SUCCESS )
450  test_fail( __FILE__, __LINE__, "case1", PAPI_ESYS );
451 
452  printf( "case2: Does setmpx/add work?\n" );
453  if ( case2( ) != SUCCESS )
454  test_fail( __FILE__, __LINE__, "case2", PAPI_ESYS );
455 
456  printf( "case3: Does add/setmpx work?\n" );
457  if ( case3( ) != SUCCESS )
458  test_fail( __FILE__, __LINE__, "case3", PAPI_ESYS );
459 
460  printf( "case4: Does add/setmpx/add work?\n" );
461  if ( case4( ) != SUCCESS )
462  test_fail( __FILE__, __LINE__, "case4", PAPI_ESYS );
463 
465  if ( retval != PAPI_VER_CURRENT )
466  CPP_TEST_FAIL( "PAPI_library_init", retval );
467 
468  test_pass( __FILE__, NULL, 0 );
469  exit( 1 );
470 }
#define SUCCESS
Definition: test_utils.h:5
tests_quiet(argc, argv)
int case1()
Definition: multiplex1.c:90
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int case2()
Definition: multiplex1.c:139
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
#define NUM_THREADS
Definition: test_utils.h:8
#define CPP_TEST_FAIL(string, retval)
int case3()
Definition: multiplex1.c:203
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
#define PAPI_ESYS
Definition: fpapi.h:108
ssize_t retval
Definition: libasync.c:338
void exit()
int case4()
Definition: multiplex1.c:262

Here is the call graph for this function:

Variable Documentation

int PAPI_events[TOTAL_EVENTS] = { 0, }
static

Definition at line 25 of file multiplex1_pthreads.c.

int PAPI_events_len = 0
static

Definition at line 26 of file multiplex1_pthreads.c.

int power6_preset_PAPI_events[TOTAL_EVENTS]
Initial value:
= {
}
#define PAPI_L1_ICM
Definition: fpapi.h:136
#define PAPI_TOT_CYC
Definition: fpapi.h:194
#define PAPI_FP_INS
Definition: fpapi.h:187
#define PAPI_L1_DCM
Definition: fpapi.h:135

Definition at line 19 of file multiplex1_pthreads.c.

int preset_PAPI_events[TOTAL_EVENTS]
Initial value:
= {
}
#define PAPI_L1_ICM
Definition: fpapi.h:136
#define PAPI_TOT_INS
Definition: fpapi.h:185
#define PAPI_FP_INS
Definition: fpapi.h:187
#define PAPI_L1_DCM
Definition: fpapi.h:135

Definition at line 22 of file multiplex1_pthreads.c.

int solaris_preset_PAPI_events[TOTAL_EVENTS]
Initial value:
= {
}
#define PAPI_L2_TCM
Definition: fpapi.h:142
#define PAPI_L1_ICM
Definition: fpapi.h:136
#define PAPI_TOT_CYC
Definition: fpapi.h:194
#define PAPI_BR_MSP
Definition: fpapi.h:181

Definition at line 16 of file multiplex1_pthreads.c.