Why does MATLAB use only single core when function lu is used?
9 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I try to LU factorize a matrix with multi-cores (4 cores). I assume that MATLAB automatically figures out available multicores and runs LU function with the multi-cores. However, when I see Task Manager of Windows, MATLAB does not use all available multicores. On the MATLAB command line, MATLAB identifies the correct number of cores, but LU does not seem to fully utilize them. Can you suggest how to fully use the resource with function LU? Thanks!
Evan
0 件のコメント
回答 (1 件)
John D'Errico
2016 年 9 月 1 日
編集済み: John D'Errico
2016 年 9 月 1 日
In general, MATLAB tries to use multiple cores only when there will be a gain from doing so. Since there is overhead in trying to split up a problem across cores, only large problems will see any gain. So typical linear algebra problems need to be large before multiple cores are used, as most problems finish within small fractions of a second anyway.
At times, I have managed to get all the cores running on my machine. But it can take a seriously large problem.
2 件のコメント
John D'Errico
2016 年 9 月 1 日
編集済み: John D'Errico
2016 年 9 月 1 日
There is no flag to set to force the basic LU to use multiple cores. It may be that the sparse version of LU will never go multi-threaded, since sparse matrices would seem to be not so easily parallelized. This is a large enough problem that if it WERE possible, then I expect you would see it happening there.
These things do change with MATLAB version, so newer releases have become more capable and more capable in this respect.
I just ran a quick test on my system (R2016a on a Mac with 4 cores), and I was unable to get it to go past 1 core on a smaller problem, although I did choose problems that took several minutes to solve. While yours is considerably larger, I would have expected to see something if this were possible.
Then I ran a second series of tests with full matrices of various sizes. Even for relatively small problems that took less 5 seconds to solve, this very quickly gobbled up all of the cores on my CPU.
So sparsity did prevent MATLAB from grabbing multiple cores. It is clearly much easier to farm out the job on full matrices.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!