Main Content

Run MATLAB Functions on Thread Workers

Hundreds of functions in MATLAB® and other toolboxes can run on thread workers if you create a thread-backed pool using parpool.

parpool("threads");
parfor i = 1:100
    A(i) = max(eig(rand(3)));
end
For more information about thread-backed pools, see ThreadPool.

Tip

You can improve some parallel workflows by using thread workers instead of process workers. For more information about choosing between the two, see Choose Between Thread-Based and Process-Based Environments.

Check Thread Worker Supported Functions

For a filtered list of MATLAB functions that are fully supported on thread workers, see Functions Supported on Thread Workers.

parallel.pool.DataQueue and parallel.pool.PollableDataQueue are fully supported on a thread worker.

parpool, parfor, parfeval, parfevalOnAll, tall, and parallel.pool.Constant are supported, subject to the following limitations.

  • A thread-based parallel pool does not have an associated cluster object.

  • afterEach and afterAll are not supported.

  • FevalQueue is not supported.

  • Tall arrays do not support write and support only tabular text and in-memory inputs.

Other parallel language functionality, including spmd and distributed is not supported.

The following core MATLAB functionality is supported on a thread worker.

In general, functionality that modifies or accesses things outside of the thread worker is not supported, including the following core MATLAB functionality.

All imageDatastore and imread functionality is supported on a thread worker except for the following image formats.

  • Flexible Image Transport System (FTS, FITS)

  • Hierarchical Data Format (HDF)

  • JPEG 2000 (J2C, J2K, JP2, JPF, JPX)

  • SVS, TIF, TIFF

gpuArray is supported on a thread worker.

See Also