Fortran Coder

查看: 19830|回复: 6
打印 上一主题 下一主题

[通用算法] Fortran并行计算中OpenMP,MPI及Coarrays之单节点多线程应用比较

[复制链接]

19

帖子

0

主题

0

精华

专家

F 币
370 元
贡献
122 点
楼主
发表于 2021-7-19 19:26:05 | 显示全部楼层
这个帖子有些时间了,不知道答主有没有后续检查。我运行了一下coarray的例子也并没有发现问题,提供一点可能的思路吧。在coarray例子下,在co_broadcast之前(11行12行之间)你可能要加一个sync call。如果有一个image先于image 1赋值之前co_broadcast了image 1的值,就有可能得不到正确的n_limit的值。我看了一个opencoarrays里的例子(https://github.com/sourceryinstitute/OpenCoarrays/blob/ef8069d94ecd3a0d93e0d4413a63c2366b894130/src/tests/unit/collectives/co_broadcast.F90),其中
[Fortran] 纯文本查看 复制代码
! Verify broadcasting of character data from image 1
  c_char_co_broadcast: block
    character(kind=c_char,len=14), save :: string_received[*]
    character(kind=c_char,len=*), parameter :: string_sent=c_char_"Hello, world!"! Character test message
    if (me==1) string_received=string_sent
    sync all
    call co_broadcast(string_received,source_image=1)
    if (string_received/=string_sent) then
      write(error_unit,*) "Incorrect co_broadcast(",string_received,") on image",me
    else
      c_char_test_passes=.true.
    end if
  end block c_char_co_broadcast

就是在co_broadcast之前加了sync all。
一点小建议哈~
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-16 17:32

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表