9 struct S
{ int s
; struct S
*t
; };
12 foo (struct S
*out
, struct S
*in
)
20 if (x
->s
!= 6) abort ();
25 baz (struct S
*x
, struct S
*y
)
32 #pragma omp declare reduction (foo: struct S: foo (&omp_out, &omp_in)) \
33 initializer (omp_priv = { 8, &omp_priv })
34 #pragma omp declare reduction (foo: char, int, short: omp_out += omp_in - 4) \
35 initializer (omp_priv = 4)
36 #pragma omp declare reduction (+: struct S: foo (&omp_out, &omp_in)) \
37 initializer (baz (&omp_priv, &omp_orig))
40 test (struct S s
, struct S t
)
43 #pragma omp parallel num_threads (4) reduction (+: s, q) reduction (foo: t)
45 if (s
.s
!= 6 || s
.t
!= &s
|| t
.s
!= 8 || t
.t
!= &t
)
51 if (s
.s
!= 12 + 2 * q
|| t
.s
!= 14 + 3 * q
)
60 int h
= 30, v
= 2, q
= 0;
61 #pragma omp declare reduction (foo: struct S: omp_out.s *= omp_in.s) \
62 initializer (omp_priv = omp_orig)
64 #pragma omp declare reduction (foo: struct S: omp_out.s += omp_in.s) \
65 initializer (omp_priv = omp_orig)
66 #pragma omp parallel num_threads (4) reduction (+: t, q) \
67 reduction (min: h) reduction (foo: s, v)
69 if (s
.s
!= 9 || t
.s
!= 6 || v
!= 4 || h
!= __INT_MAX__
) abort ();
70 asm volatile ("" : "+m" (s
.s
), "+m" (t
.s
));
71 asm volatile ("" : "+r" (h
), "+r" (v
));
72 h
= t
.s
; s
.s
++; t
.s
++; v
++; q
++;
75 if (h
!= 6 || s
.s
!= 9 + q
* 10 || t
.s
!= 10 + q
* 7 || v
!= 2 + q
)