Hi I'm using matlab parallel computing toolbox to do parallel computing. My laptop is 2 cores 4 threads, so I'm assuming the task could be connected to 4 works? However, when I type in the command "matlabpool open", only 2 workers are connected. Could anyone tell me how to specify the exact number of workers to be connected, so that I could distributed the task the the number of workers more than the number of cores to make the computation more efficiently? Thank you!
You can tell matlab to use a specific number of workers, but it won't let you use more than a maximum amount, which is probably the number of your physical cores version- and cluster-dependent. R2012b allows to use 12 workers in the local cluster, R2014a allows more than 12.
From help matlabpool
:
...
matlabpool [poolSize]
...
matlabpool
ormatlabpool OPEN
starts a worker pool using the default cluster profile with the pool size specified by that profile. You can also specify the pool size usingmatlabpool OPEN <poolSize>
, but note that most clusters have a maximum number of processes that they can start.
% Start a worker pool using the local profile with 2 workers:
matlabpool local 2
Update:
I played around a bit. Asking for 16 workers on R2012b gives me the error
You requested a minimum of 16 workers, but only 12 workers are allowed with the Local cluster.
which means that it is impossible to have more workers with this version. However, if I call the local pool with 12 workers, I get the error
You requested a minimum of 12 workers, but the cluster "local" has the NumWorkers property set to allow a maximum of 4 workers. To run a communicating job on more workers than this (up to a maximum of 12 for the Local cluster), increase the value of the NumWorkers property for the cluster. The default value of NumWorkers for a Local cluster is the number of cores on the local machine.
So, it's possible that you won't be able to use more than 12 workers, depending on your version. If you see the latter error, you can redefine your cluster to allow more cores. Duplicating the local
pool:
mycluster=parcluster('local');
mycluster.NumWorkers=48;
matlabpool(mycluster,48);
...
matlabpool close;