Parallel for-Loops (parfor) - MATLAB & Simulink (original) (raw)

Main Content

Use parallel processing by running parfor on workers in a parallel pool

Parallel Computing Toolbox™ supports interactive parallel computing and enables you to accelerate your workflow by running on multiple workers in a parallel pool. Use parfor to execute for-loop iterations in parallel on workers in a parallel pool. When you have profiled your code and identified slow for-loops, try parfor to increase your throughput. Develop parfor-loops on your desktop and scale up to a cluster without changing your code.

Functions

expand all

Functions and Classes

parfor Execute for-loop iterations in parallel on workers
parforOptions Options set for parfor
parpool Create parallel pool on cluster
parfeval Run function on parallel pool worker
ticBytes Start counting bytes transferred within parallel pool
tocBytes Read how many bytes have been transferred since callingticBytes
send Send data between clients and workers using a data queue
afterEach Define a function to call when new data is received on a data queue
parallel.Pool Parallel pool of workers
parallel.pool.DataQueue Send and listen for data between client and workers

Topics

Getting Started with parfor

Running parfor-Loops

Deep Learning

Plot During Parameter Sweep with parfor

Scale Up from Desktop to Cluster

Use parfor to Speed Up Monte-Carlo Code

Use parfor to Speed Up Monte-Carlo Code

Speed up Monte-Carlo code by using parfor-loops. Monte-Carlo methods are found in many fields, including physics, mathematics, biology, and finance. Monte-Carlo methods involve executing a function many times with randomly distributed inputs. With Parallel Computing Toolbox, you can replace a for-loop with a parfor-loop to easily speed up code.

MathWorks - Domain Selector