Low performance on Matrix operations when using parallel computing tools
1 回表示 (過去 30 日間)
古いコメントを表示
Normal operations in Matlab are well optimized. For example, if I ran,
A = rand(500,500);
b = rand(500,1);
tic
for i = 1 : 1000000
A * b;
end
toc
It ran fast and consumed all computing resources available. ( It finished in about 30s)
However, if I explicitly created parallel workers by,
parpool('local',12)
And re-ran above codes, all the artificial created workers were idle. Meanwhile, it seemed Matlab only ran the program on the master thread, which resulted in much slower performance than that of not using parpool. (it finished in about 3000s, about 100x slower) Further, if I shutdown the parallel pool through down left button (or delete(gcp)) and ran the above code again, sometimes Matlab execute this fast, sometimes not. A restart always fixed the problem.
Is that normal? It seemed Matlab will not automatically parallel its optimized builtin functions when explicitly using parallel toolbox.
Occasionally, I would receive the following information, after turning off parallel workers,
MATLAB detected: 24 physical cores.
MATLAB detected: 48 logical cores.
MATLAB was assigned: 4 logical cores by the OS.
MATLAB is using: 4 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.
MATLAB is not using all logical cores because Operating System restricted the number of cores to: 4.
What can I do if I want to program using parfor as well as taking advantage of high efficient optimized builtin functions?
1 件のコメント
Adam
2018 年 3 月 27 日
Threads can't subdivide so if you are using parallel threads in an outer loop then each only has 1 core available to it, in general so will not be optimal in itself. Parallelisation is not an exact science - you have to try out often many combinations or ways of calculating results to find the optimal performance, but usually allowing Matlab's optimised functions to work at their best, without subduing them to a single core each, would tend to be better.
回答 (0 件)
参考
カテゴリ
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!