LLVM OpenMP
20.0.0git
runtime
test
worksharing
sections
omp_parallel_sections_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
test_omp_parallel_sections_private
()
6
{
7
int
sum
;
8
int
sum0
;
9
int
i
;
10
int
known_sum;
11
12
sum
= 7;
13
sum0
=0;
14
15
#pragma omp parallel sections private(sum0, i)
16
{
17
#pragma omp section
18
{
19
sum0
=0;
20
for
(
i
=1;
i
<400;
i
++)
21
sum0
=
sum0
+
i
;
22
#pragma omp critical
23
{
24
sum
=
sum
+
sum0
;
25
}
26
}
27
#pragma omp section
28
{
29
sum0
=0;
30
for
(
i
=400;
i
<700;
i
++)
31
sum0
=
sum0
+
i
;
32
#pragma omp critical
33
{
34
sum
=
sum
+
sum0
;
35
}
36
}
37
#pragma omp section
38
{
39
sum0
=0;
40
for
(
i
=700;
i
<1000;
i
++)
41
sum0
=
sum0
+
i
;
42
#pragma omp critical
43
{
44
sum
=
sum
+
sum0
;
45
}
46
}
47
}
48
49
known_sum=(999*1000)/2+7;
50
return
(known_sum==
sum
);
51
}
/* end of check_section_private*/
52
53
int
main
()
54
{
55
int
i
;
56
int
num_failed=0;
57
58
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
59
if
(!
test_omp_parallel_sections_private
()) {
60
num_failed++;
61
}
62
}
63
return
num_failed;
64
}
i
#define i
Definition:
kmp_stub.cpp:87
sum
int sum
Definition:
omp_for_schedule_runtime.c:19
test_omp_parallel_sections_private
int test_omp_parallel_sections_private()
Definition:
omp_parallel_sections_private.c:5
main
int main()
Definition:
omp_parallel_sections_private.c:53
omp_testsuite.h
REPETITIONS
#define REPETITIONS
Definition:
omp_testsuite.h:13
sum0
static int sum0
Definition:
omp_threadprivate.c:14
Generated on Wed Jan 29 2025 20:58:03 for LLVM OpenMP by
1.9.6