PAPI  5.7.0.0
clockres_pthreads.c File Reference
Include dependency graph for clockres_pthreads.c:

Go to the source code of this file.

Functions

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

Function Documentation

◆ main()

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 }
#define PAPI_OK
Definition: fpapi.h:105
void test_pass(const char *filename)
Definition: test_utils.c:432
unsigned long int pthread_t
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
volatile double t2
int retval
Definition: zero_fork.c:53
volatile double t1
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:561
#define PAPI_ECMP
Definition: fpapi.h:109
int PAPI_thread_init(unsigned long int(*id_fn)(void))
Definition: papi.c:123
int PAPI_library_init(int version)
Definition: papi.c:500
void * pthread_main(void *arg)
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
Here is the call graph for this function:

◆ pthread_main()

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 
20  if (retval != PAPI_OK ) {
21  test_fail(__FILE__, __LINE__, "clockcore failure", retval );
22  }
23 
25  if ( retval != PAPI_OK ) {
26  test_fail( __FILE__, __LINE__, "PAPI_unregister_thread", retval );
27  }
28  return NULL;
29 }
#define PAPI_OK
Definition: fpapi.h:105
int PAPI_register_thread(void)
Definition: papi.c:208
int retval
Definition: zero_fork.c:53
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
Here is the call graph for this function:
Here is the caller graph for this function: