https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129003
Bug ID: 129003
Summary: [OpenACC] firstprivate of an explicit-shape dummy
array copies only a pointer's worth of data
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jvdelisle at gcc dot gnu.org
Target Milestone: ---
NOTE: I have a draft fix for this in gcc/omp-low.cc
subroutine sub (a, r)
real :: a(16), r(16)
integer :: i
!$acc parallel loop firstprivate(a) copyout(r)
do i = 1, 16
r(i) = a(i) + a(17 - i)
end do
end subroutine
program p
real :: a(16), r(16)
integer :: i
a = [(real (i), i = 1, 16)]
call sub (a, r)
if (any (r /= 17.0)) stop 1
end program
$ gfortran -fopenacc pr.f90 && ./a.out
STOP 1 (at -O0 and -O2)
The dummy is privatized by reference, so lower_omp_target sends the
array's address, but the OpenACC firstprivate size is taken from the
decl's type, a pointer, unless it is a REFERENCE_TYPE or an optional
argument. Only 8 of the 64 bytes reach the device. The OpenMP target
firstprivate path uses omp_privatize_by_reference and is correct.
Expected: the program completes.