我已经将下面的这段代码与第一个循环jh
的MPI和第三个三重循环(iz
,ix
,iy
的OpenmP并行化。
我的问题是,这个三重循环大约需要25秒,而第二个循环最多可以达到100000,这很长。
第二个循环is
是否也可以与MPI并行化?
do jh=rank+1,nh,size
! Initializing O
O=0.
do is=1,ns
! Reading file1
call readfile(file1(is),I)
! Reading file2
call readfile(file2(is),H)
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(iz,ix,iy,ih) COLLAPSE(3)
do iz=1,nz
do ix=1,nx
do iy=1,ny
ih=H(iz,iy)
if (ih.eq.jh) then
O(iz,iy)=O(iz,iy)+I(iz,iy)
endif
enddo ! iy
enddo ! ix
enddo ! iz
!$OMP END PARALLEL DO
enddo ! isrc
call writefile(out,O)
! Initializing for the next offset
O=0.
no=1
enddo ! jh