Use this forum to discuss the book: Using OpenMP - Portable Shared Memory Parallel Programming, by Barbara Chapman, Gabriele Jost and Ruud van der Pas Read the
viewtopic.php?f=8&t=465 for book info and to download the examples. Post your feedback about the book and examples to this forum
by arthur.avramiea » Sun Feb 27, 2011 4:53 am
I'm trying to understand the example in page 117 of the book, the one that explains how to use the flush directive to synchronize threads. I do not understand what is the nt variable in the if(iam .lt. nt) conditional (it is the 10th line down to up).
- Code: Select all
!$OMP PARALLEL PRIVATE(k, iam)
iam = OMP_GET_THREAD_NUM()
isync(iam) = 0 ! Initialize synchronization array
! Wait for neighbor thread to finish
!$OMP BARRIER
do k = 2, nz
if (iam .gt. 0) then
do while(isync(iam-1) .eq. 0)
!$OMP FLUSH(isync)
end do
isync(iam-1) = 0
!$OMP FLUSH(isync,v)
end if
!$OMP DO SCHEDULE(STATIC, nchunk)
do j = 2, ny; do i = 2, nx
v(i,j,k) = v(i,j,k) + v(i-1,j,k) + ....
end do; end do
!$OMP END DO NOWAIT
! Signal the availability of data to neighbor thread
if (iam .lt. nt) then
!$OMP FLUSH(isync,v)
do while (isync(iam) .eq. 1)
!$OMP FLUSH(isync)
end do
isync (iam) = 1
!$OMP FLUSH(isync)
end if
end do
!$OMP END PARALLEL
-
arthur.avramiea
-
- Posts: 6
- Joined: Wed Feb 23, 2011 11:43 am
by ejd » Mon Feb 28, 2011 6:19 pm
If you read what it says in the text for the Figure, you will find the following: "Note that ny is assumed to be a multiple of the number of threads nt".
-
ejd
-
- Posts: 1025
- Joined: Wed Jan 16, 2008 7:21 am
Return to Using OpenMP - The Book and Examples
Who is online
Users browsing this forum: No registered users and 1 guest