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

Go to the source code of this file.

Functions

voidpthread_main (void *arg)
 
int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file clockres_pthreads.c.

33 {
34  pthread_t t1, t2, t3, t4;
35  pthread_attr_t attr;
36  int retval;
37 
38  /* Set TESTS_QUIET variable */
39  tests_quiet( argc, argv );
40 
42  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
43  }
44 
45  retval = PAPI_thread_init( ( unsigned long ( * )(void) ) (pthread_self) );
46  if ( retval != PAPI_OK ) {
47  if ( retval == PAPI_ECMP ) {
48  test_skip( __FILE__, __LINE__, "PAPI_thread_init", retval );
49  }
50  else {
51  test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
52  }
53  }
54 
55  if ( !TESTS_QUIET ) {
56  printf( "Test case: Clock latency and resolution.\n" );
57  printf( "Note: Virtual timers are proportional to # CPUs.\n" );
58  printf( "------------------------------------------------\n" );
59  }
60 
61  pthread_attr_init( &attr );
62 
63 #ifdef PTHREAD_CREATE_UNDETACHED
64  pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_UNDETACHED );
65 #endif
66 
67 #ifdef PTHREAD_SCOPE_SYSTEM
68  retval = pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM );
69  if ( retval != 0 ) {
70  test_skip( __FILE__, __LINE__, "pthread_attr_setscope", retval );
71  }
72 #endif
73 
74  if (pthread_create( &t1, &attr, pthread_main, NULL )) {
75  test_fail(__FILE__, __LINE__, "cannot create thread", retval);
76  }
77 
78  if (pthread_create( &t2, &attr, pthread_main, NULL )) {
79  test_fail(__FILE__, __LINE__, "cannot create thread", retval);
80  }
81 
82  if (pthread_create( &t3, &attr, pthread_main, NULL )) {
83  test_fail(__FILE__, __LINE__, "cannot create thread", retval);
84  }
85 
86  if (pthread_create( &t4, &attr, pthread_main, NULL )) {
87  test_fail(__FILE__, __LINE__, "cannot create thread", retval);
88  }
89 
90  pthread_main( NULL );
91 
92  pthread_join( t1, NULL );
93  pthread_join( t2, NULL );
94  pthread_join( t3, NULL );
95  pthread_join( t4, NULL );
96 
97  test_pass( __FILE__ );
98 
99  return 0;
100 }
void test_pass(const char *filename)
Definition: test_utils.c:432
return PAPI_OK
Definition: linux-nvml.c:497
volatile double t2
volatile double t1
int int argc
Definition: iozone.c:1609
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
int PAPI_thread_init(unsigned long int(*id_fn)(void))
Definition: papi.c:123
int PAPI_library_init(int version)
Definition: papi.c:500
#define PAPI_ECMP
Definition: papi.h:256
pthread_t
Definition: iozone.c:18557
void * pthread_main(void *arg)
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
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
#define PAPI_VER_CURRENT
Definition: papi.h:225
pthread_attr_t attr
Definition: iozone.c:18466

Here is the call graph for this function:

void* pthread_main ( void arg)

Definition at line 11 of file clockres_pthreads.c.

12 {
13  ( void ) arg;
15  if ( retval != PAPI_OK ) {
16  test_fail( __FILE__, __LINE__, "PAPI_register_thread", retval );
17  }
18 
19  retval=clockcore( TESTS_QUIET );
20  if (retval != PAPI_OK ) {
21  test_fail(__FILE__, __LINE__, "clockcore failure", retval );
22  }
23 
24  retval = PAPI_unregister_thread( );
25  if ( retval != PAPI_OK ) {
26  test_fail( __FILE__, __LINE__, "PAPI_unregister_thread", retval );
27  }
28  return NULL;
29 }
int PAPI_register_thread(void)
Definition: papi.c:208
return PAPI_OK
Definition: linux-nvml.c:497
void
Definition: iozone.c:18627
int PAPI_unregister_thread(void)
Definition: papi.c:244
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 clockcore(int quiet)
Definition: clockcore.c:110
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function: