2 parfor loops and gathering/distributing cell array

1 次查看(过去 30 天)
I have a question about timing in the following minimal code. It appears that between the first and second parfor loops, time is spent gathering components of the cell array from the workers and then redistributing them to the workers. Is there any way to avoid this while still using parfor and not spmd/distributed arrays. Also, I need to do this in two stages with two parfor loops, I cannot do it with one parfor loop.
Kcell = cell(numNodes,1);
parfor n = 1:numNodes
Kcell{n} = rand(3,3*numNodes);
end
parfor n = 1:numNodes
Kcell{n}(:,1) = 1; % some other operation on Kcell{n}
end
K = cell2mat(Kcell);
% do something with K like a linear solve

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by