Low performance on Matrix operations when using parallel computing tools
1 view (last 30 days)
Normal operations in Matlab are well optimized. For example, if I ran,
A = rand(500,500);
b = rand(500,1);
for i = 1 : 1000000
A * b;
It ran fast and consumed all computing resources available. ( It finished in about 30s)
However, if I explicitly created parallel workers by,
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?