User`s guide
1 Getting Started
1-4
Key Problems Addressed by Parallel Computing
In this section...
“Run Parallel for-Loops (parfor)” on page 1-4
“Execute Batch Jobs in Parallel” on page 1-5
“Partition Large Data Sets” on page 1-5
Run Parallel for-Loops (parfor)
Many applications involve multiple segments of code, some of which are repetitive. Often
you can use for-loops to solve these cases. The ability to execute code in parallel, on one
computer or on a cluster of computers, can significantly improve performance in many
cases:
• Parameter sweep applications
• Many iterations — A sweep might take a long time because it comprises many
iterations. Each iteration by itself might not take long to execute, but to complete
thousands or millions of iterations in serial could take a long time.
• Long iterations — A sweep might not have a lot of iterations, but each iteration
could take a long time to run.
Typically, the only difference between iterations is defined by different input data. In
these cases, the ability to run separate sweep iterations simultaneously can improve
performance. Evaluating such iterations in parallel is an ideal way to sweep through
large or multiple data sets. The only restriction on parallel loops is that no iterations
be allowed to depend on any other iterations.
• Test suites with independent segments — For applications that run a series of
unrelated tasks, you can run these tasks simultaneously on separate resources. You
might not have used a for-loop for a case such as this comprising distinctly different
tasks, but a parfor-loop could offer an appropriate solution.
Parallel Computing Toolbox software improves the performance of such loop execution by
allowing several MATLAB workers to execute individual loop iterations simultaneously.
For example, a loop of 100 iterations could run on a cluster of 20 MATLAB workers, so
that simultaneously, the workers each execute only five iterations of the loop. You might
not get quite 20 times improvement in speed because of communications overhead and
network traffic, but the speedup should be significant. Even running local workers all on