3 /* double reductions. */
16 double vresult
, result
, array
[n
];
17 bool lvresult
, lresult
;
19 for (i
= 0; i
< n
; i
++)
26 #pragma acc parallel vector_length (vl)
27 #pragma acc loop reduction (+:result)
28 for (i
= 0; i
< n
; i
++)
31 /* Verify the reduction. */
32 for (i
= 0; i
< n
; i
++)
35 if (result
!= vresult
)
42 #pragma acc parallel vector_length (vl)
43 #pragma acc loop reduction (*:result)
44 for (i
= 0; i
< n
; i
++)
47 /* Verify the reduction. */
48 for (i
= 0; i
< n
; i
++)
51 if (fabs(result
- vresult
) > .0001)
56 // /* 'max' reductions. */
57 // #pragma acc parallel vector_length (vl)
58 // #pragma acc loop reduction (+:result)
59 // for (i = 0; i < n; i++)
60 // result = result > array[i] ? result : array[i];
62 // /* Verify the reduction. */
63 // for (i = 0; i < n; i++)
64 // vresult = vresult > array[i] ? vresult : array[i];
66 // printf("%d != %d\n", result, vresult);
67 // if (result != vresult)
73 // /* 'min' reductions. */
74 // #pragma acc parallel vector_length (vl)
75 // #pragma acc loop reduction (+:result)
76 // for (i = 0; i < n; i++)
77 // result = result < array[i] ? result : array[i];
79 // /* Verify the reduction. */
80 // for (i = 0; i < n; i++)
81 // vresult = vresult < array[i] ? vresult : array[i];
83 // printf("%d != %d\n", result, vresult);
84 // if (result != vresult)
93 /* '&&' reductions. */
94 #pragma acc parallel vector_length (vl)
95 #pragma acc loop reduction (&&:lresult)
96 for (i
= 0; i
< n
; i
++)
97 lresult
= lresult
&& (result
> array
[i
]);
99 /* Verify the reduction. */
100 for (i
= 0; i
< n
; i
++)
101 lvresult
= lresult
&& (result
> array
[i
]);
103 if (lresult
!= lvresult
)
112 /* '||' reductions. */
113 #pragma acc parallel vector_length (vl)
114 #pragma acc loop reduction (||:lresult)
115 for (i
= 0; i
< n
; i
++)
116 lresult
= lresult
|| (result
> array
[i
]);
118 /* Verify the reduction. */
119 for (i
= 0; i
< n
; i
++)
120 lvresult
= lresult
|| (result
> array
[i
]);
122 if (lresult
!= lvresult
)