フィルターのクリア

Why is parfor 500 times faster with 12 workers on a loop of size 100

1 回表示 (過去 30 日間)
Bananach
Bananach 2016 年 4 月 16 日
回答済み: Bananach 2016 年 4 月 16 日
I am running code that is equivalent to
A=init();
T=init2();
N=100;
B=zeros(N,1);
for i=1:N
B(i)=T.foo(A(i));
end
If I replace the for loop by a parfor, using my local pool, then the computation is approximately 500 times faster (0.4 seconds instead of 238 seconds).
How can this possibly happen, given that the for loop is only of size 100 and that I only have 12 workers (according to the small little button on the left-bottom corner of MATLAB, and also since I have only 12 cores on my CPU)?
Not that I am unhappy with the speedup, but I feel like there is something going on I should know about.
EDIT: I reduced the loopsize to 1, and parfor is still 10 times faster. For the one single computation!

採用された回答

Bananach
Bananach 2016 年 4 月 16 日
Restarted, and the effect went away. for loop became faster, in a way that made the numbers reasonable

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by