2 ! { dg-additional-options "-w" }
4 ! subroutine reduction with private and firstprivate variables
7 integer, parameter :: n
= 100
8 integer :: i
, j
, vsum
, cs
, arr(n
)
10 call redsub_private (cs
, n
, arr
)
11 call redsub_bogus (cs
, n
)
12 call redsub_combined (cs
, n
, arr
)
22 if (vsum
.ne
. arr(i
)) STOP 1
26 ! This subroutine tests a reduction with an explicit private variable.
28 subroutine redsub_private(sum
, n
, arr
)
29 integer :: sum
, n
, arr(n
)
32 !$acc parallel copyout (arr)
33 !$acc loop gang private (v)
37 !$acc loop vector reduction (+:v)
48 if (arr(i
) .ne
. 100+i
) STOP 2
50 end subroutine redsub_private
53 ! Bogus reduction on a firstprivate variable. The results do
54 ! survive the parallel region. The goal here is to ensure that gfortran
57 subroutine redsub_bogus(sum
, n
)
58 integer :: sum
, n
, arr(n
)
61 !$acc parallel firstprivate(sum)
62 !$acc loop gang worker vector reduction (+:sum)
67 end subroutine redsub_bogus
69 ! This reduction involving a firstprivate variable yields legitimate results.
71 subroutine redsub_combined(sum
, n
, arr
)
72 integer :: sum
, n
, arr(n
)
75 !$acc parallel copy (arr) firstprivate(sum)
80 !$acc loop reduction(+:sum)
88 end subroutine redsub_combined