필터 지우기
필터 지우기

Parallel pool sizing for a parfor loop

조회 수: 3 (최근 30일)
Patrick Aoun
Patrick Aoun 2016년 9월 15일
답변: Matt J 2016년 9월 16일
I run a parfor loop on an 8 cores workstation.
This loop is parfor i = 1:10 and the work in each iteration is substantial.
MATLAB automatically creates 8 workers.
Assuming that each iteration takes about the same time to complete, is this highly inefficient? I'm thinking that the 8 cores finish at about the same time, and then only 2 are assigned to the remaining 2 iterations.
Then again, I don't really understand the idea of parallel pools. How would I optimise the size?
  댓글 수: 1
Brendan Hamm
Brendan Hamm 2016년 9월 15일
Theoretically with nothing running on the machine these should finish "about the same time" if every iteration runs exactly the same (i.e. no branching with if statements etc.). However, your computer has other stuff running on it as well which will take some cpu time here and there for other processes. MATLAB does not block the use of these to other processes. So, I would conclude with don't worry if the last iteration only has 2 workers being used, the others are still available.

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

채택된 답변

Matt J
Matt J 2016년 9월 16일
Based on my own personal experience, the choice of the parpool size can be optimized only through experimentation. I have found that too many workers can be as counter-productive as too few, even when the selected pool size doesn't exceed the number of physical cores. There is an optimal middle ground that only experimentation allowed me to find.
Granted, this was a few years and a few MATLAB versions ago, and may have been a platform-dependent thing anyway... To be honest, I'm a bit surprised to hear that people still use parfor, given the time needed to launch a parpool. I use gpuArray all the time, but starting a parpool takes as long as most of the jobs I would like to accelerate.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by