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.
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.
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.
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.
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.
Here's a short C++11 program to display your OpenMP version; it also covers version 4.5 which was released in November 2015.
and compile it with:
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.
For GCC, this is a good resource (does not mention newest versions of GCC): http://gcc.gnu.org/wiki/openmp:
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.
You can go here (http://www.openmp.org/specifications/) to discover the mapping between the date provided and the actual OpenMP version number.
You need to check your
gcc
version usingand then see the (incomplete) table below (whose info is gathered from this Wiki article and from this webpage from the OpenMP official website):
The blank entries are there because I didn't find the corresponding info.
First set environment variable OMP_DISPLAY_ENV: in bash:
or in csh-like shell:
Then compile and run your OpenMP program:
There will be additional info, like :
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.