登录论坛

查看完整版本 : Preparing to Run Code in Parallel - Loren on the Art of MATLAB


poster
2021-04-24, 17:42
https://blogs.mathworks.com/wp-content/themes/mathworks_1.0/images/placeholder_5.jpg
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

...read more >> (https://blogs.mathworks.com/loren/?p=4006)

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

More... (http://feedproxy.google.com/~r/mathworks/loren/~3/t2A0rdsydnM/)