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