| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
The MATLAB software supports two types of multiprocessing: implicit and explicit.
Characteristics of implicit multiprocessing:
Runs multiple threads on a single machine, most often using one thread per processing unit.
Requires a multiple CPU (multiprocessor or multicore) system.
Speeds up elementwise computations such as those done by the sin and log functions, and computations that use the Basic Linear Algebra Subroutines (BLAS) library, such as matrix multiply.
Does not require any changes to your MATLAB code.
Works behind the scenes to take advantage of the processing units available to you. It does this by multithreading the computationally-intensive math library functions that you use in the course of your MATLAB session.
MATLAB enables multithreaded computation by default. You can disable it by specifying the singleCompThread option when starting MATLAB.
Characteristics of explicit multiprocessing:
Runs separate processes on one or many machines.
Requires installation of Parallel Computing Toolbox.
Speeds up execution of large MATLAB jobs. Enables you to run jobs simultaneously on a cluster of computers, or as several processes on a single machine.
Requires that you modify your MATLAB code.
The Parallel Computing Toolbox supports programming constructs for distributed arrays and parallel for (parfor) loops. It also supports both interactive and batch execution.
Enable explicit multiprocessing by installing Parallel Computing Toolbox.
Multithreaded computation runs in a single instance of MATLAB and generates simultaneous instruction streams on a multiple CPU (multiprocessor or multicore) system. The multiple processors share the memory of a single computer. The work to be processed is implicitly partitioned for execution on multiple threads. Multithreaded computation in MATLAB speeds up elementwise computations such as those done by the sin and log functions, and computations that use the Basic Linear Algebra Subroutines (BLAS) library, such as matrix multiply.
Note See MATLAB Multiprocessing for an overview of the multiprocessing capabilities provided with MATLAB. |
Multithreaded computation in MATLAB is enabled by default. When enabled, MATLAB automatically detects the number of CPUs on your system and recommends the number of threads based on that. To disable multithreaded computation, start MATLAB using the singleCompThread option.
To set or retrieve the maximum number of computational threads from the command line or from within an M-file program, use the maxNumCompThreads function. You can either set the maximum number of computational threads to a specific number, or indicate that you want the setting to be done automatically by MATLAB.
To set the maximum number of computational threads to a specific number N, use
maxNumCompThreads(N)
To have MATLAB set the maximum number of threads, use:
maxNumCompThreads('automatic')maxNumCompThreads also returns the current maximum number of threads if you call it with an output value:
oldN = MaxNumCompThreads(newN)
See the Parallel Computing Toolbox documentation for information regarding explicit multiprocessing in MATLAB.
![]() | Techniques for Improving Performance | Memory Usage | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |