Parallel Computing Fundamentals
Parallel computing can help you to solve big computing problems in different ways. MATLAB ® and Parallel Computing Toolbox™ provide an interactive programming environment to help tackle your computing tasks. If your code runs too slowly, you can profile it, vectorize it, and use built-in MATLAB parallel computing support. Then you can try to accelerate your code by using parfor on multiple MATLAB workers in a parallel pool. If you have big data, you can scale up using distributed arrays or datastore . You can also execute a task without waiting for it to complete, using parfeval , so that you can carry on with other tasks. You can use different types of hardware to solve your parallel computing problems, including desktop computers, GPUs, clusters, and clouds. To get started, see Quick Start Parallel Computing in MATLAB.
Functions
Key functions in Parallel Computing Toolbox
parfor | Execute for -loop iterations in parallel on workers |
parfeval | Run function on parallel pool worker |
gpuArray | Array stored on GPU |
distributed | Create and access elements of distributed arrays from client |
batch | Run MATLAB script or function on worker |
parpool | Create parallel pool on cluster |
ticBytes | Start counting bytes transferred within parallel pool |
tocBytes | Read how many bytes have been transferred since calling ticBytes |
delete (Pool) | Shut down parallel pool |
Topics
Basics
- Choose a Parallel Computing Solution
Discover the most important functionalities offered by MATLAB and Parallel Computing Toolbox to solve your parallel computing problem.
- Parallel Language Decision Tables
Discover example use cases for common parallel computing language features.
- Quick Start Parallel Computing in MATLAB
Learn about parallel computing in MATLAB and Parallel Computing Toolbox.
- Run MATLAB Functions with Automatic Parallel Support
Take advantage of parallel computing resources without requiring any extra coding.
- Interactively Run Loops in Parallel Using parfor
Convert a for -loop into a scalable parfor -loop.
- Choose How to Manage Data in Parallel Computing
Determine the data management approach that meets your parallel computing requirements.
- Plot During Parameter Sweep with parfor
Perform a parameter sweep in parallel and plot progress during parallel computations.
- Scale Up from Desktop to Cluster
Develop your parallel MATLAB® code on your local machine and scale up to a cluster.
- Run Batch Parallel Jobs
Use batch to offload work from your MATLAB session to run in the background.
- Process Big Data in the Cloud
This example shows how to access a large data set in the cloud and process it in a cloud cluster using MATLAB® capabilities for big data.
- Evaluate Functions in the Background Using parfeval
Break out of an optimizing loop early and collect results as they become available.
- Run MATLAB Functions on a GPU
Supply a gpuArray argument to automatically run functions on a GPU.
- Train Network in the Cloud Using Automatic Parallel Support (Deep Learning Toolbox)
This example shows how to train a convolutional neural network using MATLAB® automatic support for parallel training.
Learn More
- What Is Parallel Computing?
Learn about MATLAB and Parallel Computing Toolbox.
- Run Code on Parallel Pools
Learn about starting and stopping parallel pools, pool size, and cluster selection.
- Choose Between Thread-Based and Process-Based Environments
With Parallel Computing Toolbox, you can run your parallel code in different parallel environments, such as thread-based or process-based environments.
- Run MATLAB Functions in Thread-Based Environment
Check support for MATLAB functions that you want to run in the background.
- Set Environment Variables on Workers
Copy system environment variables from the client to workers in a cluster.
- Write Portable Parallel Code
Write parallel code that can use parallel resources if you have Parallel Computing Toolbox and that still runs if you do not have Parallel Computing Toolbox.
Featured Examples
Illustrating Three Approaches to GPU Computing: The Mandelbrot Set
Adapt your MATLAB® code to compute the Mandelbrot Set using a GPU.
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.