In the example shown below, please see this compute region:
!$acc kernels copy(arr)
!$acc loop independent
do i=1,10
!arr(i) = i
call add(arr,i)
end do
!$acc end kernels
a) if I have loop independent
with the direct assignment statement arr(i)=i
and no subroutine call to add(), the output is correct.
b) if I have loop independent
with the call to add(), the results are incorrect
c) if I call add() without loop independent
, the results are correct
d) if I have loop independent
with the subroutine call with the seq clause added to the routine directive, the results are correct
Can someone explain the relation between loop independent, calling an openacc subroutine, and the seq clause?
I am using pgi v14.6.
Thank you,
K
module m_test
implicit none
contains
subroutine add(arr,i)
implicit none
!$acc routine
integer, dimension(10), intent(inout) :: arr
integer, intent(in) :: i
arr(i) = i
end subroutine
end module
program test
use m_test
implicit none
integer, dimension(10) :: arr
integer :: i
!$acc kernels copy(arr)
!$acc loop independent
do i=1,10
!arr(i) = i
call add(arr,i)
end do
!$acc end kernels
do i=1,10
print *, arr(i)
end do
end program test
[/code]