Why is parfor 500 times faster with 12 workers on a loop of size 100
조회 수: 1 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!