OpenMP thinks only 1 processor is available??

General OpenMP discussion

OpenMP thinks only 1 processor is available??

Postby rrpeter » Thu Sep 18, 2008 1:24 pm

Hi,
I have tried various OpenMP examples on the web and got them all to work fine. When I tried to parallelize some software that is part of a larger project, I have had a problem; OpenMP reports only one processor available and so I get only 1 thread. More details follow.

I am running on an dual quad-core PC. I use RHEL 5.2 and have used the gcc 4.3.2 compiler (compiled it myself) and the RedHat's "stock" 4.1.2 compiler that has had OpenMP backported to it. Both exhibit the same problem.


In some simple example code (e.g., dotproduct_reduction.cpp that found on the web), I can put in the following print:
#ifdef _OPENMP
cout << " Number of processors available:" << omp_get_num_procs() << " MAX Number of threads " << omp_get_max_threads() << endl;
cout.flush();
#endif

and get something like:
Number of processors available:8 MAX Number of threads 8

In my large project on the same computer:
#ifdef _OPENMP
cout << " Number of processors available:" << omp_get_num_procs() << " MAX number of OpenMP threads " << omp_get_max_threads() << endl;
#endif

and get:
Number of processors available:1 MAX number of OpenMP threads 1

And so it doesn't parallelize. I am stumped! What could be causing OpenMP to be confused with regard to the number of processors? I thought it might be something in the compile, so I re-compiled absolutely everything with "-fopenmp" turned on and it made no difference.

Compile samples:
cd /home/hopper/UMBRA_4/umbra/SNL/rwm/buildRWM/utility && /usr/bin/g++-4.3.2 -DBOOST_ALL_NO_LIB -Dutility_EXPORTS -O3 -DNDEBUG -fopenmp -fPIC -I/usr/include/boost-1_35 -I/home/hopper/UMBRA_4/umbra/SNL/rwm/TNT -I/home/hopper/UMBRA_4 -Wall -fPIC -o CMakeFiles/utility.dir/matrix_math.o -c /home/hopper/UMBRA_4/umbra/SNL/rwm/utility/matrix_math.cpp

cd /home/hopper/UMBRA_4/umbra/SNL/rwm/buildRWM/micp && /usr/bin/g++-4.3.2 -DBOOST_ALL_NO_LIB -Dmicp_EXPORTS -O3 -DNDEBUG -fopenmp -fPIC -I/usr/include/boost-1_35 -I/home/hopper/UMBRA_4/umbra/SNL/rwm/utility -I/home/hopper/UMBRA_4/umbra/SNL/rwm/CDF -I/home/hopper/UMBRA_4 -I/home/hopper/UMBRA_4/include/cstk2 -Wall -fPIC -o CMakeFiles/micp.dir/icp.o -c /home/hopper/UMBRA_4/umbra/SNL/rwm/micp/icp.cpp

Link sample (everything is linked as a shared library)
Linking CXX shared library ../libutility.so
cd /home/hopper/UMBRA_4/umbra/SNL/rwm/buildRWM/utility && /usr/bin/cmake -E cmake_link_script CMakeFiles/utility.dir/link.txt --verbose=1
/usr/bin/g++-4.3.2 -fPIC -O3 -DNDEBUG -fopenmp -Wl,--no-undefined -shared -Wl,-soname,libutility.so -o ../libutility.so CMakeFiles/utility.dir/CharObj.o CMakeFiles/utility.dir/Classify.o CMakeFiles/utility.dir/crc16_func.o CMakeFiles/utility.dir/crc32_func.o CMakeFiles/utility.dir/dsvdfit.o CMakeFiles/utility.dir/geometry.o CMakeFiles/utility.dir/math_funcs.o CMakeFiles/utility.dir/math_predicate.o CMakeFiles/utility.dir/matrix_math.o CMakeFiles/utility.dir/PCI.o CMakeFiles/utility.dir/rwm_status.o CMakeFiles/utility.dir/statistics.o CMakeFiles/utility.dir/string_funcs.o CMakeFiles/utility.dir/timing.o CMakeFiles/utility.dir/utility.o CMakeFiles/utility.dir/ValIndex.o /usr/local/lib/libumb.so -Wl,-rpath,/usr/local/lib
rrpeter
 
Posts: 2
Joined: Thu Sep 18, 2008 1:14 pm

Re: OpenMP thinks only 1 processor is available??

Postby rrpeter » Fri Sep 19, 2008 7:08 am

BTW, I set the environment variable OMP_NUM_THREADS to 2 and got 2 threads running, but only 1 processor was used.
rrpeter
 
Posts: 2
Joined: Thu Sep 18, 2008 1:14 pm

Re: OpenMP thinks only 1 processor is available??

Postby ejd » Fri Sep 19, 2008 7:11 am

I have sent a message off to someone asking how this should be handled. I hope to have a reply shortly.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: OpenMP thinks only 1 processor is available??

Postby jakub » Fri Sep 19, 2008 7:59 am

omp_get_num_procs can be affected by processor affinity (say if you run an OpenMP program confined to one CPU, it will report 1 for omp_get_num_procs (man taskset)), or if GOMP_CPU_AFFINITY is used (similar reasons). Run the program under strace and look for sched_getaffinity syscalls.
jakub
 
Posts: 74
Joined: Fri Oct 26, 2007 3:19 am


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot] and 5 guests

cron