Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7679 Discussions

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

Weiguang_Y_
Beginner
143 Views

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!



0 Kudos
1 Reply
SergeyKostrov
Valued Contributor II
143 Views
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.
Reply