parfor calculations take longer time than for
Show older comments
I am starting to work with the Parallel Computing Toolbox, and just constructed simple example to compare for and parfor:
tic
a=rand(4000,4000);
k=size(a,1);
(par)for i=1:k
for j=1:k
a(i,j)=2/(2+a(i,j));
end
end
toc
I computed this with parfor and for (I wrote par in brackets so first time there is no "par", and second there is "par"). Computational time is several seconds, but parfor calculates it two or three times slower. I also used matlabpool (4 workers) before.
What is the problem?
Thanks in advance
3 Comments
Zoltán Csáti
on 25 Oct 2014
It is much slower on my dual-core machine too. I am also curious why it is.
Mikhail
on 25 Oct 2014
Mikhail
on 25 Oct 2014
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!