LLVM OpenMP
20.0.0git
runtime
test
worksharing
sections
omp_section_firstprivate.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_section_firstprivate
()
6
{
7
int
sum
;
8
int
sum0
;
9
int
known_sum;
10
11
sum0
= 11;
12
sum
= 7;
13
#pragma omp parallel
14
{
15
#pragma omp sections firstprivate(sum0)
16
{
17
#pragma omp section
18
{
19
#pragma omp critical
20
{
21
sum
=
sum
+
sum0
;
22
}
23
}
24
#pragma omp section
25
{
26
#pragma omp critical
27
{
28
sum
=
sum
+
sum0
;
29
}
30
}
31
#pragma omp section
32
{
33
#pragma omp critical
34
{
35
sum
=
sum
+
sum0
;
36
}
37
}
38
}
39
}
40
known_sum = 11 * 3 + 7;
41
return
(known_sum ==
sum
);
42
}
/* end of check_section_firstprivate*/
43
44
int
main
()
45
{
46
int
i
;
47
int
num_failed=0;
48
49
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
50
if
(!
test_omp_section_firstprivate
()) {
51
num_failed++;
52
}
53
}
54
return
num_failed;
55
}
i
#define i
Definition:
kmp_stub.cpp:87
sum
int sum
Definition:
omp_for_schedule_runtime.c:19
test_omp_section_firstprivate
int test_omp_section_firstprivate()
Definition:
omp_section_firstprivate.c:5
main
int main()
Definition:
omp_section_firstprivate.c:44
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