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!