]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/testsuite/libgomp.c/pr66199-4.c
gcc/
[thirdparty/gcc.git] / libgomp / testsuite / libgomp.c / pr66199-4.c
1 /* PR middle-end/66199 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -fopenmp" } */
4
5 #pragma omp declare target
6 int u[1024], v[1024], w[1024];
7 #pragma omp end declare target
8
9 __attribute__((noinline, noclone)) void
10 f1 (long a, long b)
11 {
12 long d;
13 #pragma omp target teams distribute parallel for default(none) firstprivate (a, b) shared(u, v, w)
14 for (d = a; d < b; d++)
15 u[d] = v[d] + w[d];
16 }
17
18 __attribute__((noinline, noclone)) void
19 f2 (long a, long b, long c)
20 {
21 long d, e;
22 #pragma omp target teams distribute parallel for default(none) firstprivate (a, b, c) shared(u, v, w) lastprivate(d, e)
23 for (d = a; d < b; d++)
24 {
25 u[d] = v[d] + w[d];
26 e = c + d * 5;
27 }
28 }
29
30 __attribute__((noinline, noclone)) void
31 f3 (long a1, long b1, long a2, long b2)
32 {
33 long d1, d2;
34 #pragma omp target teams distribute parallel for default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) lastprivate(d1, d2) collapse(2)
35 for (d1 = a1; d1 < b1; d1++)
36 for (d2 = a2; d2 < b2; d2++)
37 u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2];
38 }
39
40 __attribute__((noinline, noclone)) void
41 f4 (long a1, long b1, long a2, long b2)
42 {
43 long d1, d2;
44 #pragma omp target teams distribute parallel for default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) collapse(2)
45 for (d1 = a1; d1 < b1; d1++)
46 for (d2 = a2; d2 < b2; d2++)
47 u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2];
48 }
49
50 int
51 main ()
52 {
53 f1 (0, 1024);
54 f2 (0, 1024, 17);
55 f3 (0, 32, 0, 32);
56 f4 (0, 32, 0, 32);
57 return 0;
58 }