[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / parallel / omp_parallel_copyin_combined.c
blobb2f3012eb1b5fc63a98f52d79f0af2db78955c0c
1 // RUN: %libomp-compile-and-run
2 #include "omp_testsuite.h"
4 #define N 100
6 int x1, x2, x3, x4, x5;
7 #pragma omp threadprivate(x1, x2, x3, x4, x5)
9 int test_omp_parallel_copyin() {
10 int a[N];
11 x1 = 1;
13 #pragma omp parallel copyin(x1)
14 #pragma omp for
15 for (int i = 0; i < N; i++)
16 a[i] = i + x1;
18 int sum = 0;
20 for (int i = 0; i < N; i++)
21 sum += a[i];
23 return (sum == ((99 + 2 * x1) * 100) / 2);
26 int test_omp_parallel_for_copyin() {
27 int a[N];
28 x2 = 2;
30 #pragma omp parallel for copyin(x2)
31 for (int i = 0; i < N; i++)
32 a[i] = i + x2;
34 int sum = 0;
36 for (int i = 0; i < N; i++)
37 sum += a[i];
39 return (sum == ((99 + 2 * x2) * 100) / 2);
42 int test_omp_parallel_for_simd_copyin() {
43 int a[N];
44 x3 = 3;
46 #pragma omp parallel for simd copyin(x3)
47 for (int i = 0; i < N; i++)
48 a[i] = i + x3;
50 int sum = 0;
52 for (int i = 0; i < N; i++)
53 sum += a[i];
55 return (sum == ((99 + 2 * x3) * 100) / 2);
58 int test_omp_parallel_sections_copyin() {
59 int a = 0;
60 int b = 0;
61 x4 = 4;
63 #pragma omp parallel sections copyin(x4)
65 #pragma omp section
66 { a = x4; }
68 #pragma omp section
69 { b = x4; }
72 return (a + b == x4 * 2);
75 int test_omp_parallel_master_copyin() {
76 int a[N];
77 x5 = 5;
79 #pragma omp parallel master copyin(x5)
80 for (int i = 0; i < N; i++)
81 a[i] = i + x5;
83 int sum = 0;
85 for (int i = 0; i < N; i++)
86 sum += a[i];
88 return (sum == ((99 + 2 * x5) * 100) / 2);
91 int main() {
92 int num_failed = 0;
94 if (!test_omp_parallel_copyin())
95 num_failed++;
97 if (!test_omp_parallel_for_copyin())
98 num_failed++;
100 if (!test_omp_parallel_for_simd_copyin())
101 num_failed++;
103 if (!test_omp_parallel_sections_copyin())
104 num_failed++;
106 if (!test_omp_parallel_master_copyin())
107 num_failed++;
109 return num_failed;