LLVM OpenMP
20.0.0git
runtime
test
lock
omp_test_nest_lock.c
Go to the documentation of this file.
1
// RUN: %libomp-compile-and-run
2
#include <stdio.h>
3
#include "
omp_testsuite.h
"
4
5
static
omp_nest_lock_t
lck
;
6
7
int
test_omp_test_nest_lock
()
8
{
9
int
nr_threads_in_single = 0;
10
int
result
= 0;
11
int
nr_iterations = 0;
12
int
i
;
13
14
omp_init_nest_lock (&
lck
);
15
#pragma omp parallel shared(lck)
16
{
17
#pragma omp for
18
for
(
i
= 0;
i
<
LOOPCOUNT
;
i
++)
19
{
20
/*omp_set_lock(&lck);*/
21
while
(!omp_test_nest_lock (&
lck
))
22
{};
23
#pragma omp flush
24
nr_threads_in_single++;
25
#pragma omp flush
26
nr_iterations++;
27
nr_threads_in_single--;
28
result
=
result
+ nr_threads_in_single;
29
omp_unset_nest_lock (&
lck
);
30
}
31
}
32
omp_destroy_nest_lock (&
lck
);
33
return
((
result
== 0) && (nr_iterations ==
LOOPCOUNT
));
34
}
35
36
int
main
()
37
{
38
int
i
;
39
int
num_failed=0;
40
41
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
42
if
(!
test_omp_test_nest_lock
()) {
43
num_failed++;
44
}
45
}
46
return
num_failed;
47
}
result
int result[2]
Definition:
cancellation_for_sections.c:13
i
#define i
Definition:
kmp_stub.cpp:87
test_omp_test_nest_lock
int test_omp_test_nest_lock()
Definition:
omp_test_nest_lock.c:7
lck
static omp_nest_lock_t lck
Definition:
omp_test_nest_lock.c:5
main
int main()
Definition:
omp_test_nest_lock.c:36
omp_testsuite.h
LOOPCOUNT
#define LOOPCOUNT
Definition:
omp_testsuite.h:12
REPETITIONS
#define REPETITIONS
Definition:
omp_testsuite.h:13
Generated on Wed Jan 29 2025 20:58:01 for LLVM OpenMP by
1.9.6