LLVM OpenMP
20.0.0git
runtime
test
threadprivate
omp_threadprivate_for.c
Go to the documentation of this file.
1
// RUN: %libomp-compile-and-run
2
#include "
omp_testsuite.h
"
3
#include <stdlib.h>
4
#include <stdio.h>
5
6
static
int
i
;
7
#pragma omp threadprivate(i)
8
9
int
test_omp_threadprivate_for
()
10
{
11
int
known_sum;
12
int
sum
;
13
14
known_sum = (
LOOPCOUNT
* (
LOOPCOUNT
+ 1)) / 2;
15
sum
= 0;
16
17
#pragma omp parallel
18
{
19
int
sum0
= 0, i0;
20
#pragma omp for
21
for
(i0 = 1; i0 <=
LOOPCOUNT
; i0++) {
22
i
= i0;
23
sum0
=
sum0
+
i
;
24
}
25
#pragma omp critical
26
{
27
sum
=
sum
+
sum0
;
28
}
29
}
/* end of parallel */
30
31
if
(known_sum !=
sum
) {
32
fprintf(stderr,
" known_sum = %d, sum = %d\n"
, known_sum,
sum
);
33
}
34
return
(known_sum ==
sum
);
35
}
/* end of check_threadprivate*/
36
37
int
main
()
38
{
39
int
i
;
40
int
num_failed=0;
41
42
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
43
if
(!
test_omp_threadprivate_for
()) {
44
num_failed++;
45
}
46
}
47
return
num_failed;
48
}
sum
int sum
Definition:
omp_for_schedule_runtime.c:19
omp_testsuite.h
LOOPCOUNT
#define LOOPCOUNT
Definition:
omp_testsuite.h:12
REPETITIONS
#define REPETITIONS
Definition:
omp_testsuite.h:13
sum0
static int sum0
Definition:
omp_threadprivate.c:14
test_omp_threadprivate_for
int test_omp_threadprivate_for()
Definition:
omp_threadprivate_for.c:9
i
static int i
Definition:
omp_threadprivate_for.c:6
main
int main()
Definition:
omp_threadprivate_for.c:37
Generated on Tue Mar 11 2025 11:24:46 for LLVM OpenMP by
1.9.6