PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

sync all threads with threadfence?

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



Joined: 19 Oct 2009
Posts: 8

PostPosted: Tue Apr 05, 2011 9:36 pm    Post subject: sync all threads with threadfence? Reply with quote

syncthread() will only sync threads in the same block, If I want to create a check points for all threads on the device, should I use threadfense() ? for the following sample code:
Code:

attribute(global) subroutine MyTest_cuda
integer :: s, i, j

do s=1, 10

do i=do w=blockidx%x, 20, griddim%x
do j=threadidx%x, 20, blockdim%x
......
enddo  ! j
enddo  ! i
call threadfense()
enddo !s
end subroutine


If I call the subroutine with
Code:

call MyTest_cuda<<<30,30>>>


Since the i, j loops are only up to 20. some threads will not go into the loop. Are they going to wait at 'call threadfense()'? thanks for the help, Mat.
Back to top
View user's profile
mkcolg



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

PostPosted: Wed Apr 06, 2011 8:58 am    Post subject: Reply with quote

Hi tty103,

The only guaranteed method to achieve global synchronization is via multiple kernel launches. threadfense only makes sure that memory is globally visible.

You can try using it in combination with atomics to achieve but it's my understanding that it can be very slow and has the potential for deadlocks. I have not attempted it myself since it's not recommended, but in searching the NVIDIA forums you can find several implementations in C.

- 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