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