Loops are slow inside spmd blocks!!

Hi, Can anybody explain what's happening here:
spmd(0) for i=1:100000000,end end
is supposed to run the code on the client. This on most systems is 22 times slower than:
for i=1:100000000, end
without the spmd. However,if you take the loop and put it in a function like:
spmd (0) testfun; end
function testfunc for i=1:100000000,end end
it runs the same speed without spmd. This is quite puzzling.

回答 (1 件)

Sarah Wait Zaranek
Sarah Wait Zaranek 2012 年 2 月 20 日

0 投票

Looks like loops inside parfor/spmd with tons of iterations are not getting all the benefit from JIT (Just-in-Time interpreter/compiler) which allows for-loops to run faster and not be interpreted very single time step.
I have seen this happen before mostly with cases like this - with many, many iterations of a very simple loop.
To force the JIT into action, the appropriate work-around is to put it in a function - as you have done here.

カテゴリ

ヘルプ センター および File ExchangeParallel for-Loops (parfor) についてさらに検索

質問済み:

2012 年 1 月 12 日

編集済み:

2017 年 10 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by