LLVM OpenMP
20.0.0git
runtime
test
worksharing
for
omp_parallel_for_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_parallel_for_firstprivate
()
6
{
7
int
sum
;
8
int
i2;
9
int
i
;
10
int
known_sum;
11
12
sum
=0;
13
i2=3;
14
15
#pragma omp parallel for reduction(+:sum) private(i) firstprivate(i2)
16
for
(
i
= 1;
i
<=
LOOPCOUNT
;
i
++) {
17
sum
=
sum
+ (
i
+ i2);
18
}
19
20
known_sum = (
LOOPCOUNT
* (
LOOPCOUNT
+ 1)) / 2 + i2 *
LOOPCOUNT
;
21
return
(known_sum ==
sum
);
22
}
/* end of check_parallel_for_fistprivate */
23
24
int
main
()
25
{
26
int
i
;
27
int
num_failed=0;
28
29
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
30
if
(!
test_omp_parallel_for_firstprivate
()) {
31
num_failed++;
32
}
33
}
34
return
num_failed;
35
}
i
#define i
Definition:
kmp_stub.cpp:87
sum
int sum
Definition:
omp_for_schedule_runtime.c:19
main
int main()
Definition:
omp_parallel_for_firstprivate.c:24
test_omp_parallel_for_firstprivate
int test_omp_parallel_for_firstprivate()
Definition:
omp_parallel_for_firstprivate.c:5
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