Parallel Synchronization Model
Critical section and Barrier
c$omp parallel private(i,j)shared(a,b,m,n,sum)
do 20 j=1,n
c$omp do
do 10 i=1,m
c$omp critical
sum=sum+a(i,j)
c$omp end critical
10 continue
c$omp barrier
c$omp single
b(j) = sum
c$omp end single
20 continue
c$omp end parallel
J =1
Do
I=1
I=2
I=3
Parallel
J = 2
Do
Mutual exclusion
as threads update sum
(Reduction and Atomic
also available)
Wait until all threads
have finished column
sum. (Barrier actually
built into end do.)
. . .
All threads
barrier
All threads take turns
updating shared sum
Single thread executes
the update.
Previous slide
Next slide
Back to first slide
View graphic version