LLVM OpenMP
20.0.0git
runtime
test
worksharing
single
omp_single_private.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
int
myit
= 0;
6
#pragma omp threadprivate(myit)
7
int
myresult
= 0;
8
#pragma omp threadprivate(myresult)
9
10
int
test_omp_single_private
()
11
{
12
int
nr_threads_in_single;
13
int
result
;
14
int
nr_iterations;
15
int
i
;
16
17
myit
= 0;
18
nr_threads_in_single = 0;
19
nr_iterations = 0;
20
result
= 0;
21
22
#pragma omp parallel private(i)
23
{
24
myresult
= 0;
25
myit
= 0;
26
for
(
i
= 0;
i
<
LOOPCOUNT
;
i
++) {
27
#pragma omp single private(nr_threads_in_single) nowait
28
{
29
nr_threads_in_single = 0;
30
#pragma omp flush
31
nr_threads_in_single++;
32
#pragma omp flush
33
myit
++;
34
myresult
=
myresult
+ nr_threads_in_single;
35
}
36
}
37
#pragma omp critical
38
{
39
result
+= nr_threads_in_single;
40
nr_iterations +=
myit
;
41
}
42
}
43
return
((
result
== 0) && (nr_iterations ==
LOOPCOUNT
));
44
}
/* end of check_single private */
45
46
int
main
()
47
{
48
int
i
;
49
int
num_failed=0;
50
51
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
52
if
(!
test_omp_single_private
()) {
53
num_failed++;
54
}
55
}
56
return
num_failed;
57
}
result
int result[2]
Definition:
cancellation_for_sections.c:13
i
#define i
Definition:
kmp_stub.cpp:87
myresult
int myresult
Definition:
omp_single_private.c:7
myit
int myit
Definition:
omp_single_private.c:5
main
int main()
Definition:
omp_single_private.c:46
test_omp_single_private
int test_omp_single_private()
Definition:
omp_single_private.c:10
omp_testsuite.h
LOOPCOUNT
#define LOOPCOUNT
Definition:
omp_testsuite.h:12
REPETITIONS
#define REPETITIONS
Definition:
omp_testsuite.h:13
Generated on Tue Feb 4 2025 13:28:34 for LLVM OpenMP by
1.9.6