Skip gnat.dg/prot7.adb on hppa.
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / task-reduction-3.c
blob8a90e86e8470ea8f4bbd7507261d692b70526ad2
1 #ifdef __cplusplus
2 extern "C"
3 #endif
4 void abort (void);
6 int a[2];
7 long long int b[7] = { 9, 11, 1, 1, 1, 13, 15 };
8 int e[3] = { 5, 0, 5 };
9 int f[5] = { 6, 7, 0, 0, 9 };
10 int g[4] = { 1, 0, 0, 2 };
11 int h[3] = { 0, 1, 4 };
12 int k[4][2] = { { 5, 6 }, { 0, 0 }, { 0, 0 }, { 7, 8 } };
13 long long *s;
14 long long (*t)[2];
16 void
17 foo (int n, int *c, long long int *d, int m[3], int *r, int o[4], int *p, int q[4][2])
19 int i;
20 for (i = 0; i < 2; i++)
21 #pragma omp task in_reduction (+: a, c[:2]) in_reduction (*: b[2 * n:3 * n], d[0:2]) \
22 in_reduction (+: o[n:n*2], m[1], k[1:2][:], p[0], f[2:2]) \
23 in_reduction (+: q[1:2][:], g[n:n*2], e[1], h[0], r[2:2]) \
24 in_reduction (*: s[1:2], t[2:2][:])
26 a[0] += 7;
27 a[1] += 17;
28 b[2] *= 2;
29 b[4] *= 2;
30 c[0] += 6;
31 d[1] *= 2;
32 e[1] += 19;
33 f[2] += 21;
34 f[3] += 23;
35 g[1] += 25;
36 g[2] += 27;
37 h[0] += 29;
38 k[1][0] += 31;
39 k[2][1] += 33;
40 m[1] += 19;
41 r[2] += 21;
42 r[3] += 23;
43 o[1] += 25;
44 o[2] += 27;
45 p[0] += 29;
46 q[1][0] += 31;
47 q[2][1] += 33;
48 s[1] *= 2;
49 t[2][0] *= 2;
50 t[3][1] *= 2;
54 void
55 test (int n)
57 int c[2] = { 0, 0 };
58 int p[3] = { 0, 1, 4 };
59 int q[4][2] = { { 5, 6 }, { 0, 0 }, { 0, 0 }, { 7, 8 } };
60 long long ss[4] = { 5, 1, 1, 6 };
61 long long tt[5][2] = { { 9, 10 }, { 11, 12 }, { 1, 1 }, { 1, 1 }, { 13, 14 } };
62 s = ss;
63 t = tt;
64 #pragma omp parallel
65 #pragma omp single
67 long long int d[] = { 1, 1 };
68 int m[3] = { 5, 0, 5 };
69 int r[5] = { 6, 7, 0, 0, 9 };
70 int o[4] = { 1, 0, 0, 2 };
71 #pragma omp taskgroup task_reduction (+: a, c) task_reduction (*: b[2 * n:3 * n], d) \
72 task_reduction (+: e[1], f[2:2], g[n:n*2], h[0], k[1:2][0:2]) \
73 task_reduction (+: o[n:n*2], m[1], q[1:2][:], p[0], r[2:2]) \
74 task_reduction (*: t[2:2][:], s[1:n + 1])
76 int i;
77 for (i = 0; i < 4; i++)
78 #pragma omp task in_reduction (+: a, c) in_reduction (*: b[2 * n:3 * n], d) \
79 in_reduction (+: o[n:n*2], q[1:2][:], p[0], m[1], r[2:2]) \
80 in_reduction (+: g[n:n * 2], e[1], k[1:2][:], h[0], f[2:2]) \
81 in_reduction (*: s[1:2], t[2:2][:])
83 int j;
84 a[0] += 2;
85 a[1] += 3;
86 b[2] *= 2;
87 f[3] += 8;
88 g[1] += 9;
89 g[2] += 10;
90 h[0] += 11;
91 k[1][1] += 13;
92 k[2][1] += 15;
93 m[1] += 16;
94 r[2] += 8;
95 s[1] *= 2;
96 t[2][1] *= 2;
97 t[3][1] *= 2;
98 for (j = 0; j < 2; j++)
99 #pragma omp task in_reduction (+: a, c[:2]) \
100 in_reduction (*: b[2 * n:3 * n], d[n - 1:n + 1]) \
101 in_reduction (+: e[1], f[2:2], g[n:n*2], h[0], k[1:2][:2]) \
102 in_reduction (+: m[1], r[2:2], o[n:n*2], p[0], q[1:2][:2]) \
103 in_reduction (*: s[n:2], t[2:2][:])
105 m[1] += 6;
106 r[2] += 7;
107 q[1][0] += 17;
108 q[2][0] += 19;
109 a[0] += 4;
110 a[1] += 5;
111 b[3] *= 2;
112 b[4] *= 2;
113 f[3] += 18;
114 g[1] += 29;
115 g[2] += 18;
116 h[0] += 19;
117 s[2] *= 2;
118 t[2][0] *= 2;
119 t[3][0] *= 2;
120 foo (n, c, d, m, r, o, p, q);
121 r[3] += 18;
122 o[1] += 29;
123 o[2] += 18;
124 p[0] += 19;
125 c[0] += 4;
126 c[1] += 5;
127 d[0] *= 2;
128 e[1] += 6;
129 f[2] += 7;
130 k[1][0] += 17;
131 k[2][0] += 19;
133 r[3] += 8;
134 o[1] += 9;
135 o[2] += 10;
136 p[0] += 11;
137 q[1][1] += 13;
138 q[2][1] += 15;
139 b[3] *= 2;
140 c[0] += 4;
141 c[1] += 9;
142 d[0] *= 2;
143 e[1] += 16;
144 f[2] += 8;
147 if (d[0] != 1LL << (8 + 4)
148 || d[1] != 1LL << 16
149 || m[0] != 5
150 || m[1] != 19 * 16 + 6 * 8 + 16 * 4
151 || m[2] != 5
152 || r[0] != 6
153 || r[1] != 7
154 || r[2] != 21 * 16 + 7 * 8 + 8 * 4
155 || r[3] != 23 * 16 + 18 * 8 + 8 * 4
156 || r[4] != 9
157 || o[0] != 1
158 || o[1] != 25 * 16 + 29 * 8 + 9 * 4
159 || o[2] != 27 * 16 + 18 * 8 + 10 * 4
160 || o[3] != 2)
161 abort ();
163 if (a[0] != 7 * 16 + 4 * 8 + 2 * 4
164 || a[1] != 17 * 16 + 5 * 8 + 3 * 4
165 || b[0] != 9 || b[1] != 11
166 || b[2] != 1LL << (16 + 4)
167 || b[3] != 1LL << (8 + 4)
168 || b[4] != 1LL << (16 + 8)
169 || b[5] != 13 || b[6] != 15
170 || c[0] != 6 * 16 + 4 * 8 + 4 * 4
171 || c[1] != 5 * 8 + 9 * 4
172 || e[0] != 5
173 || e[1] != 19 * 16 + 6 * 8 + 16 * 4
174 || e[2] != 5
175 || f[0] != 6
176 || f[1] != 7
177 || f[2] != 21 * 16 + 7 * 8 + 8 * 4
178 || f[3] != 23 * 16 + 18 * 8 + 8 * 4
179 || f[4] != 9
180 || g[0] != 1
181 || g[1] != 25 * 16 + 29 * 8 + 9 * 4
182 || g[2] != 27 * 16 + 18 * 8 + 10 * 4
183 || g[3] != 2
184 || h[0] != 29 * 16 + 19 * 8 + 11 * 4
185 || h[1] != 1 || h[2] != 4
186 || k[0][0] != 5 || k[0][1] != 6
187 || k[1][0] != 31 * 16 + 17 * 8
188 || k[1][1] != 13 * 4
189 || k[2][0] != 19 * 8
190 || k[2][1] != 33 * 16 + 15 * 4
191 || k[3][0] != 7 || k[3][1] != 8
192 || p[0] != 29 * 16 + 19 * 8 + 11 * 4
193 || p[1] != 1 || p[2] != 4
194 || q[0][0] != 5 || q[0][1] != 6
195 || q[1][0] != 31 * 16 + 17 * 8
196 || q[1][1] != 13 * 4
197 || q[2][0] != 19 * 8
198 || q[2][1] != 33 * 16 + 15 * 4
199 || q[3][0] != 7 || q[3][1] != 8
200 || ss[0] != 5
201 || ss[1] != 1LL << (16 + 4)
202 || ss[2] != 1LL << 8
203 || ss[3] != 6
204 || tt[0][0] != 9 || tt[0][1] != 10 || tt[1][0] != 11 || tt[1][1] != 12
205 || tt[2][0] != 1LL << (16 + 8)
206 || tt[2][1] != 1LL << 4
207 || tt[3][0] != 1LL << 8
208 || tt[3][1] != 1LL << (16 + 4)
209 || tt[4][0] != 13 || tt[4][1] != 14)
210 abort ();
214 main ()
216 test (1);
217 return 0;