deep copy does not seem to work for arrays two levels down

I am using deepcopy in PGI 17.7.

I have a type defined as:

      type :: vvec_bc
        type(vvec_bcr) :: r0
        type(vvec_bcr) :: r1
      end type

with

      type :: vvec_bcr
        real(r_typ), dimension(:,:), pointer :: r  
        real(r_typ), dimension(:,:), pointer :: t  
        real(r_typ), dimension(:,:), pointer :: p  
      end type

I then declare

type(vvec_bc) :: vb

which has all its arrays inside allocated.

When I try to use “vb” with deepcopy, it does not work and segfaults:

!$acc enter data copyin(vb)

followed by

!$acc parallel present(vv,vb)
!$acc loop gang worker
        do k=2,npm1
!$acc loop vector
          do j=2,ntm1
            vv%r(1,j,k)=bcmask*vb%r0%r(j,k)
          enddo
        enddo

I instead have to do:

!$acc enter data copyin(vb%r0,vb%r1)

and

!$acc parallel present(vv,vb%r0)
!$acc loop gang worker
        do k=2,npm1
!$acc loop vector
          do j=2,ntm1
            vv%r(1,j,k)=bcmask*vb%r0%r(j,k)
          enddo
        enddo

Can deepcopy only go down one level?

Hi sumseq,

Can deepcopy only go down one level?

It should be able to go down multiple levels (we’ve tested it using multi-levels), but obviously missed this case. Deepcopy is brand new and should be considered beta.

I was able to recreate the error with this simplified version below and have filed a problem report (TPR#24770). If you can, please send in a reproducing example to PGI Customer Service (trs@pgroup.com). We can then attach it to the report and ensure that the problem is the same as what I have below.

Thanks for the report!
Mat


% cat test2.f90
program main
      type :: vvec_bcr
         real, dimension(:,:), pointer :: r
       end type
       type :: vvec_bc
         type(vvec_bcr) :: r0
       end type

       type(vvec_bc) :: vb

      allocate(vb%r0%r(128,128))

      !$acc enter data copyin(vb)
      !$acc kernels loop present(vb)
      do i=1,128
        do j=1,128
          vb%r0%r(i,j)=1.0
        enddo
     enddo
     !$acc exit data copyout(vb)
     print *, vb%r0%r(2,3)
     deallocate(vb%r0%r)

end program main

% pgf90 test2.f90 -ta=tesla:cc60,deepcopy -Minfo=accel
main:
     13, Generating enter data copyin(vb)
     14, Generating present(vb)
     15, Loop is parallelizable
     16, Loop is parallelizable
         Accelerator kernel generated
         Generating Tesla code
         15, !$acc loop gang, vector(128) ! blockidx%x threadidx%x
         16, !$acc loop gang ! blockidx%y
     20, Generating exit data copyout(vb)
% a.out
Segmentation fault

Your example looks exactly what my problem is.

24770 - OpenACC: Deepcopy of multiple leveled UDT causes segv

has been fixed in the current 17.10 release.

dave