1 typedef __SIZE_TYPE__ size_t;
2 extern void abort (void);
3
4 void
bar(int * a,int * b,int * c,int (* d)[2],int (* e)[4],size_t n,int f[1][n],int g[1][n * 2])5 bar (int *a, int *b, int *c, int (*d)[2], int (*e)[4], size_t n, int f[1][n], int g[1][n * 2])
6 {
7 #pragma omp task in_reduction (*: a[:n], b[3:n], c[n:n], d[0][:n], e[0][1:n], f[0][:], g[0][1:n])
8 {
9 a[0] *= 12;
10 a[1] *= 13;
11 b[3] *= 14;
12 b[4] *= 15;
13 c[n] *= 16;
14 c[n + 1] *= 17;
15 d[0][0] *= 18;
16 d[0][1] *= 19;
17 e[0][1] *= 20;
18 e[0][2] *= 21;
19 f[0][0] *= 22;
20 f[0][1] *= 23;
21 g[0][1] *= 24;
22 g[0][2] *= 25;
23 }
24 }
25
26 void
foo(size_t n,void * x,void * y,int f[1][n],int g[1][n * 2])27 foo (size_t n, void *x, void *y, int f[1][n], int g[1][n * 2])
28 {
29 int a[n], b[n + 3], c[2 * n];
30 int (*d)[n] = (int (*)[n]) x;
31 int (*e)[n * 2] = (int (*)[n * 2]) y;
32 int i;
33 for (i = 0; i < n; i++)
34 {
35 a[i] = 1;
36 b[i + 3] = 1;
37 c[i + n] = 1;
38 d[0][i] = 1;
39 e[0][i + 1] = 1;
40 f[0][i] = 1;
41 g[0][i + 1] = 1;
42 }
43 #pragma omp taskgroup task_reduction (*: a, b[3:n], c[n:n], d[0][:n], e[0][1:n], f[0][:], g[0][1:n])
44 {
45 bar (a, b, c, (int (*)[2]) d, (int (*)[4]) e, n, f, g);
46 #pragma omp task in_reduction (*: a, b[3:n], c[n:n], d[0][:n], e[0][1:n], f[0][:], g[0][1:n])
47 {
48 a[0] *= 2;
49 a[1] *= 3;
50 b[3] *= 4;
51 b[4] *= 5;
52 c[n] *= 6;
53 c[n + 1] *= 7;
54 d[0][0] *= 8;
55 d[0][1] *= 9;
56 e[0][1] *= 10;
57 e[0][2] *= 11;
58 f[0][0] *= 12;
59 f[0][1] *= 13;
60 g[0][1] *= 14;
61 g[0][2] *= 15;
62 }
63 n = 0;
64 }
65 if (a[0] != 24 || a[1] != 39 || b[3] != 56 || b[4] != 75)
66 abort ();
67 if (c[2] != 96 || c[3] != 119 || d[0][0] != 144 || d[0][1] != 171)
68 abort ();
69 if (e[0][1] != 200 || e[0][2] != 231 || f[0][0] != 264 || f[0][1] != 299)
70 abort ();
71 if (g[0][1] != 336 || g[0][2] != 375)
72 abort ();
73 }
74
75 void
baz(size_t n,void * x,void * y,int f[1][n],int g[1][n * 2])76 baz (size_t n, void *x, void *y, int f[1][n], int g[1][n * 2])
77 {
78 int a[n], b[n + 3], c[2 * n];
79 int (*d)[n] = (int (*)[n]) x;
80 int (*e)[n * 2] = (int (*)[n * 2]) y;
81 int i;
82 for (i = 0; i < n; i++)
83 {
84 a[i] = 1;
85 b[i + 3] = 1;
86 c[i + n] = 1;
87 d[0][i] = 1;
88 e[0][i + 1] = 1;
89 f[0][i] = 1;
90 g[0][i + 1] = 1;
91 }
92 #pragma omp parallel num_threads(2)
93 #pragma omp master
94 #pragma omp taskgroup task_reduction (*: a, b[3:n], c[n:n], d[0][:n], e[0][1:n], f[0][:], g[0][1:n])
95 {
96 bar (a, b, c, (int (*)[2]) d, (int (*)[4]) e, n, f, g);
97 #pragma omp task in_reduction (*: a, b[3:n], c[n:n], d[0][:n], e[0][1:n], f[0][:], g[0][1:n])
98 {
99 a[0] *= 2;
100 a[1] *= 3;
101 b[3] *= 4;
102 b[4] *= 5;
103 c[n] *= 6;
104 c[n + 1] *= 7;
105 d[0][0] *= 8;
106 d[0][1] *= 9;
107 e[0][1] *= 10;
108 e[0][2] *= 11;
109 f[0][0] *= 12;
110 f[0][1] *= 13;
111 g[0][1] *= 14;
112 g[0][2] *= 15;
113 }
114 n = 0;
115 }
116 if (a[0] != 24 || a[1] != 39 || b[3] != 56 || b[4] != 75)
117 abort ();
118 if (c[2] != 96 || c[3] != 119 || d[0][0] != 144 || d[0][1] != 171)
119 abort ();
120 if (e[0][1] != 200 || e[0][2] != 231 || f[0][0] != 264 || f[0][1] != 299)
121 abort ();
122 if (g[0][1] != 336 || g[0][2] != 375)
123 abort ();
124 }
125
126 int
main()127 main ()
128 {
129 int d[1][2], e[1][4], f[1][2], g[1][4];
130 volatile int two;
131 two = 2;
132 #pragma omp parallel num_threads (2)
133 #pragma omp master
134 foo (two, (void *) d, (void *) e, f, g);
135 baz (two, (void *) d, (void *) e, f, g);
136 return 0;
137 }
138