- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can someone help me with parallelizing multiple do loops which is inside each other and 3D matrix calculation?
For example:
INTEGER :: Array_size, nnnode
REAL*8, ALLOCATABLE, dimension ( : ) :: Array( :, :, : )
ALLOCATE (Array( 580, 580, 580 ))
Array_size = 580
nnode=omp_get_num_procs()
CALL omp_set_num_threads(nnode)
!$OMP parallel default(private) shared(Array)
!$OMP do private(I, j, k)
do 120 i = 1, Array_size
do 120 j = 2, Array_size
!calculation
do 110 k = j, Array_size
Array(I, j, k) = !do some calculation here.
110 !Some calculationg here..
120 !Other calculation here..
!$OMP end do
!$OMP end parallel
DEALLOCATE (Array)
Would OMP DO paralelize all the loop which is inside or not? And what is the best way to paralelize 3D matrixes.
Thanks in advance.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OpenMP would parallelize the outer loop, so you would need to correct the loop nesting. This is particularly important, if the loop would be vectorizable when re-nested with the i loop inside. The slogan from 20 years ago was "concurrent [threaded] outer, vector inner," and nothing has changed this recommendation.
If your objective is to show maximum gain from threading by minimizing the unthreaded performance, you can still do that by -O0.
ifort -O3, without openmp, can perform some multi-level loop optimizations, but openmp would prevent changing the outer loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So it's mean that I can't use OpenMp to parallelize multiple do loops which inside each other. Can you post some link for using ifort -O3.
Thanks in advance.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Consider reordering the indexing (by swaping order of do loops) if possible.
In Array(I, j, k), elements Array(I, j, k) and Array(I+1, j, k) would be in adjacent memory cells and therefore are potential for vectorization. Therefore, placing the "do I" loop as inner loop would increase the prospect of vectorization.
Jim Dempsey

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page