How to break out of a nested parallel (OpenMP) Fortran loop idiomatically?
Posted
by J.F. Sebastian
on Stack Overflow
See other posts from Stack Overflow
or by J.F. Sebastian
Published on 2010-06-05T09:02:32Z
Indexed on
2010/06/05
9:12 UTC
Read the original article
Hit count: 346
Here's sequential code:
do i = 1, n
do j = i+1, n
if ("some_condition") then
result = "here's result"
return
end if
end do
end do
Is there a cleaner way to execute iterations of the outer loop concurrently other than:
!$OMP PARALLEL private(i,j)
!$OMP DO
do i = 1, n
if (found) goto 10
do j = i+1, n
if (found) goto 10
if ("some_condition") then
!$OMP CRITICAL
!$OMP FLUSH
if (.not.found) then
found = .true.
result = "here's result"
end if
!$OMP FLUSH
!$OMP END CRITICAL
goto 10
end if
end do
10 continue
end do
!$OMP END DO NOWAIT
!$OMP END PARALLEL
© Stack Overflow or respective owner