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
问问题
2269 次
1 回答
4
如果您使用MDCS集群, PARFOR 可以跨多台机器运行,因此它必须能够将所需的数据复制到工作人员。碰巧的是,即使工作人员与您的桌面 MATLAB 位于同一主机上,它也会复制数据。造成这种情况的部分原因是 MATLAB 无法理解何时可以安全地共享数组。请注意,这适用于“广播”数据,而不是“切片”数据 - 当数组被“切片”时,只有相关部分被发送给每个工作人员。在以下人为的示例中:
broadcast = rand(400);
slicedIn = rand(400);
parfor idx = 1:400
slicedOut(idx) = numel(broadcast) + sum(slicedIn(:, idx));
end
然后将所有broadcast
内容复制到每个工人;而只有所需的slicedIn
和slicedOut
被复制。更多信息:http: //www.mathworks.co.uk/help/distcomp/advanced-topics.html#bq_of7_-1
于 2013-07-15T07:34:03.717 回答