Hi, I have this simple Fortran code
parameter (n=100000,m=10)
real*8 x(n),y(n)
real*8 A(m),B(m)
!$acc routine(mult)
do i=1,m
A(i)=2.0d0
B(i)=3.0d0
enddo
do i=1,n
x(i)=0.0d0
y(i)=1.0d0
enddo
!$acc data copy(x) copyin(y,A,B)
!$acc parallel loop gang
do i=1,10000,2
im=m*(i-1)+1
ik=m*i+1
call mult(m,A,x(im),y(im))
call mult(m,B,x(ik),y(ik))
enddo
!$acc end parallel
!$acc end data
aa=0.0d0
do i=1,n
aa=aa+x(i)
enddo
print*,aa
stop
end
subroutine mult(m,A,x,y)
real*8 A(*),x(*),y(*)
!$acc routine seq
!$acc loop
do i=1,m
x(i)=A(i)*y(i)
enddo
return
end
The subroutine’s loop is executed sequentially. In order to enable parallelization in this loop, I replaced seq with vector in the !$acc routine seq statement, but the computation result is wrong. How can I fix it ?
Manolis