Possible cominations of sentinels

General OpenMP discussion

Possible cominations of sentinels

Postby trav9 » Wed Jun 20, 2012 10:15 am

I am trying to optimize a code that is in the format below

Code: Select all
do .....
   call .....
   call .....
   if .....
      do .....
      end do .....
   else .....
      do .....
      end do .....
   end if .....
end do .....


I am having difficulty in running the call sequences through parallel due to the complexity of the code itself. As an alternate strategy I am attempting to run the outer do loop in parallel and have it run through one thread when it gets to the call spots. Is it possible to format OpenMP like below?

Code: Select all
!$OMP PARALLEL
!$OMP DO
do .....
!$OMP SINGLE
   call .....
   call .....
!$OMP END SINGLE
   if .....
      do .....
      end do .....
   else .....
      do .....
      end do .....
   end if .....
end do .....
!$OMP END DO
!$OMP END PARALLEL


I want to have the section split up the loop into multiple threads, but I don't want all of the threads to do all of the work and each give me a separate answer. That is why I want to include the OMP DO, but I am having trouble with this setup. Any ideas on a better way to do it?
trav9
 
Posts: 7
Joined: Wed Jun 13, 2012 3:01 pm

Re: Possible cominations of sentinels

Postby MarkB » Thu Jun 21, 2012 1:39 am

In a case like this, in order to achieve the effect you are looking for, you should use CRITICAL instead of SINGLE.
MarkB
 
Posts: 480
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 14 guests