使用数组减少 Fortran 90/95 OpenMP(总和)
我正在努力将一些 OpenMP 指令添加到大量相当昂贵的嵌套循环中。我相信我需要在指令中使用归约子句,因为数组上的操作不一定是独立的。但是,当尝试添加缩减指令时,我的应用程序核心转储(但确实编译)。我正在使用支持 OpenMP 3.0 的 IBM XL Fortran 编译器。我的(简化的)代码如下:
!$omp parallel do reduction(+:f) private(n,m,l,i,j,k, &
!$omp parm,ista,iend,jsta,jend,ksta,kend)
do n=1,lm !k
do m=1,jm !j
do l=1,im !i
if (val(l,m,n) .ne. zero) then
jsta=max j bounds in box
jend=min j bounds in box
ista=max i bounds in box
iend=min i bounds in box
ksta=min k bounds in box
kend=max k bounds in box
do k=ksta,kend
do j=jsta,jend
do i=ista,iend
parm = exp( -dx*(abs(i-l)) &
-dy*(abs(j-m)) &
-dz*(abs(k-n)))
f(i,j,k) = f(i,j,k)+ val(l,m,n) * parm
end do
end do
end do
end if
end do
end do
end do
其中 f 具有维度(im,jm,lm)。这仅仅是语法问题吗?我一直在几个较小的玩具问题上尝试这个方法,但我很难将我在较小的测试中学到的知识应用到这种情况下。出于参考目的,我几个月前问了一个类似的问题,但从那时起问题发生了轻微的变化,我不认为现在的解决方案那么简单( 链接 )。
感谢您的任何帮助/评论!
I'm working on adding some OpenMP directives to a large set of fairly expensive nested loops. I believe I need to use a reduction clause with my directive since the operations on the array on not necessarily independent. However, when attempting to add the reduction directive my application core dumps (but does compile). I'm using IBM's XL Fortran compiler enabled with OpenMP 3.0. My (simplified) code is below:
!$omp parallel do reduction(+:f) private(n,m,l,i,j,k, &
!$omp parm,ista,iend,jsta,jend,ksta,kend)
do n=1,lm !k
do m=1,jm !j
do l=1,im !i
if (val(l,m,n) .ne. zero) then
jsta=max j bounds in box
jend=min j bounds in box
ista=max i bounds in box
iend=min i bounds in box
ksta=min k bounds in box
kend=max k bounds in box
do k=ksta,kend
do j=jsta,jend
do i=ista,iend
parm = exp( -dx*(abs(i-l)) &
-dy*(abs(j-m)) &
-dz*(abs(k-n)))
f(i,j,k) = f(i,j,k)+ val(l,m,n) * parm
end do
end do
end do
end if
end do
end do
end do
Where f has dimension (im,jm,lm). Is this simply an issue of syntax? I've been trying this out on several smaller, toy problems but I'm having trouble getting what I learn with a smaller test to apply in this context. For reference purposes I asked a similar question a few months back but the problem has changed slightly since then and I don't believe the solution is as straightforward now ( link ).
Thanks for any help/comments!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在使用 Intel Fortran 编译器,但我也有过和你类似的经历,运行时出现分段错误。
就我而言,以下解决了问题,这增加了线程堆栈大小。我希望这有帮助。
I'm using Intel Fortran compiler, but I have had a similar experience like you, segmentation fault at runtime.
In my case, the following solves the problem, which increases thread stack size. I hope this helps.