111
|
1 /* { dg-do run } */
|
|
2
|
|
3 struct A { int t; };
|
|
4 struct B { char t; };
|
|
5 struct C { unsigned long long t; };
|
|
6 struct D { long t; };
|
|
7 void
|
|
8 add (struct B *x, struct B *y)
|
|
9 {
|
|
10 x->t += y->t;
|
|
11 }
|
|
12 void
|
|
13 zero (struct B *x)
|
|
14 {
|
|
15 x->t = 0;
|
|
16 }
|
|
17 void
|
|
18 orit (struct C *x, struct C *y)
|
|
19 {
|
|
20 y->t |= x->t;
|
|
21 }
|
|
22 #pragma omp declare reduction(+:struct A:omp_out.t += omp_in.t)
|
|
23 #pragma omp declare reduction(+:struct B:add (&omp_out, &omp_in)) initializer(zero (&omp_priv))
|
|
24 #pragma omp declare reduction(*:struct A:omp_out.t *= omp_in.t) initializer(omp_priv = { 1 })
|
|
25 #pragma omp declare reduction(|:struct C:orit (&omp_in, &omp_out))
|
|
26 #pragma omp declare reduction(&:struct D:omp_out.t = omp_out.t & omp_in.t) initializer(omp_priv = { ~0L })
|
|
27 #pragma omp declare reduction(maxb:short:omp_out = omp_in > omp_out ? omp_in : omp_out) initializer(omp_priv = -6)
|
|
28
|
|
29 struct B z[10];
|
|
30
|
|
31 __attribute__((noinline, noclone)) void
|
|
32 foo (struct A (*x)[3][2], struct A *y, struct D w[1][2], int s, int t)
|
|
33 {
|
|
34 struct C a[9] = {};
|
|
35 short b[5] = {};
|
|
36 int i;
|
|
37 #pragma omp parallel for reduction(+:x[-1:2][:][0:2], z[t + 2:4]) \
|
|
38 reduction(*:y[-s:3]) reduction(|:a[s + 3:4]) \
|
|
39 reduction(&:w[s + 1:1][t:2]) reduction(maxb:b[2:])
|
|
40 for (i = 0; i < 128; i++)
|
|
41 {
|
|
42 x[i / 64 - 1][i % 3][(i / 4) & 1].t += i;
|
|
43 if ((i & 15) == 1)
|
|
44 y[1].t *= 3;
|
|
45 if ((i & 31) == 2)
|
|
46 y[2].t *= 7;
|
|
47 if ((i & 63) == 3)
|
|
48 y[3].t *= 17;
|
|
49 z[i / 32 + 2].t += (i & 3);
|
|
50 if (i < 4)
|
|
51 z[i + 2].t += i;
|
|
52 a[i / 32 + 2].t |= 1ULL << (i & 30);
|
|
53 w[0][i & 1].t &= ~(1L << (i / 17 * 3));
|
|
54 if ((i % 23) > b[2])
|
|
55 b[2] = i % 23;
|
|
56 if ((i % 85) > b[3])
|
|
57 b[3] = i % 85;
|
|
58 if ((i % 192) > b[4])
|
|
59 b[4] = i % 192;
|
|
60 }
|
|
61 for (i = 0; i < 9; i++)
|
|
62 if (a[i].t != ((i < 6 && i >= 2) ? 0x55555555ULL : 0))
|
|
63 __builtin_abort ();
|
|
64 if (b[0] != 0 || b[1] != 0 || b[2] != 22 || b[3] != 84 || b[4] != 127)
|
|
65 __builtin_abort ();
|
|
66 }
|
|
67
|
|
68 int
|
|
69 main ()
|
|
70 {
|
|
71 struct A a[4][3][2] = {};
|
|
72 static int a2[4][3][2] = {{{ 0, 0 }, { 0, 0 }, { 0, 0 }},
|
|
73 {{ 312, 381 }, { 295, 356 }, { 337, 335 }},
|
|
74 {{ 1041, 975 }, { 1016, 1085 }, { 935, 1060 }},
|
|
75 {{ 0, 0 }, { 0, 0 }, { 0, 0 }}};
|
|
76 struct A y[5] = { { 0 }, { 1 }, { 1 }, { 1 }, { 0 } };
|
|
77 int y2[5] = { 0, 6561, 2401, 289, 0 };
|
|
78 char z2[10] = { 0, 0, 48, 49, 50, 51, 0, 0, 0, 0 };
|
|
79 struct D w[1][2] = { { { ~0L }, { ~0L } } };
|
|
80 foo (&a[2], y, w, -1, 0);
|
|
81 int i, j, k;
|
|
82 for (i = 0; i < 4; i++)
|
|
83 for (j = 0; j < 3; j++)
|
|
84 for (k = 0; k < 2; k++)
|
|
85 if (a[i][j][k].t != a2[i][j][k])
|
|
86 __builtin_abort ();
|
|
87 for (i = 0; i < 5; i++)
|
|
88 if (y[i].t != y2[i])
|
|
89 __builtin_abort ();
|
|
90 for (i = 0; i < 10; i++)
|
|
91 if (z[i].t != z2[i])
|
|
92 __builtin_abort ();
|
|
93 if (w[0][0].t != ~0x249249L || w[0][1].t != ~0x249249L)
|
|
94 __builtin_abort ();
|
|
95 return 0;
|
|
96 }
|