why is parfor slower than for?
19 ビュー (過去 30 日間)
古いコメントを表示
In this case, t_parfor is higher than t_for.
N = 100000;
x=zeros(1,N);
tic;
for i = 1 : N
x(i)=rand();
end
t_for = toc;
tic;
parfor i = 1 : N
x(i)=rand();
end
t_parfor = toc;
t_for
t_parfor
0 件のコメント
回答 (1 件)
Sean de Wolski
2013 年 5 月 9 日
First, do you have a matlabpool open? If no matlabpool is open then the parfor loop will not be run in parallel anyway.
Here the data transfer and communication overhead cost more than the computation. parfor will do the most good when the data transfer is low and the calculation time is high.
(And I assume you are aware of: x = rand(N,1) % ;) )
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Parallel for-Loops (parfor) についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!