3

Switching a parfor to a parfeval

 1 month ago
source link: https://blogs.mathworks.com/videos/2024/03/20/switching-a-parfor-to-a-parfeval/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Switching a parfor to a parfeval » Stuart’s MATLAB Videos

I use parfor a lot when processing large amounts of data. It could be on my local machine, or it could be on a remote cluster. It is very simple to convert a for loop to a parfor loop and often you do not need to change the code in your loop.

A parfor is efficient when the work required for each iteration is similar, but if it’s not, then, near the end of your loop, some workers can become idle. This is where parfevalcan be helpful. It’s a little more complicated to use, but it will keep all workers busy until the work is finished. As a result, you should get your calculation finished sooner.

Here I take a parfor loop in one of my existing scripts, and attempt to convert it to use parfeval instead.

Features covered in this code-along style video include:

  • parfor
  • parfeval, FevalFuture
image.jpg

Play the video in full screen mode for a better viewing experience. 


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK