I have installed clang and llvm version 9 using instructions from https://apt.llvm.org/ .
Next I try to get my version of openmp from clang compiler, so I created file openmp_v.cpp:
#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());
printf("Version: %d.\n", _OPENMP);
return 0;
}
and compile it:
clang++-9 -std=c++17 -fopenmp openmp_v.cpp -o openmp_v -fopenmp=libiomp5
The result is:
We have OpenMP 3.1.
Version: 201107.
The problem is that the openmp version should be 4.5 and not 3.1, because clang-9 support openMp 4.5.
I even installed libomp-9-dev and nothing have changed. Also, I have located llvm-9 include and lib files, which are in: /usr/lib/llvm-9 and try to add them as:
clang++-9 -std=c++17 -fopenmp openmp_v.cpp -o openmp_v -fopenmp=libiomp5 -I /usr/lib/llvm-9/include/openmp -L /usr/lib/llvm-9/lib/
But it still doen't work.
EDIT: replaced placeholder with reply.
After a bit of conversation with one of the clang developers, it's not really clear if this is a bug in clang or more a feature. IMHO, it could be that the version string for _OPENMP
was not correctly set, when clang 9.0 was branched from the mainline code version.
The mainline version in the repository correctly reports 201511
for _OPENMP
, which corresponds to OpenMP API Version 4.5. I think this is correct, as clang (to my knowledge) does not yet fully support OpenMP 5.0.
So, clang 10.0.0 will correctly report the version number. I'm not sure if there will be a bugfix release of clang 9.0.0 that will also fix this issue.
Hope that helps!