Go to the source code of this file.
◆ APPR_TOTAL_ITER
| #define APPR_TOTAL_ITER 1000000 |
◆ MAX_THREADS
◆ lockloop()
| void lockloop |
( |
int |
iters, |
|
|
volatile long long * |
mycount |
|
) |
| |
Definition at line 25 of file ctests/locks_pthreads.c.
26{
28 for (
i = 0;
i < iters;
i++ ) {
30 *mycount = *mycount + 1;
32 }
33}
Lock one of two mutex variables defined in papi.h.
Unlock one of the mutex variables defined in papi.h.
◆ main()
| int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 53 of file ctests/locks_pthreads.c.
54{
59
60
62
66 }
67
69 if (hwinfo == NULL ) {
70 test_fail( __FILE__, __LINE__,
"PAPI_get_hardware_info", 2 );
71 }
72
77 "PAPI_thread_init",
retval );
78 }
79 else {
81 "PAPI_thread_init",
retval );
82 }
83 }
84
87 }
88 else {
90 }
91
92
94
96 printf( "Creating %d threads, %lld lock/unlock\n",
98 }
99
100 for (
i = 0;
i < nthr;
i++ ) {
101 rc = pthread_create( &slaves[
i], NULL,
Slave, NULL );
105 "pthread_create",
retval );
106 }
107 }
108
109 for (
i = 0;
i < nthr;
i++ ) {
110 pthread_join( slaves[
i], NULL );
111 }
112
114 printf( "Expected: %lld Received: %lld\n",
117 }
118
120 test_fail( __FILE__, __LINE__,
"Thread Locks", 1 );
121 }
122
124
125 return 0;
126
127}
get information about the system hardware
initialize the PAPI library.
Initialize thread support in the PAPI library.
volatile long long thread_iter
unsigned long int pthread_t
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
◆ Slave()
| void * Slave |
( |
void * |
arg | ) |
|
Definition at line 36 of file ctests/locks_pthreads.c.
37{
38 long long duration;
39
43
45 printf("%f lock/unlocks per us\n",
47 }
48 pthread_exit( arg );
49}
get real time counter value in microseconds
void lockloop(int iters, volatile long long *mycount)
◆ count
◆ quiet
◆ thread_iter
◆ tmpcount