Parallelization of inner loop

Parallelization of inner loop

Hello.
I have a code that in pseudo is sth like this:

Do while loop
if condition
call subroutinex(In)
else
do i=2,max
ln=i
call subroutinex(ln)
end do
endif
other serial work
end do

I have managed to succesfully parallelize the inner loop like that
Do while loop
if condition
call subroutinex(In)
else
!$OMP PARALLEL DEFAULT (SHARED) PRIVATE (pr.variables)
!$OMP DO
do i=2,max
ln=i
call subroutinex(ln)
end do
!$OMP END DO
!$OMP END PARALLEL
endif
other serial work
end do

This code works fine for me producing the correct results, and running at about half the time of the optimized auto parallelized NO-OMP version (for max=5). I suspect (though not quite sure about it) that spawning the parallel region within the "Do while loop" may be causing some unnecessary overhead that I can avoid using a different approach (spawning the parallel region outside the outer loop and using !$OMP CRITICAL or !$OMP MASTER). I can't seem to understand how the correct syntax would be for sth like that though. Any suggestions are very welcome.

Best regards,
Apostolos

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You are asking this question in the wrong place. This forum is a place for questions about the implementation of the Intel Open Source OpenMP runtime, whereas your question is about general parallelization strategies using OpenMP. Since the question isn't even Intel specific, I suggest you take it to a larger, more general forum such as http://www.stackoverflow.com which has a specific tag for OpenMP. Since there are more people there you're much more likely to get a useful answer.

Thank you and sorry for the inconvenience

Leave a Comment

Please sign in to add a comment. Not a member? Join today