Why parfor is slower than for in my algorithm?
Show older comments
Why this:
...
parfor i=1:k
if M(:,:,i)*A*M(:,:,i)'==B
iz(1,i)=1;
end
end
...
is slower than the same algorithm with non-parallel for? A and B are n*n matrices, M is array of all n*n permutation matrices, k=n!. I can use only 2 workers.
- n=4 - 250 times slower than non-parallel for
- n=5 - 40 times slower
- n=6 - 10 times slower
- n=7 - 4 times slower (0.16 sec vs 0.04 sec)
- n=8 - 2 times slower (0.8 sec vs 0.4 sec)
- n=9 (9!=362880) - 2.5 times slower (?) (10 sec vs 4 sec)
- n=10 - error in parfor vs 55 sec in for
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!