annotate libgomp/testsuite/libgomp.c/reduction-12.c @ 111:04ced10e8804

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