Shut down parallel pool - only working for parfeval() but not spmd

조회 수: 17 (최근 30일)
Timo Schmid
Timo Schmid 2020년 4월 9일
답변: Deepak Meena 2021년 6월 28일
Hello all,
I would like to shut down my parallel pool by a button press in a Matlab GUI to stop the execution of functions running on these pool workers.
Unfortunately this only works when starting the functions with "parfeval()". In this case, as soon as I press the button, my parallel pool is shutting down and therefore the functions called with parfeval() stop running.
As I prefer using "spmd" over "parfeval" to establish communication between the workers, I tried the same but it failed.
Nothing is happening on a button press and the parallel pool is only shutting down as soon as I cancel the whole script with ctrl+c.
Hope someone can assist me with this problem.
Working:
function StartButtonPushed1(app,event)
pool = gcp();
parfeval(pool, @dosomething, 0, app);
end
Not working:
function StartButtonPushed2(app,event)
pool = gcp();
spmd
dosomething(app);
end
end
Stop-button:
function StopButtonPushed(app,event)
delete(gcp); %shutdown pool
end

답변 (1개)

Deepak Meena
Deepak Meena 2021년 6월 28일
Hi,
delete(gcp) works with spmd as well.
Try:
spmd,workers=labindex,end
delete(gcp)
This will shut down the current parallel pool. The problem might be with the dosomething(app) that you are doing inside the spmd function.
Please elaborate on the dosomething(app) so we can investigate further.
Thanks

카테고리

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