Skip gnat.dg/prot7.adb on hppa.
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / taskloop-reduction-2.c
blob8fc05dc668e2ae6727d9dbec22e8346bed833301
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 #pragma omp taskloop in_reduction (+: a, c[:2]) in_reduction (*: b[2 * n:3 * n], d[0:2]) \
21 in_reduction (+: o[n:n*2], m[1], k[1:2][:], p[0], f[2:2]) \
22 in_reduction (+: q[1:2][:], g[n:n*2], e[1], h[0], r[2:2]) \
23 in_reduction (*: s[1:2], t[2:2][:]) nogroup
24 for (i = 0; i < 2; i++)
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 int i;
72 #pragma omp taskloop reduction (+: a, c) reduction (default, *: b[2 * n:3 * n], d) \
73 reduction (+: e[1], f[2:2], g[n:n*2], h[0], k[1:2][0:2]) \
74 reduction (default, +: o[n:n*2], m[1], q[1:2][:], p[0], r[2:2]) \
75 reduction (*: t[2:2][:], s[1:n + 1])
76 for (i = 0; i < 4; i++)
78 int j;
79 a[0] += 2;
80 a[1] += 3;
81 b[2] *= 2;
82 f[3] += 8;
83 g[1] += 9;
84 g[2] += 10;
85 h[0] += 11;
86 k[1][1] += 13;
87 k[2][1] += 15;
88 m[1] += 16;
89 r[2] += 8;
90 s[1] *= 2;
91 t[2][1] *= 2;
92 t[3][1] *= 2;
93 #pragma omp taskloop in_reduction (+: a, c[:2]) \
94 in_reduction (*: b[2 * n:3 * n], d[n - 1:n + 1]) \
95 in_reduction (+: e[1], f[2:2], g[n:n*2], h[0], k[1:2][:2]) \
96 in_reduction (+: m[1], r[2:2], o[n:n*2], p[0], q[1:2][:2]) \
97 in_reduction (*: s[n:2], t[2:2][:]) nogroup
98 for (j = 0; j < 2; j++)
100 m[1] += 6;
101 r[2] += 7;
102 q[1][0] += 17;
103 q[2][0] += 19;
104 a[0] += 4;
105 a[1] += 5;
106 b[3] *= 2;
107 b[4] *= 2;
108 f[3] += 18;
109 g[1] += 29;
110 g[2] += 18;
111 h[0] += 19;
112 s[2] *= 2;
113 t[2][0] *= 2;
114 t[3][0] *= 2;
115 foo (n, c, d, m, r, o, p, q);
116 r[3] += 18;
117 o[1] += 29;
118 o[2] += 18;
119 p[0] += 19;
120 c[0] += 4;
121 c[1] += 5;
122 d[0] *= 2;
123 e[1] += 6;
124 f[2] += 7;
125 k[1][0] += 17;
126 k[2][0] += 19;
128 r[3] += 8;
129 o[1] += 9;
130 o[2] += 10;
131 p[0] += 11;
132 q[1][1] += 13;
133 q[2][1] += 15;
134 b[3] *= 2;
135 c[0] += 4;
136 c[1] += 9;
137 d[0] *= 2;
138 e[1] += 16;
139 f[2] += 8;
141 if (d[0] != 1LL << (8 + 4)
142 || d[1] != 1LL << 16
143 || m[0] != 5
144 || m[1] != 19 * 16 + 6 * 8 + 16 * 4
145 || m[2] != 5
146 || r[0] != 6
147 || r[1] != 7
148 || r[2] != 21 * 16 + 7 * 8 + 8 * 4
149 || r[3] != 23 * 16 + 18 * 8 + 8 * 4
150 || r[4] != 9
151 || o[0] != 1
152 || o[1] != 25 * 16 + 29 * 8 + 9 * 4
153 || o[2] != 27 * 16 + 18 * 8 + 10 * 4
154 || o[3] != 2)
155 abort ();
157 if (a[0] != 7 * 16 + 4 * 8 + 2 * 4
158 || a[1] != 17 * 16 + 5 * 8 + 3 * 4
159 || b[0] != 9 || b[1] != 11
160 || b[2] != 1LL << (16 + 4)
161 || b[3] != 1LL << (8 + 4)
162 || b[4] != 1LL << (16 + 8)
163 || b[5] != 13 || b[6] != 15
164 || c[0] != 6 * 16 + 4 * 8 + 4 * 4
165 || c[1] != 5 * 8 + 9 * 4
166 || e[0] != 5
167 || e[1] != 19 * 16 + 6 * 8 + 16 * 4
168 || e[2] != 5
169 || f[0] != 6
170 || f[1] != 7
171 || f[2] != 21 * 16 + 7 * 8 + 8 * 4
172 || f[3] != 23 * 16 + 18 * 8 + 8 * 4
173 || f[4] != 9
174 || g[0] != 1
175 || g[1] != 25 * 16 + 29 * 8 + 9 * 4
176 || g[2] != 27 * 16 + 18 * 8 + 10 * 4
177 || g[3] != 2
178 || h[0] != 29 * 16 + 19 * 8 + 11 * 4
179 || h[1] != 1 || h[2] != 4
180 || k[0][0] != 5 || k[0][1] != 6
181 || k[1][0] != 31 * 16 + 17 * 8
182 || k[1][1] != 13 * 4
183 || k[2][0] != 19 * 8
184 || k[2][1] != 33 * 16 + 15 * 4
185 || k[3][0] != 7 || k[3][1] != 8
186 || p[0] != 29 * 16 + 19 * 8 + 11 * 4
187 || p[1] != 1 || p[2] != 4
188 || q[0][0] != 5 || q[0][1] != 6
189 || q[1][0] != 31 * 16 + 17 * 8
190 || q[1][1] != 13 * 4
191 || q[2][0] != 19 * 8
192 || q[2][1] != 33 * 16 + 15 * 4
193 || q[3][0] != 7 || q[3][1] != 8
194 || ss[0] != 5
195 || ss[1] != 1LL << (16 + 4)
196 || ss[2] != 1LL << 8
197 || ss[3] != 6
198 || tt[0][0] != 9 || tt[0][1] != 10 || tt[1][0] != 11 || tt[1][1] != 12
199 || tt[2][0] != 1LL << (16 + 8)
200 || tt[2][1] != 1LL << 4
201 || tt[3][0] != 1LL << 8
202 || tt[3][1] != 1LL << (16 + 4)
203 || tt[4][0] != 13 || tt[4][1] != 14)
204 abort ();
208 main ()
210 test (1);
211 return 0;