PAPI 7.1.0.0
Loading...
Searching...
No Matches
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}
static struct timeval t1 t2
Definition: benchSANVML.c:117
initialize the PAPI library.
Initialize thread support in the PAPI library.
void * pthread_main(void *arg)
volatile double t1
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_ECMP
Definition: f90papi.h:214
int TESTS_QUIET
Definition: test_utils.c:18
unsigned long int pthread_t
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int retval
Definition: zero_fork.c:53
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}
Notify PAPI that a thread has 'appeared'.
Notify PAPI that a thread has 'disappeared'.
int clockcore(int quiet)
Definition: clockcore.c:111
Here is the call graph for this function:
Here is the caller graph for this function: