what does "parpool close force local" mean?

5 views (last 30 days)
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!

Accepted Answer

Walter Roberson
Walter Roberson on 12 Jul 2020
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

More Answers (0)

Categories

Find more on Parallel Computing Fundamentals in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!