PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

best equivalent of mirror in OpenACC

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
franzisko



Joined: 11 Jan 2011
Posts: 25

PostPosted: Wed Apr 04, 2012 6:26 am    Post subject: best equivalent of mirror in OpenACC Reply with quote

Hello,
I read there is no mirror equivalent in OpenACC. I am wondering about the best way to "translate" it in OpenACC. Starting from a trivial example:

Code:
module storage
   integer, parameter :: N=1000
   real, dimension(:,:), allocatable :: A,B,C
!$acc mirror(A,B,C)
end module storage

subroutine matadd_sub() 
   use storage; implicit none
   integer :: i,j
!$acc region
   do i=1,N 
      do j=1,N 
         C(i,j) = A(i,j) + B(i,j)
      enddo
   enddo     
!$acc end region
end subroutine matadd_sub

program matadd 
   use storage  ; implicit none
   allocate(A(N,N),B(N,N),C(N,N))
   A = 1.  ; B = 2.  ; C = 0.
!$acc update device(A,B)
   call matadd_sub()
!$acc update host(C)
   print*,"C: ",C(6,3)
end program matadd


I think a possibility is:
Code:


module storage
   integer, parameter :: N=1000
   real, dimension(:,:), allocatable :: A,B,C
end module storage

subroutine matadd_sub()
   use storage; implicit none
   integer :: i,j
!$acc kernels loop present(A,B,C)
   do i=1,N 
      do j=1,N
         C(i,j) = A(i,j) + B(i,j)
      enddo       
   enddo   
!$acc end kernels
end subroutine matadd_sub

program matadd
   use storage  ; implicit none
   allocate(A(N,N),B(N,N),C(N,N))
   A = 1.  ; B = 2.  ; C = 0.
!$acc data region copyin(A,B) copyout(C)
   call matadd_sub()
!$acc end data region
   print*,"C: ",C(6,3)
end program matadd                                                                                                         


It seems to work with PGI 12.3. But I would prefer much something like

Code:

module storage
   integer, parameter :: N=1000
   real, dimension(:,:), allocatable :: A,B,C
!$acc declare device_resident(A,B,C) ! I do not know the clause
end module storage

subroutine matadd_sub() 
   use storage; implicit none
   integer :: i,j
!$acc kernels
   do i=1,N 
      do j=1,N 
         C(i,j) = A(i,j) + B(i,j)
      enddo
   enddo     
!$acc end kernels
end subroutine matadd_sub

program matadd 
   use storage  ; implicit none
   allocate(A(N,N),B(N,N),C(N,N))
   A = 1.  ; B = 2.  ; C = 0.
!$acc update device(A,B)
   call matadd_sub()
!$acc update host(C)
   print*,"C: ",C(6,3)
end program matadd



This second version seems to be incorrect. Is it possibile to do modify it to make it working?

thanks in advance,
Francesco
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6122
Location: The Portland Group Inc.

PostPosted: Wed Apr 04, 2012 10:54 am    Post subject: Reply with quote

Hi Francesco,

Quote:
!$acc declare device_resident(A,B,C) ! I do not know the clause
You got it correct. "device_resident" is the closest OpenACC equivalent to mirror. However, it's not supported in the 12.3 OpenACC beta. "device_resident" should be available by the full release in June.

- Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group