2015-11-30 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / libgomp / testsuite / libgomp.c / pr66199-8.c
blob102af0691ec8f72df4ac310b4cbe7f812af35a36
1 /* PR middle-end/66199 */
2 /* { dg-do run } */
4 #pragma omp declare target
5 int u[1024], v[1024], w[1024];
6 #pragma omp end declare target
8 __attribute__((noinline, noclone)) long
9 f1 (long a, long b)
11 long d;
12 #pragma omp target map(from: d)
13 #pragma omp teams default(none) shared(a, b, d, u, v, w)
14 #pragma omp distribute simd firstprivate (a, b)
15 for (d = a; d < b; d++)
16 u[d] = v[d] + w[d];
17 return d;
20 __attribute__((noinline, noclone)) long
21 f2 (long a, long b, long c)
23 long d, e;
24 #pragma omp target map(from: d, e)
25 #pragma omp teams default(none) firstprivate (a, b, c) shared(d, e, u, v, w)
26 #pragma omp distribute simd linear(d) lastprivate(e)
27 for (d = a; d < b; d++)
29 u[d] = v[d] + w[d];
30 e = c + d * 5;
32 return d + e;
35 __attribute__((noinline, noclone)) long
36 f3 (long a1, long b1, long a2, long b2)
38 long d1, d2;
39 #pragma omp target map(from: d1, d2)
40 #pragma omp teams default(none) shared(a1, b1, a2, b2, d1, d2, u, v, w)
41 #pragma omp distribute simd firstprivate (a1, b1, a2, b2) lastprivate(d1, d2) collapse(2)
42 for (d1 = a1; d1 < b1; d1++)
43 for (d2 = a2; d2 < b2; d2++)
44 u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2];
45 return d1 + d2;
48 __attribute__((noinline, noclone)) long
49 f4 (long a1, long b1, long a2, long b2)
51 long d1, d2;
52 #pragma omp target map(from: d1, d2)
53 #pragma omp teams default(none) firstprivate (a1, b1, a2, b2) shared(d1, d2, u, v, w)
54 #pragma omp distribute simd collapse(2)
55 for (d1 = a1; d1 < b1; d1++)
56 for (d2 = a2; d2 < b2; d2++)
57 u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2];
58 return d1 + d2;
61 int
62 main ()
64 if (f1 (0, 1024) != 1024
65 || f2 (0, 1024, 17) != 1024 + (17 + 5 * 1023)
66 || f3 (0, 32, 0, 32) != 64
67 || f4 (0, 32, 0, 32) != 64)
68 __builtin_abort ();
69 return 0;