How Parallel 4 Works with PARFOR with Core i3 in Matlab

I have Matlab R2012b for 64 bit Ubuntu. I have an Intel Core i3 M 330 @ 2.13GHz ร— 4 processor.

I want to use parfor to parallelize 4 loops simultaneously. Since Intel Core i3 has 2 cores and 4 threads, I use this code:

if matlabpool('size') == 0 % checking to see if my pool is already open matlabpool(4) else matlabpool close matlabpool(4) end 

And I get the following error:

Error:

You requested at least 4 workers, but the "local" cluster has the NumWorkers property set for a maximum of two workers. To start a communication job for more workers than this (up to 12 for the local cluster), increase the NumWorkers property for the cluster. The default value for NumWorkers for the local cluster is the number of cores on the local machine.

Why? The default value of NumWorkers in my machine is 2, but if I can do 4 cycles at the same time, how to do it?

+6
source share
2 answers

To increase the default value of NumWorkers , open the Cluster Profile Manager (Parallel-> Manage Cluster Profiles). Select the local profile, click "Edit" and increase NumWorkers to the maximum possible value (in your case 4). Now you can create matlabpool with more workers than physical kernels on your computer.

However, note that using more workers than cores can result in lower performance than the same number of workers as cores.

+8
source

To programmatically change the NumWorkers value from 2 to 4 from the local cluster profile, you can use :

 myCluster = parcluster('local'); myCluster.NumWorkers = 4; % 'Modified' property now TRUE saveProfile(myCluster); % 'local' profile now updated, % 'Modified' property now FALSE 
+8
source

All Articles