I was trying to add a piece of C++ code using openmp to an old program which uses c++, c and Fortran. The problem is that omp_get_max_threads() always returns 1. Although I have explicitly set omp_set_dynamic(0) and omp_set_num_threads(4), I still get 4 same thread number from the parallel region. For example, I linked an openmp hello world to the old codes. The program displayed 4 hello world messages from thread 1 instead of from thread 0,1,2,3 and 4. However, the openmp hello world code worked correctly on the same machine when it was separated from the program.
The original makefile doesn't use openmp. I just simply added flag openmp to the corresponding CXX compiler and linker as follows:
CXX = icpc -pthread --> CXX= icpc -pthread -openmp
LINK_EXE =$CXX -thread -o --> LINK_EXE =$CXX -thread -openmp -o
I am wondering whether there is anything wrong in my makefile.
Thanks for your time and help!