I encounter an issue with the PGI compiler and OpenACC when an array of 5 ranks is used in a computational region.
The issue is present from PGI 15.1 to 16.7.
Here is a reproducer.
program testcase_pgi
implicit none
! --variable
integer, parameter :: SIZE=400
real, dimension(SIZE,SIZE,SIZE,4,4) :: velocity
integer :: i,j,k,ig,mx
!-- initialization
velocity=10.0
!
!--loop
do ig=1,4
print *,"ig", ig
!$ACC PARALLEL COPY(velocity(:,:,:,:,:))
!$ACC LOOP COLLAPSE(3)
do k=1,SIZE
do j=1,SIZE
do i=1,SIZE
velocity(i,j,k,ig,ig) = velocity(i,j,k,ig,ig) + 10.0
enddo
enddo
enddo
!$ACC END PARALLEL
enddo
end program testcase_pgi
call to cuMemFreeHost returned error 700: Illegal address during kernel execution
When I run your code, I get the same error for both 15.1 and 16.7. The problem being that your static array is greater than 2GB which requires the medium memory model. Hence the fix is to compile with “-mcmodel=medium”.
% pgfortran -acc test_10_17_16.f90 -V16.7
% a.out
ig 1
ig 2
ig 3
call to cuStreamSynchronize returned error 700: Illegal address during kernel execution
call to cuMemFreeHost returned error 700: Illegal address during kernel execution
% pgfortran -acc test_10_17_16.f90 -V16.7 -mcmodel=medium
% a.out
ig 1
ig 2
ig 3
ig 4
I realized that we are using a dynamic array instead of a static array.
the use of -mcmodel=medium fixes the problem. It is weird to have this issue on dynamic array.