OpenMP 几个“共享”指令?
嘿, 我在 OpenMP 中有一个很长的共享变量列表,所以我必须在 fortran 中分割行并使用“&”语法来确保这些行粘在一起!
类似这样的事情:
!$OMP PARALLEL DEFAULT(private) SHARED(vars....,
& more_vars...,
& more_vars...
& )
在没有 OpenMP 的情况下编译时,这会给我带来错误,因为只有第一个赞才会被识别为评论!现在的问题是我不能添加“!”在这些行前面有一个“&”前面支持不使用 OpenMP 进行编译:
!$OMP PARALLEL DEFAULT(private) SHARED(vars....,
! & more_vars...,
! & more_vars...
! & )
因为它不再使用 OpenMP 进行编译...但我想在一个代码中支持两种编译...关于如何做到这一点有什么建议吗?
Hey there,
I have a very long list of shared variables in OpenMP so I have to split lines in fortran and use the "&"-syntax to make sure the lines stick together!
Something like that:
!$OMP PARALLEL DEFAULT(private) SHARED(vars....,
& more_vars...,
& more_vars...
& )
That gives me errors when compiling without OpenMP, since only the first like is recognized as a comment! The problem now is that I can't add a "!" in front of those lines with a "&" in front to support compiling without OpenMP:
!$OMP PARALLEL DEFAULT(private) SHARED(vars....,
! & more_vars...,
! & more_vars...
! & )
because than it doesn't compile with OpenMP anymore... But I want to support both sorts of compiling in just one code... Any advices on how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有使用正确的语法。如果您查看 OpenMP V3.0 规范的第 2.1.2 节“自由源形式指令”,您将看到以下内容:
所以正确的形式应该是:
对于固定形式来说,是同一类型的东西。您以 OMP 标记开始每一行,并确保后续行在第 6 列中具有非空白和非零字符。
You are not using the correct syntax. If you look at the OpenMP V3.0 specification, section 2.1.2 Free Source Form Directives, you will see the following:
So the correct form should be:
For fixed form, it is the same type of thing. You start each line with the OMP sentinel and make sure continuation lines have a non-blank and non-zero character in column 6.
好吧,伙计们......我找到了解决方案:循环标识符(我的意思是以下代码中的 i:
do i=1,end
)必须共享,因为我正在使用DEFAULT(private)
我必须将其写入共享变量列表中:)希望有一天这对某人有帮助:)Okay guys... I found out the solution: The loop-identifier (I mean i in the following code:
do i=1,end
) has to be shared and as I am usingDEFAULT(private)
I had to write this into the list of shared vars :) Hope this helps somebody someday :)