Parallel Computing Hardware Setting
2 ビュー (過去 30 日間)
古いコメントを表示
I wrote a script that takes hours to run. I opened the Task Manager and noticed it appears to be using all the CPUs. By default does Matlab attempt to use all CPUs or is there a setting somewhere in the software to specify how much hardware it utilizes? Granted, I'd prefer it to use all available hardware, but for my own knowledge, I'd like to know how Matlab decides how much to use.
Thanks,
M Ridzon
0 件のコメント
採用された回答
Walter Roberson
2017 年 11 月 29 日
By default, for "sufficiently large" computations that follow mathematical patterns that MATLAB happens to recognize, then MATLAB will call into high performance libraries telling them it is okay to use a number of threads equal to the number of physical cores (not the number of hyperthreads.) This applies even without the Parallel Computing Toolbox. This can be controlled with https://www.mathworks.com/help/matlab/ref/maxnumcompthreads.html
If you are using the Parallel Computing Toolbox, then by default each worker is given only one thread -- but for large problems the workers will still call into the high performance libraries. Because of the overhead involved in calling those libraries, this can result in some loss of performance. With sufficiently new MATLAB releases you can edit your default cluster profile to allocate more threads per parallel worker.
2 件のコメント
Walter Roberson
2017 年 11 月 29 日
編集済み: Walter Roberson
2017 年 11 月 29 日
"I'm not sure what "sufficiently large" refers to or how Matlab determines that."
MATLAB uses internal heuristics and does not document the exact patterns it detects or the size of problems that lead to the high performance library being called. Likely the size boundaries change every couple of releases.
Generally speaking, the operations that are really fast such as plain addition or element-by-element multiplication, have fewer opportunities for increasing performance by making extra function calls, so MATLAB would want the arrays to be large before bothering. Array sizes of roughly 10000 have been suggested as the breakpoint for those relatively simple operations. The high performance libraries know about factors such as processor cache sizes and so know how to arrange the operations in blocks for really optimal performance -- but the high performance libraries have setup costs and memory transfer costs so it is not always worth coding them.
For more complicated operations such as qr() where more work has to be done per input data point, then MATLAB calls the high performance libraries at smaller breakpoints.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!