Can we have more workers than the number of cores in MATLAB?

I have a processor Core i7

and 4 real cores

. Can I have more than 4 workers

my calculation, or is the number of workers always equal to the number of cores?

Thank.

+3


source to share


1 answer


You will have 8 workers because 4 cores are hyper-threaded, which gives you 8 logical cores. But since there are only 4 physical cores, 8 workers shouldn't be much faster than 4 workers in theory. However, I found that 6 and 8 workers were faster than 4 on my i7.

To do this try

matlabpool open 8;
parfor I = 1:N
    #your code
end

      

EDIT: in R2014a it matlabpool

is replaced by parpool

, so use this instead:

parpool('local', 8);
parfor I = 1:N
    #your code
end

      

to open 8 cores on your local machine.



Note: you only need to run the command matlabpool

once when Matlab starts up. Then you can run many scripts with parfor loops in them without opening workers again, they will stay open until you close them or close Matlab.

This should open 8 workers on your local system.

If you receive a message about the number of available workers, you need to change the parameter: Parallel Menu → Manage Configurations. Right click on the "local" line. On the scheduler tab, set the "Number of workers available for the scheduler" to 8.

Finally, you can only open one worker pool using this:

poolobj = gcp('nocreate');
delete(poolobj);

      

close the open pool. Then you can try to open another pool with more workers.

+4


source







All Articles