Pergunta

I don't understand how parfor cicle in Matlab parallel computing toolbox works with the memory: I read it share the memory between all workers (then I think every worker (core) can access the memory location of interest without making a local copy) but others references tell me that every core makes a local copy of memory (variables etc.) where it works! what is the answer?Parfor has shared memory system and not makes copies of data or every worker has a local copy of data? Thanks

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top