Use several pools of workers in a parfor loop

조회 수: 9 (최근 30일)
gmhs
gmhs 2019년 9월 9일
댓글: gmhs 2019년 10월 29일
Hi all,
I am currently trying to figure out if there is a way to use multiple pools of workers in a parfor loop. More precisely, I have 16 cores on my computer (8 physical cores) and until now I was using a classical for loop to perform 20 fminunc optimisations.
While fminunc already performs multiprocessing, I found out that the 16 cores of my cluster where only used to 30%, therefore I was thinking about using some kind of parfor loop over three pools of 5 workers in order to increase the efficiency of the computation and hopefully reduce the time of the computation.
I searched for a while now but didn't really find a way to do that...
Thanks a lot !
Gabriel

답변 (2개)

Pravin Jagtap
Pravin Jagtap 2019년 9월 18일
Hello Gabriel,
Yes, most of the MATLAB in-built functions are multithreaded from 2008a Release. Following document may help you in accelerating the problem:
A ‘parfor’ will likely to slow the performance since the inbuilt function of optimization is inherently multithreaded and make use of multiple cores calling. For further optimization/speedup we need to dig more into code which uses parfor.
Kind Regards
~Pravin

Matt J
Matt J 2019년 10월 16일
편집: Matt J 2019년 10월 16일
Your terminology is a bit confusing. There is only ever 1 pool of workers, but each worker may use multiple cores and the entire pool will always try to make best use of all available processors. To loop with a pool of 3 workers (so roughly 5 cores per worker), you would do,
parfor (i=1:20,3)
x{i}=fminunc(...);
end
  댓글 수: 1
gmhs
gmhs 2019년 10월 29일
Thanks for your answer. I managed to solve this issue some time ago now and indeed used a parfor loop with 3 workers. The problem came from the fact that the default cluster profile allows only one thread per worker, it is therefore necessary to change the value of NumThreads to allow fminunc to use all the CPUs.

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

카테고리

Help CenterFile Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by