Stuart’s MATLAB Videos

Watch and Learn

Switching a parfor to a parfeval

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

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

|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。