Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / task-reduction-7.c
blobc656f5ff00bdcf63a9483ea7e37888cd9dd57a2b
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 long long int d[] = { 1, 1 };
63 int m[3] = { 5, 0, 5 };
64 int r[5] = { 6, 7, 0, 0, 9 };
65 int o[4] = { 1, 0, 0, 2 };
66 s = ss;
67 t = tt;
68 #pragma omp parallel reduction (task, +: a, c) reduction (task, *: b[2 * n:3 * n], d) \
69 reduction (task, +: e[1], f[2:2], g[n:n*2], h[0], k[1:2][0:2]) \
70 reduction (task, +: o[n:n*2], m[1], q[1:2][:], p[0], r[2:2]) \
71 reduction (task, *: t[2:2][:], s[1:n + 1]) num_threads(4)
73 int i;
74 #pragma omp for
75 for (i = 0; i < 4; i++)
77 #pragma omp task in_reduction (+: a, c) in_reduction (*: b[2 * n:3 * n], d) \
78 in_reduction (+: o[n:n*2], q[1:2][:], p[0], m[1], r[2:2]) \
79 in_reduction (+: g[n:n * 2], e[1], k[1:2][:], h[0], f[2:2]) \
80 in_reduction (*: s[1:2], t[2:2][:])
82 int j;
83 a[0] += 2;
84 a[1] += 3;
85 b[2] *= 2;
86 f[3] += 8;
87 g[1] += 9;
88 g[2] += 10;
89 h[0] += 11;
90 k[1][1] += 13;
91 k[2][1] += 15;
92 m[1] += 16;
93 r[2] += 8;
94 s[1] *= 2;
95 t[2][1] *= 2;
96 t[3][1] *= 2;
97 for (j = 0; j < 2; j++)
98 #pragma omp task in_reduction (+: a, c[:2]) \
99 in_reduction (*: b[2 * n:3 * n], d[n - 1:n + 1]) \
100 in_reduction (+: e[1], f[2:2], g[n:n*2], h[0], k[1:2][:2]) \
101 in_reduction (+: m[1], r[2:2], o[n:n*2], p[0], q[1:2][:2]) \
102 in_reduction (*: s[n:2], t[2:2][:])
104 m[1] += 6;
105 r[2] += 7;
106 q[1][0] += 17;
107 q[2][0] += 19;
108 a[0] += 4;
109 a[1] += 5;
110 b[3] *= 2;
111 b[4] *= 2;
112 f[3] += 18;
113 g[1] += 29;
114 g[2] += 18;
115 h[0] += 19;
116 s[2] *= 2;
117 t[2][0] *= 2;
118 t[3][0] *= 2;
119 foo (n, c, d, m, r, o, p, q);
120 r[3] += 18;
121 o[1] += 29;
122 o[2] += 18;
123 p[0] += 19;
124 c[0] += 4;
125 c[1] += 5;
126 d[0] *= 2;
127 e[1] += 6;
128 f[2] += 7;
129 k[1][0] += 17;
130 k[2][0] += 19;
132 r[3] += 8;
133 o[1] += 9;
134 o[2] += 10;
135 p[0] += 11;
136 q[1][1] += 13;
137 q[2][1] += 15;
138 b[3] *= 2;
139 c[0] += 4;
140 c[1] += 9;
141 d[0] *= 2;
142 e[1] += 16;
143 f[2] += 8;
147 if (a[0] != 7 * 16 + 4 * 8 + 2 * 4
148 || a[1] != 17 * 16 + 5 * 8 + 3 * 4
149 || b[0] != 9 || b[1] != 11
150 || b[2] != 1LL << (16 + 4)
151 || b[3] != 1LL << (8 + 4)
152 || b[4] != 1LL << (16 + 8)
153 || b[5] != 13 || b[6] != 15
154 || c[0] != 6 * 16 + 4 * 8 + 4 * 4
155 || c[1] != 5 * 8 + 9 * 4
156 || d[0] != 1LL << (8 + 4)
157 || d[1] != 1LL << 16
158 || e[0] != 5
159 || e[1] != 19 * 16 + 6 * 8 + 16 * 4
160 || e[2] != 5
161 || f[0] != 6
162 || f[1] != 7
163 || f[2] != 21 * 16 + 7 * 8 + 8 * 4
164 || f[3] != 23 * 16 + 18 * 8 + 8 * 4
165 || f[4] != 9
166 || g[0] != 1
167 || g[1] != 25 * 16 + 29 * 8 + 9 * 4
168 || g[2] != 27 * 16 + 18 * 8 + 10 * 4
169 || g[3] != 2
170 || h[0] != 29 * 16 + 19 * 8 + 11 * 4
171 || h[1] != 1 || h[2] != 4
172 || k[0][0] != 5 || k[0][1] != 6
173 || k[1][0] != 31 * 16 + 17 * 8
174 || k[1][1] != 13 * 4
175 || k[2][0] != 19 * 8
176 || k[2][1] != 33 * 16 + 15 * 4
177 || k[3][0] != 7 || k[3][1] != 8
178 || m[0] != 5
179 || m[1] != 19 * 16 + 6 * 8 + 16 * 4
180 || m[2] != 5
181 || o[0] != 1
182 || o[1] != 25 * 16 + 29 * 8 + 9 * 4
183 || o[2] != 27 * 16 + 18 * 8 + 10 * 4
184 || o[3] != 2
185 || p[0] != 29 * 16 + 19 * 8 + 11 * 4
186 || p[1] != 1 || p[2] != 4
187 || q[0][0] != 5 || q[0][1] != 6
188 || q[1][0] != 31 * 16 + 17 * 8
189 || q[1][1] != 13 * 4
190 || q[2][0] != 19 * 8
191 || q[2][1] != 33 * 16 + 15 * 4
192 || q[3][0] != 7 || q[3][1] != 8
193 || r[0] != 6
194 || r[1] != 7
195 || r[2] != 21 * 16 + 7 * 8 + 8 * 4
196 || r[3] != 23 * 16 + 18 * 8 + 8 * 4
197 || r[4] != 9
198 || ss[0] != 5
199 || ss[1] != 1LL << (16 + 4)
200 || ss[2] != 1LL << 8
201 || ss[3] != 6
202 || tt[0][0] != 9 || tt[0][1] != 10 || tt[1][0] != 11 || tt[1][1] != 12
203 || tt[2][0] != 1LL << (16 + 8)
204 || tt[2][1] != 1LL << 4
205 || tt[3][0] != 1LL << 8
206 || tt[3][1] != 1LL << (16 + 4)
207 || tt[4][0] != 13 || tt[4][1] != 14)
208 abort ();
212 main ()
214 test (1);
215 return 0;