I wonder how to check the version of OpenMP on a Linux remote machine?
I don't know where it is installed either.
I wonder how to check the version of OpenMP on a Linux remote machine?
I don't know where it is installed either.
You need to check your gcc version using
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):
| 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.
First set environment variable OMP_DISPLAY_ENV: in bash:
export OMP_DISPLAY_ENV="TRUE"
or in csh-like shell:
setenv OMP_DISPLAY_ENV TRUE
Then compile and run your OpenMP program:
./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 documentation improved a lot. You can find more information about supported OpenMP versions corresponding compilers from this link.
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.
Above link also has the supported OpenMP versions in the different compliers.
Actually, I think you can not get the version of openmp directly, but compiler will use a predefined macro _OPENMP to represent the release date of openmp, and you should specify the -fopenmp option to use this macro.
You can get the release date of openmp first using shell command like this
echo _OPENMP | gcc -fopenmp -E -x c - | tail -1
As for my gcc, it is
201511
Then you can check the openmp release history (https://www.openmp.org/news/press-releases/) to get the version. Of 201511, it means Nov 2015, and the version is openmp 4.5 .
The release history is below:
Date Version
----------------------
Nov 2021 OpenMP 5.2
Nov 2020 OpenMP 5.1
Nov 2018 OpenMP 5.0
Nov 2015 OpenMP 4.5
Jul 2013 OpenMP 4.0
Jul 2011 OpenMP 3.1
May 2008 OpenMP 3.0
May 2005 OpenMP 2.5
Mar 2002 C/C++ 2.0
Nov 2000 Fortran 2.0
Nov 1999 Fortran 1.1
Oct 1998 C/C++ 1.0
Oct 1997 Fortran 1.0
This is a bit safer version of an answer by user2023370 above. Ancient OpenMP versions are omitted for brevity:
#include <map>
#include <fmt/format.h>
using namespace std;
...
fmt::print("OpenMP v{}\n", map<int, string>{{200805, "3.0"},{201107, "3.1"}, {201307, "4.0"}, {201511, "4.5"}, {201811, "5.0"}}[_OPENMP]);
If a new version number or corrupted one is encountered, this statement will not throw exception as opposed to using at() function member.
Version numbers are from https://github.com/jeffhammond/HPCInfo/blob/master/docs/Preprocessor-Macros.md.