1 extern "C" void abort ();
2
3 int as[2];
4 int (&a)[2] = as;
5 long long int bs[7] = { 9, 11, 1, 1, 1, 13, 15 };
6 long long int (&b)[7] = bs;
7 int es[3] = { 5, 0, 5 };
8 int (&e)[3] = es;
9 int fs[5] = { 6, 7, 0, 0, 9 };
10 int (&f)[5] = fs;
11 int gs[4] = { 1, 0, 0, 2 };
12 int (&g)[4] = gs;
13 int hs[3] = { 0, 1, 4 };
14 int (&h)[3] = hs;
15 int ks[4][2] = { { 5, 6 }, { 0, 0 }, { 0, 0 }, { 7, 8 } };
16 int (&k)[4][2] = ks;
17 long long *ss;
18 long long *&s = ss;
19 long long (*ts)[2];
20 long long (*&t)[2] = ts;
21
22 template <typename T>
23 void
foo(T & n,T * & c,long long int * & d,T (& m)[3],T * & r,T (& o)[4],T * & p,T (& q)[4][2])24 foo (T &n, T *&c, long long int *&d, T (&m)[3], T *&r, T (&o)[4], T *&p, T (&q)[4][2])
25 {
26 T i;
27 for (i = 0; i < 2; i++)
28 #pragma omp task in_reduction (+: a, c[:2]) in_reduction (*: b[2 * n:3 * n], d[0:2]) \
29 in_reduction (+: o[n:n*2], m[1], k[1:2][:], p[0], f[2:2]) \
30 in_reduction (+: q[1:2][:], g[n:n*2], e[1], h[0], r[2:2]) \
31 in_reduction (*: s[1:2], t[2:2][:])
32 {
33 a[0] += 7;
34 a[1] += 17;
35 b[2] *= 2;
36 b[4] *= 2;
37 c[0] += 6;
38 d[1] *= 2;
39 e[1] += 19;
40 f[2] += 21;
41 f[3] += 23;
42 g[1] += 25;
43 g[2] += 27;
44 h[0] += 29;
45 k[1][0] += 31;
46 k[2][1] += 33;
47 m[1] += 19;
48 r[2] += 21;
49 r[3] += 23;
50 o[1] += 25;
51 o[2] += 27;
52 p[0] += 29;
53 q[1][0] += 31;
54 q[2][1] += 33;
55 s[1] *= 2;
56 t[2][0] *= 2;
57 t[3][1] *= 2;
58 }
59 }
60
61 template <typename T>
62 void
test(T & n)63 test (T &n)
64 {
65 T cs[2] = { 0, 0 };
66 T (&c)[2] = cs;
67 T ps[3] = { 0, 1, 4 };
68 T (&p)[3] = ps;
69 T qs[4][2] = { { 5, 6 }, { 0, 0 }, { 0, 0 }, { 7, 8 } };
70 T (&q)[4][2] = qs;
71 long long sb[4] = { 5, 1, 1, 6 };
72 long long tb[5][2] = { { 9, 10 }, { 11, 12 }, { 1, 1 }, { 1, 1 }, { 13, 14 } };
73 T ms[3] = { 5, 0, 5 };
74 T os[4] = { 1, 0, 0, 2 };
75 s = sb;
76 t = tb;
77 #pragma omp parallel
78 #pragma omp single
79 {
80 long long int ds[] = { 1, 1 };
81 long long int (&d)[2] = ds;
82 T (&m)[3] = ms;
83 T rs[5] = { 6, 7, 0, 0, 9 };
84 T (&r)[5] = rs;
85 T (&o)[4] = os;
86 #pragma omp taskgroup task_reduction (+: a, c) task_reduction (*: b[2 * n:3 * n], d) \
87 task_reduction (+: e[1], f[2:2], g[n:n*2], h[0], k[1:2][0:2]) \
88 task_reduction (+: o[n:n*2], m[1], q[1:2][:], p[0], r[2:2]) \
89 task_reduction (*: t[2:2][:], s[1:n + 1])
90 {
91 T i;
92 for (i = 0; i < 4; i++)
93 #pragma omp task in_reduction (+: a, c) in_reduction (*: b[2 * n:3 * n], d) \
94 in_reduction (+: o[n:n*2], q[1:2][:], p[0], m[1], r[2:2]) \
95 in_reduction (+: g[n:n * 2], e[1], k[1:2][:], h[0], f[2:2]) \
96 in_reduction (*: s[1:2], t[2:2][:])
97 {
98 T j;
99 a[0] += 2;
100 a[1] += 3;
101 b[2] *= 2;
102 f[3] += 8;
103 g[1] += 9;
104 g[2] += 10;
105 h[0] += 11;
106 k[1][1] += 13;
107 k[2][1] += 15;
108 m[1] += 16;
109 r[2] += 8;
110 s[1] *= 2;
111 t[2][1] *= 2;
112 t[3][1] *= 2;
113 for (j = 0; j < 2; j++)
114 #pragma omp task in_reduction (+: a, c[:2]) \
115 in_reduction (*: b[2 * n:3 * n], d[n - 1:n + 1]) \
116 in_reduction (+: e[1], f[2:2], g[n:n*2], h[0], k[1:2][:2]) \
117 in_reduction (+: m[1], r[2:2], o[n:n*2], p[0], q[1:2][:2]) \
118 in_reduction (*: s[n:2], t[2:2][:])
119 {
120 m[1] += 6;
121 r[2] += 7;
122 q[1][0] += 17;
123 q[2][0] += 19;
124 a[0] += 4;
125 a[1] += 5;
126 b[3] *= 2;
127 b[4] *= 2;
128 f[3] += 18;
129 g[1] += 29;
130 g[2] += 18;
131 h[0] += 19;
132 s[2] *= 2;
133 t[2][0] *= 2;
134 t[3][0] *= 2;
135 T *cp = c;
136 long long int *dp = d;
137 T *rp = r;
138 T *pp = p;
139 foo (n, cp, dp, m, rp, o, pp, q);
140 r[3] += 18;
141 o[1] += 29;
142 o[2] += 18;
143 p[0] += 19;
144 c[0] += 4;
145 c[1] += 5;
146 d[0] *= 2;
147 e[1] += 6;
148 f[2] += 7;
149 k[1][0] += 17;
150 k[2][0] += 19;
151 }
152 r[3] += 8;
153 o[1] += 9;
154 o[2] += 10;
155 p[0] += 11;
156 q[1][1] += 13;
157 q[2][1] += 15;
158 b[3] *= 2;
159 c[0] += 4;
160 c[1] += 9;
161 d[0] *= 2;
162 e[1] += 16;
163 f[2] += 8;
164 }
165 }
166 if (d[0] != 1LL << (8 + 4)
167 || d[1] != 1LL << 16
168 || m[0] != 5
169 || m[1] != 19 * 16 + 6 * 8 + 16 * 4
170 || m[2] != 5
171 || r[0] != 6
172 || r[1] != 7
173 || r[2] != 21 * 16 + 7 * 8 + 8 * 4
174 || r[3] != 23 * 16 + 18 * 8 + 8 * 4
175 || r[4] != 9
176 || o[0] != 1
177 || o[1] != 25 * 16 + 29 * 8 + 9 * 4
178 || o[2] != 27 * 16 + 18 * 8 + 10 * 4
179 || o[3] != 2)
180 abort ();
181 }
182 if (a[0] != 7 * 16 + 4 * 8 + 2 * 4
183 || a[1] != 17 * 16 + 5 * 8 + 3 * 4
184 || b[0] != 9 || b[1] != 11
185 || b[2] != 1LL << (16 + 4)
186 || b[3] != 1LL << (8 + 4)
187 || b[4] != 1LL << (16 + 8)
188 || b[5] != 13 || b[6] != 15
189 || c[0] != 6 * 16 + 4 * 8 + 4 * 4
190 || c[1] != 5 * 8 + 9 * 4
191 || e[0] != 5
192 || e[1] != 19 * 16 + 6 * 8 + 16 * 4
193 || e[2] != 5
194 || f[0] != 6
195 || f[1] != 7
196 || f[2] != 21 * 16 + 7 * 8 + 8 * 4
197 || f[3] != 23 * 16 + 18 * 8 + 8 * 4
198 || f[4] != 9
199 || g[0] != 1
200 || g[1] != 25 * 16 + 29 * 8 + 9 * 4
201 || g[2] != 27 * 16 + 18 * 8 + 10 * 4
202 || g[3] != 2
203 || h[0] != 29 * 16 + 19 * 8 + 11 * 4
204 || h[1] != 1 || h[2] != 4
205 || k[0][0] != 5 || k[0][1] != 6
206 || k[1][0] != 31 * 16 + 17 * 8
207 || k[1][1] != 13 * 4
208 || k[2][0] != 19 * 8
209 || k[2][1] != 33 * 16 + 15 * 4
210 || k[3][0] != 7 || k[3][1] != 8
211 || p[0] != 29 * 16 + 19 * 8 + 11 * 4
212 || p[1] != 1 || p[2] != 4
213 || q[0][0] != 5 || q[0][1] != 6
214 || q[1][0] != 31 * 16 + 17 * 8
215 || q[1][1] != 13 * 4
216 || q[2][0] != 19 * 8
217 || q[2][1] != 33 * 16 + 15 * 4
218 || q[3][0] != 7 || q[3][1] != 8
219 || sb[0] != 5
220 || sb[1] != 1LL << (16 + 4)
221 || sb[2] != 1LL << 8
222 || sb[3] != 6
223 || tb[0][0] != 9 || tb[0][1] != 10 || tb[1][0] != 11 || tb[1][1] != 12
224 || tb[2][0] != 1LL << (16 + 8)
225 || tb[2][1] != 1LL << 4
226 || tb[3][0] != 1LL << 8
227 || tb[3][1] != 1LL << (16 + 4)
228 || tb[4][0] != 13 || tb[4][1] != 14)
229 abort ();
230 }
231
232 int
main()233 main ()
234 {
235 int n = 1;
236 test (n);
237 return 0;
238 }
239