Since PARFOR can operate across multiple machines if you are using an MDCS cluster, then it must be able to copy the required data to the workers. As it happens, it also copies data even if the workers are on the same host as your desktop MATLAB. Part of the reason for this is that MATLAB has no means of understanding when it is safe to share arrays. Note that this applies to 'broadcast' data, not 'sliced' data - when an array is 'sliced', only the relevant portions are sent to each worker. In the following contrived example:
broadcast = rand(400);
slicedIn = rand(400);
parfor idx = 1:400
slicedOut(idx) = numel(broadcast) + sum(slicedIn(:, idx));
end
then all of broadcast
is copied to each worker; whereas only the required pieces of slicedIn
and slicedOut
are copied. More here: http://www.mathworks.co.uk/help/distcomp/advanced-topics.html#bq_of7_-1