提问人:Pablo Grobas Illobre 提问时间:11/1/2023 更新时间:11/1/2023 访问量:45
平行折叠 + 减少不起作用
Parallel collapse + reduction not working
问:
我正在尝试并行化两个嵌套循环,但折叠子句失败了。
嘿,我正在尝试并行化这两个嵌套循环,以计算两个积分(int_coulomb 和 int_overlap)。当我应用 collapse 子句时,我的问题就来了,然后我的代码无法从 in 序列中恢复结果。
此外,我还添加了使用所选数量的处理器启动 fortran 程序(并行编译)的可能性。如果我做 ./program input.inp -omp 1,我的代码都不起作用。
另一方面,当我消除 collapse 子句时,我的代码比串行慢,但给了我正确的结果。
This is my code:
!$omp parallel do private(i,j,r,dist,invdst,sf,sf0,screen_pot) &
!$omp collapse(2) &
!$omp reduction(+:int_coulomb,int_overlap)
! aceptor
do i = 1, aceptor%n_points_reduced
do j = 1, donor%n_points_reduced
r(1) = (aceptor%xyz(1,i)-donor%xyz(1,j))
r(2) = (aceptor%xyz(2,i)-donor%xyz(2,j))
r(3) = (aceptor%xyz(3,i)-donor%xyz(3,j))
!
dist = dsqrt(DOT_PRODUCT(r,r))
!
! Skip when grid points are coincident to avoid instabilities
if (dist.le.1.0e-14) then
int_coulomb = int_coulomb + zero
int_overlap = int_overlap + zero
else
invdst = one/dist
!
! Screening function
sf = dist / QMscrnFact
sf0 = erf(sf)
screen_pot = sf0
!
! Integrate charges as rho_aceptor * rho_donor * (1/dist) * screening
! --> the density has been already weigthed by the cube volume
int_coulomb = int_coulomb +&
aceptor%rho_reduced(i) * donor%rho_reduced(j) * invdst * screen_pot
!
! Aceptor-donor overlap
int_overlap = int_overlap +&
aceptor%rho_reduced(i) * donor%rho_reduced(j)
!
endif
!
enddo
enddo
!$omp end parallel do`
有什么想法吗?
答: 暂无答案
下一个:对嵌套字典进行排序
评论