parfor does not uns parallel pool when a parfeval process is still running

12 ビュー (過去 30 日間)
Andre Zeug
Andre Zeug 2020 年 5 月 1 日
コメント済み: Edric Ellis 2020 年 5 月 6 日
Dear all,
in my code I use parallel pool on a local machine and execute a longer function with 'parfeval'. In the main code I shortly later want to use 'parfor', but checking CPU work load, 'parfor' does not use any worker since 'parfeval' still uses one worker when executing 'parfor'.
Is this behaviour expected?
How to check, if there are still running processes at the parallel pool?
How to wait until all processes at the parallel pool are finished?
Thanks in advance
I am using Win10 64bit, Matlab R2020a, Parallel Computing Toolbox 7.2.
  2 件のコメント
Matt J
Matt J 2020 年 5 月 1 日
The wait() command will block execution until parfeval is finished
Andre Zeug
Andre Zeug 2020 年 5 月 1 日
@Matt Thanks for immediat reply.
But how to find the future object F? So far I execute parfeval in a subfunction and do not handle return values from parfeval.



Edric Ellis
Edric Ellis 2020 年 5 月 1 日
Yes, this behaviour is expected - the different parallel language features parfor, parfeval, and spmd do not share the pool. You can wait for all parfeval requests like so:
p = gcp('nocreate');
if ~isempty(p)
q = p.FevalQueue;
% First wait for any queued futures
% Then wait for any running futures
(The calls to wait need to be in that order - in the other order, any queued futures will start running after the first wait).
  8 件のコメント
Andre Zeug
Andre Zeug 2020 年 5 月 5 日
Interesting, but look at this:
l2 = parcluster('local2'); l2.NumWorkers
ans =
p = parpool('local', 6); p.NumWorkers
>> Starting parallel pool (parpool) using the 'local' profile ...
>> Connected to the parallel pool (number of workers: 6).
ans =
>> l2.NumWorkers
ans =
so 'parpool' is a subset of 'parcluster'? But when creating it extends 'parcluster'.
Edric Ellis
Edric Ellis 2020 年 5 月 6 日
parpool consumes workers from the appropriate cluster. When you say parpool('local', 6), this effectively does the following:
clus = parcluster('local');
parpool(clus, 6);
So, in your case, the 'local' cluster defines NumWorkers to be 8. Your parpool explicitly asks for only 6 of them. As I showed above, all local clusters are linked to a single mechanism behind the scenes. Therefore, (and I admit somewhat surprisingly), calling parpool('local',6) has the side-effect of changing the value of l2.NumWorkers to whatever NumWorkers is specified in your 'local' cluster.


その他の回答 (0 件)


Help Center および File ExchangeParallel Computing Fundamentals についてさらに検索




Community Treasure Hunt

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

Start Hunting!

Translated by