So far as I know, parfor will not use all available cores if Matlab considers the task as not sufficiently heavy.
But does SPMD always use all available cores even if the task is small? It seems to me YES as far as I have tried.
I am working on the shared memory system. Due to the memory restriction, I cannot increase the size of each sub-task in order to increase the computational load. If SPMD can use all the cores regardless of the computational load, then it will be probably more suitable in my case, as SPMD will then not waste the computational ability of the hardwares. But if I finally resort to SPMD, then I will have to make a certain amount of changes to my code.
Any opinions are appreciated. Thank you.

댓글 수: 2

Adam
Adam 2016년 4월 12일
I've not really noticed parfor using anything less than the number of cores available within the opened Matlab pool, unless, of course, there aren't as many indices in the parfor loop as there are cores. I haven't studied it closely though.
Hanzhi Diao
Hanzhi Diao 2016년 4월 13일
I had the same idea with you and expected that parfor could take full use of the computational ability. But the observation has denied my expectation.
I have no idea about the system you work on. The system that I use consists of 80 cores sharing 2TB memory. A typical computation will last around one hour and the entire task is usually divided into about one thousand sub-tasks independent of each other. The computation of each sub-task takes several minutes.
Using 32 cores and 64 cores, the difference in computation time is no more than 300 seconds shown by tic/toc. I believe that my code itself can still be to some extent optimised. Besides that I suspect that some cores cannot be fully engaged and therefore stay idle in the most time of the computation using parfor. This is also observed with the top command in linux environment.

댓글을 달려면 로그인하십시오.

 채택된 답변

Edric Ellis
Edric Ellis 2016년 4월 13일

0 개 추천

spmd blocks by default use all the workers in your parallel pool. You can make an spmd block use fewer workers by specifying the optional argument, like so
parpool('local', 4);
spmd(2)
assert(numlabs == 2);
end

댓글 수: 1

Hanzhi Diao
Hanzhi Diao 2016년 4월 13일
Thanks a lot. I am now on the work changing the parfor code to SPDM.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

질문:

2016년 4월 12일

댓글:

2016년 4월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by