Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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!

Akzeptierte Antwort

Bananach
Bananach am 16 Apr. 2016
Restarted, and the effect went away. for loop became faster, in a way that made the numbers reasonable

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by