Multithreading Big loop containing several loops inside

jimdempseyatthecove
Total Points:
34,847
Status Points:
34,847
Black Belt
October 8, 2008 1:25 PM PDT
Rate
 
#3 Reply to #2

You might start with something like the following:

!$omp parallel
!$omp do private(i,j)
do i=nx1+1,nx2-2
do j=ny1+2,ny2-2

     “stuff1”
enddo
enddo
!$omp end do nowait

 

!$omp do private(i,j)
do i=nx1+2,nx2-2
do j=ny1+1,ny2-2

     “stuff2”
enddo
enddo
!$omp end do nowait
!$omp end parallel

Note, depending on what is inside of stuff1 and stuff2 you may need to use different temporaries (or make subroutines out of stuff1 and stuff2 and passing i and j into the routines.

Also, if the computation overhead varies per iteration then experiment with adding the schedule clause.

Once you get the above working for stuff1 and stuff2 apply what you learned to the remaining stuff sections.

Jim Dempsey

 



Intel Software Network Forums Statistics

8290 users have contributed to 31236 threads and 99111 posts to date.
In the past 24 hours, we have 7 new thread(s) 19 new posts(s), and 24 new user(s).

In the past 3 days, the most popular thread for everyone has been comparison cilk++, openmp, pthreads first results The most posts were made to comparison cilk++, openmp, pthreads first results The post with the most views is Very amusing...  Escalated as

Please welcome our newest member zq.x