LLVM OpenMP
20.0.0git
runtime
test
worksharing
sections
omp_parallel_sections_lastprivate.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_lastprivate
()
6
{
7
int
sum
;
8
int
sum0
;
9
int
i
;
10
int
i0;
11
int
known_sum;
12
sum
=0;
13
sum0
= 0;
14
i0 = -1;
15
16
#pragma omp parallel sections private(i,sum0) lastprivate(i0)
17
{
18
#pragma omp section
19
{
20
sum0
=0;
21
for
(
i
=1;
i
<400;
i
++) {
22
sum0
=
sum0
+
i
;
23
i0=
i
;
24
}
25
#pragma omp critical
26
{
27
sum
=
sum
+
sum0
;
28
}
29
}
30
#pragma omp section
31
{
32
sum0
=0;
33
for
(
i
=400;
i
<700;
i
++) {
34
sum0
=
sum0
+
i
;
35
i0=
i
;
36
}
37
#pragma omp critical
38
{
39
sum
=
sum
+
sum0
;
40
}
41
}
42
#pragma omp section
43
{
44
sum0
=0;
45
for
(
i
=700;
i
<1000;
i
++) {
46
sum0
=
sum0
+
i
;
47
i0=
i
;
48
}
49
#pragma omp critical
50
{
51
sum
=
sum
+
sum0
;
52
}
53
}
54
}
55
56
known_sum=(999*1000)/2;
57
return
((known_sum==
sum
) && (i0==999) );
58
}
59
60
int
main
()
61
{
62
int
i
;
63
int
num_failed=0;
64
65
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
66
if
(!
test_omp_parallel_sections_lastprivate
()) {
67
num_failed++;
68
}
69
}
70
return
num_failed;
71
}
i
#define i
Definition:
kmp_stub.cpp:87
sum
int sum
Definition:
omp_for_schedule_runtime.c:19
test_omp_parallel_sections_lastprivate
int test_omp_parallel_sections_lastprivate()
Definition:
omp_parallel_sections_lastprivate.c:5
main
int main()
Definition:
omp_parallel_sections_lastprivate.c:60
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