MATLAB Multicore

Run MATLAB on multicore and multiprocessor machines

MATLAB® and Simulink® enable you to take advantage of multicore and multiprocessor computers in two main ways: built-in multithreading and explicit parallelism using MATLAB workers. You can run your MATLAB applications and Simulink models faster and more efficiently by using the full computational power of your machine.

Built-In Multithreading

The built-in multithreading feature in MATLAB automatically parallelizes computations using underlying libraries at runtime, resulting in significant performance improvements for linear algebra and numerical functions such as fft, eig, mldivide, svd, and sort. Since MATLAB does this implicitly, you do not need to enable it manually. If you would like to control the number of computational threads, you can use the maxNumCompThreads function.

Similarly, Simulink prepares all eligible models and blocks for execution on multiple threads. When Simulink detects that performance can be improved, it automatically executes the eligible models using multiple threads, resulting in faster execution times.

Explicit Parallelism Using MATLAB Workers

Parallel Computing Toolbox™ provides functions for creating and using parallel pools, allowing you to use additional hardware resources through threads and processes to enhance your application's performance and reduce time to results. Parallel pools can be leveraged in MATLAB and Simulink by using parallel programming features, including parallel-for-loops (parfor), parallel queues (parfeval), parallel execution of a single program with multiple data (spmd), and parallel simulations (parsim).

There are a growing number of functions and features for MATLAB and Simulink that help you take advantage of parallel computing resources without requiring any extra coding. For example, in Simulink, you can easily enable parallel support in some interfaces by setting a flag or preference.

Process-Based Parallel Pool

Parallel Computing Toolbox allows you to execute MATLAB applications in parallel using multiple worker processes (computational engines) on a local machine or a remote cluster. By default, these process workers are computationally single-threaded.

Unlike built-in multithreading, the explicit parallelism provided by a parallel process-based pool can help you scale parallel applications that use MATLAB workers beyond a single machine by leveraging compute clusters enabled with MATLAB Parallel Server™.

Thread-Based Parallel Pool

Thread-based parallel pools allow you to achieve parallelism and distribute computations across multiple threads within a single MATLAB process. These pools reduce communication overhead and enable shared memory access, but their use is limited to computations on a single machine. With MATLAB, you can enable a single additional thread worker with backgroundpool, while Parallel Computing Toolbox lets you use multiple thread workers through parpool(“threads”).