使用数组减少 Fortran 90/95 OpenMP(总和)

发布于 2024-12-13 18:29:08 字数 1198 浏览 4 评论 0原文

我正在努力将一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明月夜 2024-12-20 18:29:08

我正在使用 Intel Fortran 编译器,但我也有过和你类似的经历,运行时出现分段错误。

就我而言,以下解决了问题,这增加了线程堆栈大小。我希望这有帮助。

[hoge@hoge]$ ulimit -s unlimited
[hoge@hoge]$ export OMP_STACKSIZE=1g # 1GB for thread stack size

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.

[hoge@hoge]$ ulimit -s unlimited
[hoge@hoge]$ export OMP_STACKSIZE=1g # 1GB for thread stack size
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文