1 struct S
{ int a
, b
, c
[2]; };
2 #pragma omp declare reduction (+: struct S : (omp_out.a += omp_in.a, omp_out.b += omp_in.b)) \
3 initializer (omp_priv = { 0, 0, { 0, 0 } })
6 foo (struct S x
, struct S
*y
, int n
, int v
)
8 struct S z
[3] = { { 45, 47, {} }, { 46, 48, {} }, { 47, 49, {} } };
11 for (i
= 0; i
< n
; i
++)
13 w
[i
].a
= u
[i
].a
= n
+ i
;
14 w
[i
].b
= u
[i
].b
= n
- i
;
15 w
[i
].c
[0] = u
[i
].c
[0] = 0;
16 w
[i
].c
[1] = u
[i
].c
[1] = 0;
18 #pragma omp taskgroup task_reduction (+: x, y[:2], z[1:2], u, w[1:v])
20 #pragma omp task in_reduction (+: x, y[:2], z[1:2], u, w[1:v])
35 #pragma omp target in_reduction (+: x, y[:2], z[1:2], u, w[1:v]) map(tofrom: x.a, x.b, x.c[:2])
50 #pragma omp target in_reduction (+: x, y[:v], z[1:v], u, w[1:2])
66 if (x
.a
!= 56 || y
[0].a
!= 60 || y
[1].a
!= 64)
68 if (x
.b
!= 86 || y
[0].b
!= 100 || y
[1].b
!= 104)
70 if (z
[0].a
!= 45 || z
[1].a
!= 62 || z
[2].a
!= 54)
72 if (z
[0].b
!= 47 || z
[1].b
!= 84 || z
[2].b
!= 66)
74 if (u
[0].a
!= 8 || u
[1].a
!= 12 || u
[2].a
!= 18)
76 if (u
[0].b
!= 18 || u
[1].b
!= 20 || u
[2].b
!= 24)
78 if (w
[0].a
!= 3 || w
[1].a
!= 24 || w
[2].a
!= 12)
80 if (w
[0].b
!= 3 || w
[1].b
!= 42 || w
[2].b
!= 18)
85 bar (struct S x
, struct S
*y
, int n
, int v
)
87 struct S z
[3] = { { 45, 47, {} }, { 46, 48, {} }, { 47, 49, {} } };
90 for (i
= 0; i
< n
; i
++)
92 w
[i
].a
= u
[i
].a
= n
+ i
;
93 w
[i
].b
= u
[i
].b
= n
- i
;
94 w
[i
].c
[0] = u
[i
].c
[0] = 0;
95 w
[i
].c
[1] = u
[i
].c
[1] = 0;
97 #pragma omp parallel master
98 #pragma omp taskgroup task_reduction (+: x, y[:2], z[1:2], u, w[1:v])
100 #pragma omp task in_reduction (+: x, y[:2], z[1:2], u, w[1:v])
115 #pragma omp target in_reduction (+: x, y[:2], z[1:2], u, w[1:v]) map(tofrom: x.a, x.b, x.c[:2])
130 #pragma omp target in_reduction (+: x, y[:v], z[1:v], u, w[1:2])
146 if (x
.a
!= 56 || y
[0].a
!= 77 || y
[1].a
!= 84)
148 if (x
.b
!= 86 || y
[0].b
!= 147 || y
[1].b
!= 154)
150 if (z
[0].a
!= 45 || z
[1].a
!= 62 || z
[2].a
!= 54)
152 if (z
[0].b
!= 47 || z
[1].b
!= 84 || z
[2].b
!= 66)
154 if (u
[0].a
!= 8 || u
[1].a
!= 12 || u
[2].a
!= 18)
156 if (u
[0].b
!= 18 || u
[1].b
!= 20 || u
[2].b
!= 24)
158 if (w
[0].a
!= 3 || w
[1].a
!= 24 || w
[2].a
!= 12)
160 if (w
[0].b
!= 3 || w
[1].b
!= 42 || w
[2].b
!= 18)
167 struct S x
= { 42, 52 };
168 struct S y
[2] = { { 43, 53 }, { 44, 54 } };
169 #pragma omp parallel master