log() much slower in parallel
9 ビュー (過去 30 日間)
古いコメントを表示
I run a MATLAB parallel job using the local scheduler to increase performance of the calculation. However, my function is much slower in the parallel job compared to its serial execution. By profiling I found out that some operations take much more time in parallel tasks (e.g. calling the built-in function log() about 6 times more). Any idea why it is slower?
A simplified example, let us have the following three functions:
function par_test()
Scheduler = findResource('scheduler', 'type', 'local');
Job = createJob(Scheduler);
createTask(Job, @par_func, 1, {});
submit(Job);
waitForState(Job, 'finished')
OutputArgCell = getAllOutputArguments(Job);
pInfoVector = [OutputArgCell{:, 1}];
mpiprofile('viewer', pInfoVector);
destroy(Job);
end
function pInfo = par_func()
mpiInit;
mpiprofile on
par_calc()
pInfo = mpiprofile('info');
end
function par_calc()
U = unifrnd(0, 1, 10000, 10000);
R = log(U);
end
Run
>> par_test
to execute par_calc in one parallel task and generate a profile report.
Run
>> profile on
>> par_calc
>> profile viewer
to execute par_calc serially and generate a profile report. Compare the execution time of log().
0 件のコメント
採用された回答
Walter Roberson
2012 年 11 月 15 日
log() is, I believe, normally automatically parallized over the number of available cores, even without the Parallel Computing Toolbox. If you have 6 cores then 1/6 of the work (approximately) would go to each core. But then when you run in parallel, each session only has access to a single core and cannot distribute the session's work.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で MATLAB Parallel Server についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!