Clang + OpenMP on Linux uses only 1 CPU core -
i have following code:
int main(int argc, char** argv) { const int64_t n = 10000000000; float* data = new float[n]; int64_t i; omp_set_dynamic(0); omp_set_num_threads(4); #pragma omp parallel for(i = 0; < n; ++i) data[i] = i*i; return 0; }
if compile g++ during runtime code uses 4 cores:
g++ -fopenmp -std=c++11 main.cpp
if compile clang++3.7 during runtime code uses 1 core:
clang++-3.7 -fopenmp -std=c++11 main.cpp
in both cases have set:
omp_num_threads=4
both compilers have been installed debian testing repository:
sudo apt-get install g++-5 sudo apt-get install clang-3.7
so, ideas why clang uses 1 core? in advance.
see this:
openmp 3.1 supported, disabled default. enable it, please use -fopenmp=libomp command line option.
it looks missed -fopenmp=libomp
in compilation flags.
Comments
Post a Comment