matlabpool open n; doesn't work.
12 次查看(过去 30 天)
显示 更早的评论
Hi,
I'd like to open matlabpool with a variable number of cores, to use the maximum number of cores available. So n would equal features('numCores') here.
But matlabpool open n, matlabpool open features('numCores'), matlabpool open maxNumCompThreads don't work here. matlabpool open seems to accept only numbers and not variables.
I could do something stupid like
if features('numCores') == 4
matlabpool open 4;
elseif features('numCores') == 2
matlabpool open 2;
end
but I'd like to know if something more elegant exists.
Thanks!
0 个评论
采纳的回答
Niklas Nylén
2014-5-7
编辑:Niklas Nylén
2014-5-7
This is because writing arguments like this:
matlabpool open 2
is the same as passing the strings 'open' and '2' to the matlabpool function, i.e. the equivalent to
matlabpool('open','2')
What you can do is to call matlabpool like this:
matlabpool('open', num2str(features('numCores')))
Possibly you can also pass the number of cores directly, but since I do not have parallell computing toolbox I can't test it, like so:
matlabpool('open', features('numCores'))
0 个评论
更多回答(2 个)
Malshikho
2018-5-25
Unfortunately I have Matlab R2010b
1 个评论
Steven Lord
2018-5-25
Then use matlabpool using the syntax described in the accepted answer by Niklas Nylén.
另请参阅
类别
在 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!