LLVM OpenMP
20.0.0git
runtime
test
worksharing
single
omp_single_copyprivate.c
Go to the documentation of this file.
1
// RUN: %libomp-compile-and-run
2
#include "
omp_testsuite.h
"
3
4
#define DEBUG_TEST 0
5
6
int
j
;
7
#pragma omp threadprivate(j)
8
9
int
test_omp_single_copyprivate
()
10
{
11
int
result
;
12
int
nr_iterations;
13
14
result
= 0;
15
nr_iterations = 0;
16
#pragma omp parallel num_threads(4)
17
{
18
int
i
;
19
for
(
i
= 0;
i
<
LOOPCOUNT
;
i
++)
20
{
21
#if DEBUG_TEST
22
int
thread;
23
thread = omp_get_thread_num ();
24
#endif
25
#pragma omp single copyprivate(j)
26
{
27
nr_iterations++;
28
j
=
i
;
29
#if DEBUG_TEST
30
printf (
"thread %d assigns, j = %d, i = %d\n"
, thread,
j
,
i
);
31
#endif
32
}
33
#if DEBUG_TEST
34
#pragma omp barrier
35
#endif
36
#pragma omp critical
37
{
38
#if DEBUG_TEST
39
printf (
"thread = %d, j = %d, i = %d\n"
, thread,
j
,
i
);
40
#endif
41
result
=
result
+
j
-
i
;
42
}
43
#pragma omp barrier
44
}
/* end of for */
45
}
/* end of parallel */
46
return
((
result
== 0) && (nr_iterations ==
LOOPCOUNT
));
47
}
48
49
int
main
()
50
{
51
int
i
;
52
int
num_failed=0;
53
54
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
55
if
(!
test_omp_single_copyprivate
()) {
56
num_failed++;
57
}
58
}
59
return
num_failed;
60
}
result
int result[2]
Definition:
cancellation_for_sections.c:13
i
#define i
Definition:
kmp_stub.cpp:87
test_omp_single_copyprivate
int test_omp_single_copyprivate()
Definition:
omp_single_copyprivate.c:9
j
int j
Definition:
omp_single_copyprivate.c:6
main
int main()
Definition:
omp_single_copyprivate.c:49
omp_testsuite.h
LOOPCOUNT
#define LOOPCOUNT
Definition:
omp_testsuite.h:12
REPETITIONS
#define REPETITIONS
Definition:
omp_testsuite.h:13
Generated on Wed Feb 5 2025 10:57:22 for LLVM OpenMP by
1.9.6