blob: 6f661895a379308cb8244cb41a1d8e405d44f00e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// { dg-do run }
extern "C" void abort ();
struct S
{
int s;
void foo (S &x) { s += x.s; }
S (const S &x) { s = x.s + 1; }
S () { s = 6; }
~S () {}
};
void
bar (S &x, S &y)
{
if (x.s != 6 || y.s != 6)
abort ();
x.s = 8;
}
#pragma omp declare reduction (foo: S: omp_out.foo (omp_in)) \
initializer (omp_priv (omp_orig))
#pragma omp declare reduction (bar : S: omp_out.foo (omp_in)) \
initializer (bar (omp_priv, omp_orig))
S
baz (S x)
{
S r;
int i = 0;
if (x.s != 7 || r.s != 6)
abort ();
#pragma omp parallel reduction (foo: x) reduction (bar: r) \
reduction (+: i)
{
if (x.s != 8 || r.s != 8)
abort ();
x.s = 12;
r.s = 14;
i = 1;
}
if (x.s != 7 + 12 * i || r.s != 6 + 14 * i)
abort ();
return r;
}
void
baz (S &x, S &y)
{
int i = 0, &j = i;
#pragma omp parallel reduction (foo: x) reduction (bar: y) \
reduction (+: i)
{
if (x.s != 7 || y.s != 8)
abort ();
x.s = 12;
y.s = 14;
i = 1;
}
if (x.s != 6 + 12 * j || y.s != 6 + 14 * j)
abort ();
}
int
main ()
{
S s;
baz (s);
S t, u;
baz (t, u);
}
|