Parallel programming: parfor vs for computing time
이전 댓글 표시
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ó.
채택된 답변
추가 답변 (2개)
Walter Roberson
2012년 8월 9일
0 개 추천
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
2012년 8월 9일
0 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!