Low performance on Matrix operations when using parallel computing tools

1 Ansicht (letzte 30 Tage)
Wei HU
Wei HU am 27 Mär. 2018
Kommentiert: Adam am 27 Mär. 2018
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 Kommentar
Adam
Adam am 27 Mär. 2018
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Parallel Computing Fundamentals finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by