Alternative for matlabpool

谁说我不能喝 提交于 2020-03-16 09:14:35

问题


I am trying to use someone else's code and there is this line in it:

if (m<100) || (matlabpool('size')==0)

I am using MATLAB R2016a, so this command fails. What is the equivalent of matlabpool('size') in the new version?

I know that matlabpool is replaced by parpool. But what does matlabpool('size') do specifically? It doesn't actually create the parallel workers.


回答1:


As per the change log:

matlabpool function removed The matlabpool function has been removed. Compatibility Considerations Calling matlabpool now generates an error. You should instead use parpool to create a parallel pool.

matlabpool('size') does exactly what you'd expect it to do: it gives you the size of the current pool, i.e. the amount of workers assigned to it. gcp (GetCurrentPool) does this for you. Its documentation's first example:

p = gcp('nocreate'); % If no pool, do not create new one.
if isempty(p)
    poolsize = 0;
else
    poolsize = p.NumWorkers
end


来源:https://stackoverflow.com/questions/41827593/alternative-for-matlabpool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!