parallel computing speed question when the body of the parfor loop takes about 2 seconds
1 次查看(过去 30 天)
显示 更早的评论
I have a question about parallel:
parfor ii=1:N dosomething%% end
in the parfor loop, the time of dosomething is 2 seconds in each loop, and N is about 100. In that condition, is it efficient to use parfor here???
I feel confused about that as I test the time and find the more core I use, the more time I spend!!!!!! Could someone help to answer this question?!!!!
0 个评论
采纳的回答
Ken Atwell
2015-5-13
It really depends on what "dosomething" is doing. If it is pure computation, it should be a big win. If there is file or network I/O going on, your mileage will vary depending on the application and hardware.
Also keep an eye on memory usage on your computer -- if you're using all of your physical RAM, your computer may be spending much of its time swapping, more than offsetting and gain you'd get from multiprocessor operation.
2 个评论
Walter Roberson
2015-5-13
Pure computation on a local system is fine. If you were using the Distributed Computing Engine to send to several hosts then there would be network traffic. If you were load()'ing files then there would be file I/O.
更多回答(1 个)
Guanfeng Gao
2015-5-13
1 个评论
Walter Roberson
2015-5-13
Are the matrices large? If so then you might be encountering a lot of overhead in transmitting the values back. Try experimenting with drange() instead of parfor()
另请参阅
类别
在 Help Center 和 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!