diff options
author | utsumi <utsumi.yuichiro@jp.fujitsu.com> | 2022-08-23 07:18:23 -0700 |
---|---|---|
committer | Alexey Bataev <a.bataev@outlook.com> | 2022-08-23 07:58:35 -0700 |
commit | 2e2caea37f4b70568cec180e5af12ee532aba0af (patch) | |
tree | a4d7db2f72ab6a10cf46d6fe2dbff64400ceaafd /openmp/runtime | |
parent | c9608d57b8ffa0102cb645fb5b42621831bf4d40 (diff) | |
download | llvm-2e2caea37f4b70568cec180e5af12ee532aba0af.zip llvm-2e2caea37f4b70568cec180e5af12ee532aba0af.tar.gz llvm-2e2caea37f4b70568cec180e5af12ee532aba0af.tar.bz2 |
[Clang][OpenMP] Make copyin clause on combined and composite construct work (patch by Yuichiro Utsumi (utsumi.yuichiro@fujitsu.com))
Make copyin clause on the following constructs work.
- parallel for
- parallel for simd
- parallel sections
Fixes https://github.com/llvm/llvm-project/issues/55547
Patch by Yuichiro Utsumi (utsumi.yuichiro@fujitsu.com)
Reviewed By: ABataev
Differential Revision: https://reviews.llvm.org/D132209
Diffstat (limited to 'openmp/runtime')
-rw-r--r-- | openmp/runtime/test/parallel/omp_parallel_copyin_combined.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/openmp/runtime/test/parallel/omp_parallel_copyin_combined.c b/openmp/runtime/test/parallel/omp_parallel_copyin_combined.c new file mode 100644 index 0000000..b2f3012 --- /dev/null +++ b/openmp/runtime/test/parallel/omp_parallel_copyin_combined.c @@ -0,0 +1,110 @@ +// RUN: %libomp-compile-and-run +#include "omp_testsuite.h" + +#define N 100 + +int x1, x2, x3, x4, x5; +#pragma omp threadprivate(x1, x2, x3, x4, x5) + +int test_omp_parallel_copyin() { + int a[N]; + x1 = 1; + +#pragma omp parallel copyin(x1) +#pragma omp for + for (int i = 0; i < N; i++) + a[i] = i + x1; + + int sum = 0; + + for (int i = 0; i < N; i++) + sum += a[i]; + + return (sum == ((99 + 2 * x1) * 100) / 2); +} + +int test_omp_parallel_for_copyin() { + int a[N]; + x2 = 2; + +#pragma omp parallel for copyin(x2) + for (int i = 0; i < N; i++) + a[i] = i + x2; + + int sum = 0; + + for (int i = 0; i < N; i++) + sum += a[i]; + + return (sum == ((99 + 2 * x2) * 100) / 2); +} + +int test_omp_parallel_for_simd_copyin() { + int a[N]; + x3 = 3; + +#pragma omp parallel for simd copyin(x3) + for (int i = 0; i < N; i++) + a[i] = i + x3; + + int sum = 0; + + for (int i = 0; i < N; i++) + sum += a[i]; + + return (sum == ((99 + 2 * x3) * 100) / 2); +} + +int test_omp_parallel_sections_copyin() { + int a = 0; + int b = 0; + x4 = 4; + +#pragma omp parallel sections copyin(x4) + { +#pragma omp section + { a = x4; } + +#pragma omp section + { b = x4; } + } + + return (a + b == x4 * 2); +} + +int test_omp_parallel_master_copyin() { + int a[N]; + x5 = 5; + +#pragma omp parallel master copyin(x5) + for (int i = 0; i < N; i++) + a[i] = i + x5; + + int sum = 0; + + for (int i = 0; i < N; i++) + sum += a[i]; + + return (sum == ((99 + 2 * x5) * 100) / 2); +} + +int main() { + int num_failed = 0; + + if (!test_omp_parallel_copyin()) + num_failed++; + + if (!test_omp_parallel_for_copyin()) + num_failed++; + + if (!test_omp_parallel_for_simd_copyin()) + num_failed++; + + if (!test_omp_parallel_sections_copyin()) + num_failed++; + + if (!test_omp_parallel_master_copyin()) + num_failed++; + + return num_failed; +} |