如何在 Linux 上检查 OpenMP 的版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1304363/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to check the version of OpenMP on Linux
提问by Tim
I wonder how to check the version of OpenMP on a Linux remote machine?
我想知道如何在 Linux 远程机器上检查 OpenMP 的版本?
I don't know where it is installed either.
我也不知道它安装在哪里。
回答by nobar
It appears that the C/C++ specification for OpenMP provides no direct way of doing this programmatically. So you have to check the docs for your compiler version.
OpenMP 的 C/C++ 规范似乎没有提供以编程方式执行此操作的直接方法。所以你必须检查你的编译器版本的文档。
gcc --version ## get compiler version
For GCC, this is a good resource (does not mention newest versions of GCC): http://gcc.gnu.org/wiki/openmp:
对于 GCC,这是一个很好的资源(没有提到 GCC 的最新版本):http: //gcc.gnu.org/wiki/openmp:
As of GCC 4.2, the compiler implements version 2.5 of the OpenMP standard and as of 4.4 it implements version 3.0 of the OpenMP standard. The OpenMP 3.1 is supported since GCC 4.7.
从 GCC 4.2 开始,编译器实现了 OpenMP 标准的 2.5 版,从 4.4 开始,它实现了 OpenMP 标准的 3.0 版。自 GCC 4.7 起支持 OpenMP 3.1。
Edit
编辑
After trying a bit harder, I got the following to work. It at least gives an indication of the OpenMP version -- although it still requires you to look something up.
在更努力地尝试之后,我得到了以下工作。它至少给出了 OpenMP 版本的指示——尽管它仍然需要您查找一些东西。
$ echo |cpp -fopenmp -dM |grep -i open
#define _OPENMP 200805
You can go here (http://www.openmp.org/specifications/) to discover the mapping between the date provided and the actual OpenMP version number.
您可以到这里 ( http://www.openmp.org/specifications/) 来发现提供的日期和实际 OpenMP 版本号之间的映射。
In implementations that support a preprocessor, the _OPENMP macro name is defined to have the decimal value yyyymm where yyyy and mm are the year and month designations of the version of the OpenMP API that the implementation supports.
在支持预处理器的实现中,_OPENMP 宏名称定义为具有十进制值 yyyymm,其中 yyyy 和 mm 是实现支持的 OpenMP API 版本的年和月指定。
回答by user2023370
Here's a short C++11 program to display your OpenMP version; it also covers version 4.5 which was released in November 2015.
这是一个简短的 C++11 程序,用于显示您的 OpenMP 版本;它还涵盖了 2015 年 11 月发布的 4.5 版。
#include <unordered_map>
#include <cstdio>
#include <omp.h>
int main(int argc, char *argv[])
{
std::unordered_map<unsigned,std::string> map{
{200505,"2.5"},{200805,"3.0"},{201107,"3.1"},{201307,"4.0"},{201511,"4.5"}};
printf("We have OpenMP %s.\n", map.at(_OPENMP).c_str());
return 0;
}
and compile it with:
并编译它:
g++ -std=c++11 -fopenmp foobar.cpp
回答by nbro
You need to check your gcc
version using
您需要使用检查您的gcc
版本
gcc --version
and then see the (incomplete) table below (whose info is gathered from this Wiki articleand from this webpagefrom the OpenMP official website):
然后查看下面的(不完整的)表格(其信息是从这篇 Wiki 文章和来自OpenMP 官方网站的这个网页中收集的):
| gcc version | OpenMP version | Languages | Offloading |
|-------------|----------------|-----------------|------------|
| 4.2.0 | 2.5 | C | |
| 4.4.0 | 3.0 | C | |
| 4.7.0 | 3.1 | C | |
| 4.9.0 | 4.0 | C, C++ | |
| 4.9.1 | 4.0 | C, C++, Fortran | |
| 5 | | | Yes |
| 6.1 | 4.5 | C, C++ | |
The blank entries are there because I didn't find the corresponding info.
空白条目在那里是因为我没有找到相应的信息。
回答by Adam
First set environment variable OMP_DISPLAY_ENV: in bash:
首先在 bash 中设置环境变量OMP_DISPLAY_ENV:
export OMP_DISPLAY_ENV="TRUE"
or in csh-like shell:
或在类似 csh 的外壳中:
setenv OMP_DISPLAY_ENV TRUE
Then compile and run your OpenMP program:
然后编译并运行您的 OpenMP 程序:
./a.out
There will be additional info, like :
会有额外的信息,比如:
OPENMP DISPLAY ENVIRONMENT BEGIN
_OPENMP = '201511'
OMP_DYNAMIC = 'FALSE'
OMP_NESTED = 'FALSE'
OMP_NUM_THREADS = '8'
OMP_SCHEDULE = 'DYNAMIC'
OMP_PROC_BIND = 'FALSE'
OMP_PLACES = ''
OMP_STACKSIZE = '0'
OMP_WAIT_POLICY = 'PASSIVE'
OMP_THREAD_LIMIT = '4294967295'
OMP_MAX_ACTIVE_LEVELS = '2147483647'
OMP_CANCELLATION = 'FALSE'
OMP_DEFAULT_DEVICE = '0'
OMP_MAX_TASK_PRIORITY = '0'
OPENMP DISPLAY ENVIRONMENT END
where _OPENMP have the 8 decimal value yyyymm where yyyy and mm are the year and month designations of the version of the OpenMP API that the implementation supports.
其中 _OPENMP 具有 8 位十进制值 yyyymm,其中 yyyy 和 mm 是实现支持的 OpenMP API 版本的年份和月份名称。
回答by Hari Krishna Nalla
OpenMP documentation improved a lot. You can find more information about supported OpenMP versions corresponding compilers from thislink.
OpenMP 文档改进了很多。你可以找到关于由相应的编译器支持OpenMP的版本的详细信息该链接。
Coming to your question, as mentioned above first find the gcc compiler version and then refer the above link to know the corresponding OpenMP version.
来回答你的问题,如上所述,首先找到gcc编译器版本,然后参考上面的链接知道对应的OpenMP版本。
Above link also has the supported OpenMP versions in the different compliers.
上面的链接也有不同编译器支持的 OpenMP 版本。