parfor does not uns parallel pool when a parfeval process is still running
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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
wait(q.QueuedFutures);
% Then wait for any running futures
wait(q.RunningFutures);
end
(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 个评论
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 Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!