Low performance on Matrix operations when using parallel computing tools

조회 수: 3 (최근 30일)
Wei HU
Wei HU 2018년 3월 27일
댓글: Adam 2018년 3월 27일
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
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 CenterFile Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by