[Omp] Noob question about processors

Terboven, Christian terboven at rz.rwth-aachen.de
Thu Apr 27 01:33:54 PDT 2006


Hi Klaas. 


> I just started with using OpenMP on the gcc4.2
> compiler.
I assume you are aware that the gcc 4.2 OpenMP implementation is still
in some kind of beta state?


> My first concern is the following, if I have a node
> with lets say 2 Xeon processors with hyper threading
> enabled, and I use 4 threads in my openmp implementation,
> will those threads be evenly spread over the 2 processors
> (so 1 thread over each of the 4 virtual processors) or
> do I have to do some special kernel stuff that this would
> happen?
Scheduling depends on the OpenMP runtime library and the operating
system.
AFAIK the combination gcc/linux does not provide reliable mechanisms to
bind threads to processors. You can expect that if your program is the
only one running on that node only one thread at a time will run on
given processor, but you will probably experience your threads changing
the processors very often. This situation is different on Solaris (for
example) where you can do explicit thread binding.

Make sure you know about the OMP_DYNAMIC environment variable.


> Finally I am wondering about the following, I would like
> to compile my code on a couple of machines separately,
> and the amount of threads I have depend on the amount
> of real/virtual processors.  Is there a preprocessor
> directive which obtains the amount of cpus?  In that way
> I could do something like
No, compilation is independent of the number of threads during runtime.
There is _OPENMP defined during compilation if you enable OpenMP support
in your compiler.



Regards,
Christian
--
Christian Terboven

High Performance Computing               Hochleistungsrechnen
RWTH Aachen University                   Rechen- und Kommunikations-
Center for Computing and Communication   zentrum der RWTH Aachen
phone: ++49-(0)241-80-24377              Seffenter Weg 23
fax:   ++49-(0)241-80-22134              52074 Aachen, Germany
email: terboven at rz.rwth-aachen.de



More information about the Omp mailing list