Parallel programming: parfor vs for computing time
Show older comments
Good afternoon.
I'm interested in learning parallel programming in matlab. For that reason I tried some scripts in matlab using both the function for and parfor, just to explore the differences between them and the time that took both to run the script. I am yet to see a script where parfor runs in less time than a for cycle... I'm starting to think that the problem might be of my computer instead of my scripts..
My processor is dual-core, and whenever I use parfor I first run the function matlabpool open 2.
Can anyone tell me if the problem is from my computer or my scripts? If possible can anyone give me a simple script that should run faster with parfor so I can test it against a normal version using for?
Thanks in advance. Jaló.
Accepted Answer
More Answers (2)
Walter Roberson
on 9 Aug 2012
0 votes
I would expect that you might improve by using functions instead of scripts. Until one of the very recent releases, scripts were not accelerated.
Jason Ross
on 9 Aug 2012
0 votes
In addition to Sumit's response, you also have to take a look at the machine itself. If you open too many worker processes, you can take more resources than the machine has to give, and end up taking longer since you have to wait on some shared resource like memory or disk access.
Categories
Find more on Loops and Conditional Statements 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!