Hi,
I am trying to allocate memory on the GPU that persists between subroutine calls. My understanding is that
c$acc declare device_resident(a, b)
when placed in a module will ensure that a and b, when allocated, exist on the GPU for the duration of the program. The program below compiles fine, but fails at run-time with the following error:
FATAL ERROR: data in PRESENT clause was not found: name=b
file:/lcpscratch/patnaik/openACC/tests/test2.f init line:21
My best guess is that the allocation is not happening on the GPU but on the CPU. I do not want to have a data directive with all GPU variables in the main, I want to isolate them into modules. Please help.
Regards, Gopal
c
compile with: pgfortran -acc -Minfo=accel test2.f
c
module acc_data
integer, parameter :: NX = 100000, NY = 1000
c$acc declare device_resident(a, b)
real, allocatable, save, dimension(:,:) :: a, b
real, allocatable, save, dimension(:,:) :: c
contains
subroutine init
integer :: i, j
allocate (a(NX,NY),b(NX,NY))
allocate (c(NX,NY))
c$acc kernels loop present (a,b)
do j = 1, NY
do i = 1, NX
a(i,j) = 1.3
b(i,j) = 3.4
end do
end do
return
end subroutine init
end module acc_data
program test2
use acc_data
implicit none
integer :: i, j
call init
c$acc kernels loop present (a,b) copyout(c)
do j = 1, NY
do i = 1, NX
c(i,j) = a(i,j)**b(i,j)
end do
end do
c$acc end kernels loop
write(*,*)sum(c(1,:))
stop
end