Hi,
I create a data region by !$acc data copy/copyin/create for GPU parallel computing,but some data results really confused me .
here is the code:
subroutine loop
use head !!!!!!store data
N=0
N_pre=0
etm=300
N_cdcl=10
N_state=300
!$acc data copyin(f(1:im,1:jm,0:kk),feq(1:im,1:jm,0:kk),ex(0:kk),ey(0:kk),y(1:jm),x(1:im)) &
!$acc create(fm(1:im,1:jm,0:kk),aa_cy1(:,:),aa_cy2(:,:,:),aax(:,:),aay(:,:)) &
!$acc copy(ux(1:im,1:jm),uy(1:im,1:jm),rho(1:im,1:jm))
100 continue
call collision!!!!!!!!!!!!
call stream!!!!!!!!!!!!!!parallel computing ux,uy,rho
call macro!!!!!!!!!!!!!!!
!$acc update host(ux(1:im,1:jm),uy(1:im,1:jm),rho(1:im,1:jm)
call velocity_modified!!!!!!!!!!!!!calculate with cpu
time=N*dt*U
if(mod(N,N_cdcl).eq.0) then
write(31,*) time,cd_cy
write(32,*) time,cl_cy
write(33,*) time,cd_f(1)
write(34,*) time,cl_f(1)
write(35,*) time,cd_f(2)
write(36,*) time,cl_f(2)
write(41,*) time,xyfl(nfl,1,1)
write(42,*) time,xyfl(nfl,2,1)
write(43,*) time,xyfl(nfl,1,2)
write(44,*) time,xyfl(nfl,2,2)
write(47,*) time,dyc
write(48,*) time,voc
write(5,*) time,spow
print *,time,'cd=',cd_cy,',cl=',cl_cy,',dyc=',dyc
!$acc update device(ux(1:im,1:jm),uy(1:im,1:jm))
call cylinder_vorticity
write(45,*) time,vor_up
write(46,*) time,vor_dn
endif
if(mod(N,200).eq.0) then
call vorticity!!!!!!!!!!!!calculate vor with GPU
call output!!!!!!!!!!!!!!output rho ux uy vor
endif
if(time.ge.120.0.and.time.le.140.0) then
if(mod(N,N_cdcl).eq.0) then
write(51,*) xyfl(nfl,1,1),xyfl(nfl,2,1)
write(52,*) xyfl(nfl,1,2),xyfl(nfl,2,2)
write(53,*) cd_cy,cl_cy
write(54,*) cd_f(1),cl_f(1)
write(55,*) cd_f(2),cl_f(2)
write(64,*) dyc,cd_cy
write(65,*) dyc,cl_cy
endif
endif
if(mod(N,5000).eq.0) call wholefield
call motion_cylinder
call forcing
call equilibrium
N=N+1
if(time.le.etm) goto 100
!$acc end data
end subroutine loop
after the computation,i found that the value of rho is not right ,so i added !$acc update host rho(:,:),and then the result goes right,but the vor was all right without the update clause ,as far as i’m concerned,the only difference between them was the declaring in data clause.
So,i wonder the parameter declared in data clause must use update clause to pass the value to the host,those not declared would automatically update.Am i right?
if not,please tell me how the data clause and data movement in/out kernels/parallel region work .thanks a lot