Is there a way for a worker to see how many workers are in the parpool?

조회 수: 5 (최근 30일)
Bobby Brown
Bobby Brown 2016년 6월 28일
답변: 埃博拉酱 2024년 10월 27일
Hi,
Is there a way for a worker to see how many workers are in a parpool?
Currently i have this, but i have to change the value of NumWorkers before the parpool is started and for the first pctRunOnAll.
NumWorkers = 32;
ParallelPool = parpool(NumWorkers);
pctRunOnAll NumWorkers = 32;
pctRunOnAll ParaScript
I know that i can do..
ParallelPool.NumWorkers
..in the parent script but this doesn't work in a worker.
Thanks

답변 (2개)

Harsh
Harsh 2024년 10월 26일
Hi Bobby,
The “pctRunOnAll command runs the specified code on all workers. So in your code the command pctRunOnAll NumWorkers = 32; sets the NumWorkers” variable for all the workers and you can access it directly.
You can check the following documentation link to understand how pctRunOnAll” works - https://www.mathworks.com/help/parallel-computing/pctrunonall.html
Parallel pools of up to 2000 workers are supported but the actual number of workers depends on various factors. You can check the following documentation to learn more about this topic - https://www.mathworks.com/help/parallel-computing/run-code-on-parallel-pools.html#bufclig-1:~:text=the%20period%20key).-,Factors%20That%20Affect%20Pool%20Size,-Parallel%20Computing%20Toolbox

埃博拉酱
埃博拉酱 2024년 10월 27일
It is recommended that you use spmd instead of pctRunOnAll. In a spmd block, you can easily get the parallel pool size using spmdSize.

카테고리

Help CenterFile Exchange에서 Distributed Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by