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

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -