如何在Linux上检查OpenMP的版本

时间:2021-09-21 20:31:10

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.

我也不知道它在哪里安装。

3 个解决方案

#1


41  

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: http://gcc.gnu.org/wiki/openmp:

对于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/ations/)来发现提供的日期和实际的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版本的年和月指定。

#2


10  

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

#3


1  

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 article and from this webpage from 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.

空白的条目在那里,因为我没有找到相应的信息。

#1


41  

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: http://gcc.gnu.org/wiki/openmp:

对于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/ations/)来发现提供的日期和实际的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版本的年和月指定。

#2


10  

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

#3


1  

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 article and from this webpage from 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.

空白的条目在那里,因为我没有找到相应的信息。