MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB技术文章 (https://www.labfans.com/bbs/forumdisplay.php?f=25)
-   -   Preparing to Run Code in Parallel - Loren on the Art of MATLAB (https://www.labfans.com/bbs/showthread.php?t=27091)

poster 2021-04-24 17:42

Preparing to Run Code in Parallel - Loren on the Art of MATLAB
 
[IMG]https://blogs.mathworks.com/wp-content/themes/mathworks_1.0/images/placeholder_5.jpg[/IMG]
In a recent post, I talked about for-loops in MATLAB and how to optimize their use knowing how MATLAB stores arrays in memory. Today I want to talk about getting ready for parallel computation, specifically using parallel for-loops, via parfor. En route to creating code suitable for running in parallel, sometimes we take code with a for-loop and simply replace it with a parallel loop, using parfor. That is, if we can't vectorize the code well first. This transformation from for->parfor works really well sometimes, but does not always work, and for very good reasons. For example, you can't simply replace for with parfor if loop iterations are not completely independent. You can find out more conditions here. There is a notable

...[URL="https://blogs.mathworks.com/loren/?p=4006"]read more >>[/URL]

[IMG]http://feeds.feedburner.com/~r/mathworks/loren/~4/t2A0rdsydnM[/IMG]

[url=http://feedproxy.google.com/~r/mathworks/loren/~3/t2A0rdsydnM/]More...[/url]


所有时间均为北京时间。现在的时间是 23:21

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.