spmd for drange extremely slow

2 次查看(过去 30 天)
Christoph W
Christoph W 2011-2-24
i try to run spmd with a for drange loop even if i try the example from the mathlab documentation i'll take 1000x more than using a normal for loop
i'am using a Matlab 2010b May system is a Q9000 quad core 2x 2GHz using a matlabpool of 4 workers
spmd
PP = codistributed.zeros(6,8,12);
RR = rand(6,8,12,codistributor())
% Default distribution:
% by third dimension, evenly across 4 labs.
for ii = 1:6
for jj = 1:8
for kk = drange(1:12)
PP(ii,jj,kk) = RR(ii,jj,kk) + labindex;
end
end
end
end
most time takes the function SpmDControllerImpl (Java maethod)
why is it so extremely slow??
thanks Christoph

回答(2 个)

Dmitry
Dmitry 2011-2-24
Hi, Cristoph!
To my mind, parallel compuing starts to make sense if the number of loop iterations is rather high (which is not the case -- you have "only" 576). You may want to perform a simple test by increasing the number of drange() iterations to, say, 1e4 or more if you have time. It is only my oppinion and, of course, you may have something constraining the speed in matlab settings.
Dmitry.

Jill Reese
Jill Reese 2011-3-4
For this simple example there really is no need for the nested for loops. This documentation example provides a simple illustration of the drange concept, but it is not suggesting that drange is the best tool for this type of problem.
spmd
PP = codistributed.zeros(6,8,12);
RR = codistributed.rand(6,8,12);
PP = RR + labindex;
end

类别

Help CenterFile Exchange 中查找有关 Distributed Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by