spmd for drange extremely slow

2 views (last 30 days)
Christoph W
Christoph W on 24 Feb 2011
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

Answers (2)

Dmitry
Dmitry on 24 Feb 2011
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 on 4 Mar 2011
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

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!