what does "parpool close force local" mean?

6 次查看(过去 30 天)
I am using a code based on old version matlab, and I got a error when it comes to:
if numProc <= 1
parpool close force local
else
% poolSize = parpool('size'); % check to see if a pool is already open
p = gcp('nocreate'); % If no pool, do not create new one.
if isempty(p)
poolSize = 0;
else
poolSize = p.NumWorkers
end
if poolSize == 0 || poolSize < numProc || poolSize ~= numProc
parpool close force local
eval(['parpool open ' num2str(numProc)])
end
end
and got the following error:
Error using parpool (line 145)
Properties and values must be specified in pairs.
it seems that the command has been deprecated, what does it mean? and what is its alternatives?
thank you in advance!

采纳的回答

Walter Roberson
Walter Roberson 2020-7-12
Something like,
if numProc <= 1
p = gcp('nocreate');
if ~isempty(p)
delete(p);
end
poolSize = 0;
else
p = gcp('nocreate');
if isempty(p)
poolSize = 0;
else
poolSize = p.NumWorkers;
if poolSize ~= numProc
delete(p);
poolSize = 0;
end
end
if poolSize == 0
try
p = parpool(numProc);
poolSize = p.NumWorkers;
catch
poolSize = 0;
end
end
end

更多回答(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