[Omp] How to restrict the number of cpus openmp use?

Marcel Beemster marcel at ace.nl
Wed May 30 00:11:14 PDT 2007


Dear Ying,

You wrote:
> for example, I want to use only 4 of the 16 cpus in the cluster, but there
> are 10 independent threads for the loop to paralell? after a thread
> completes, it will go on to perform another but the total cpu number is
> restricted to 4.

OpenMP has no facilities to do this. You can set the
OMP_NUM_THREADS environment variable, which initializes the
initial value of the nthreads-var internal variable of
OpenMP. But this value can be overwritten by the OpenMP
application so it does not set a limit.

What you want may be Operating System functionality.
For example, on my system the command 'limits -s' allows me
to set a limit on the stack size of processes. 'limits -u' sets
the number of available processes. But I have no way to limit
the number of processors. Check your OS manuals to see if there
is such functionality for you.

Marcel

-- 
Dr. Marcel Beemster, Senior Software Engineer, marcel at ace.nl,www.ace.nl
Associated Compiler Experts bv. Amsterdam, Netherlands. +31 20 6646416.
-----------------------------------------------------------------------
This e-mail and any  files transmitted  with it are  confidential.  Any
technical information contained herein is supplied as-is, and no rights
can be  derived therefrom.  If you have received this message in error,
please notify  the sender by reply  e-mail immediately,  and delete the
message and all copies thereof.




More information about the Omp mailing list