Dear All,
I create a new topic on what seems to us a different issue, even though always related to the use of arrays in OpenACC (the first topic was Wrong results when using vector clause in parallel loop with array syntax).
It seems that the acc data copyout clause requires the array bounds to be explicited even when only one element of an array has to be accessed, namely: to copyout only the inner ith element of an array (computed on GPUs) one should write:
!$acc data copyout(a(i:i))
If we write:
!$acc data copyout(a(i))
what happens is:
34, Generating copyout(a(:i)) [if not already present]
while the the copyout(a(i:i)):
34, Generating copyout(a(2)) [if not already present]
which is what we want. Is that a known feature? can’t I use the syntax a(i) for specifying a single element?
Thank you for any clarification you may provide,
best
Isabella
Toy reproducer of the error:
! nvfortran -c -o test.o test.F90 -cuda -acc -gpu=cc70 -Minfo=accel -g -r8 -traceback -Mnoinline
! nvfortran -o test test.o -cuda -acc -gpu=cc70 -Minfo=accel -g -r8 -traceback -Mnoinline
module simple
type TType
integer :: a, b, c
end type
contains
subroutine set_val_gpu(test, idx)
type(TType), intent(out) :: test
integer, intent(in) :: idx
!$acc serial present(test) copyin(idx) async(1)
test%a = 10
test%b = 20
test%c = 30
!$acc end serial
end subroutine set_val_gpu
subroutine set_val_cpu(test, idx)
type(TType), intent(out) :: test
integer, intent(in) :: idx
test%a = 1
test%b = 2
test%c = 3
end subroutine set_val_cpu
end module simple
program testprogram
use simple
implicit none
type(TType), dimension(3) :: a
integer :: i
write (*,*) "test start"
!$acc data copyout(a(2))
CALL set_val_gpu(a(2), 2)
CALL set_val_cpu(a(1), 1)
CALL set_val_cpu(a(3), 3)
write (*,*) "result"
write (*,*) "a"
write (*,*) a
!$acc wait(1)
!$acc end data
write (*,*) "result"
write (*,*) "a"
write (*,*) a
end program testprogram