Help: OpenMP can't get multiple threads, max num thread is always 1

Help: OpenMP can't get multiple threads, max num thread is always 1

Portrait de Weiguang Y.

Hi,

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!

2 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de Sergey Kostrov

Please upload a test case and I could verify it on Evy Bridge ( 4 CPUs / 8 cores ) and Pentium 4 ( 1 CPU ) systems. Thanks in advance.

Connectez-vous pour laisser un commentaire.