[torqueusers] MATLAB and cpusets
martin.thompson at unsw.edu.au
Thu Dec 16 04:24:33 MST 2010
On Thu, 2010-12-16 at 09:04 +1100, Gus Correa wrote:
> Hi Martin
> Not sure if this will help, but there it goes anyway.
> In March I asked MathWorks/Matlab how to control the number of threads
> used by Matlab.
> Their software engineer was very forthcoming, but I ended up with the
> impression that there is no way to have a consistent control of the
> number of active threads for all Matlab operations.
> It seems to depend on which Matlab functions are being called,
> and on different mechanisms that Matlab uses to control
> the number of threads.
> For instance, (most) Linear Algebra functions can be
> controlled by MaxNumCompThreads, which you set
> inside Matlab (or the Matlab script).
> However, for the FFTs functions, for instance,
> you either get one thread only or all the cores/cpus
> in the node/computer.
> In this case the behavior seems to be selected through
> -singleCompThread, a flag that you set when you launch Matlab.
> Given this lack of master control on the number of threads,
> I asked the users to request a full node
> to run Matlab, to launch Matlab in batch mode through a wrapper
> with nodisplay, nojvm, no-nothing.
> To my joy and relief nobody is currently using Matlab in the cluster anyway.
> I wonder if what you described is a side effect of these
> multiple mechanisms that Matlab seems to use to control the
> number of threads, and perhaps how they interact with the
> resources that Torque makes available to each job.
The main reason why I have started experimenting with the cpuset support
in Torque is that I hoped it would solve our original problem of MATLAB
grabbing all available cores. My interpretation of the advice we
received from Mathworks about that original problem is that fine-grained
control of threads is no longer possible. You can either restrict
MATLAB to one thread (-singleCompThread) or apply no restrictions and
MATLAB will use as many cores as it can. The maxNumCompThreads()
function is deprecated.
Anyway, I have isolated the cpusets problem a little further. It
appears that MATLAB will only behave correctly when it is assigned the
first N cores. So if my job requests 4 cores and it is allocated cores
0-3 then all 4 cores are used in my matrix multiply test. However, if
the job is allocated cores 4-7 then only one core will be used, even if
there is no other job running on that node.
I'll post the problem on a MATLAB forum and report back here if I make
More information about the torqueusers