log() much slower in parallel
显示 更早的评论
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 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!