Run Tests Using Parallel Execution
Running tests in parallel can speed up execution and decrease the amount of time it takes to get test results. If you have a Parallel Computing Toolbox™ license, you can execute tests in parallel on your local machine or cluster. If you have a MATLAB® Parallel Server™ license, you can execute tests in parallel on a remote cluster, such as in the cloud.
Note
You can run tests in parallel only on interactive parallel pools that you start by
using parpool
. Running tests on noninteractive parallel pools
is not supported.
When Do Tests Benefit from Using Parallel Execution?
In general, parallel execution can help reduce test execution time if you have
A complex Simulink® model that takes a long time to simulate
Numerous long-running tests, such as iterations
Use Parallel Execution
To run tests in parallel:
Set up and open a parallel pool on the desired cluster, or set the desired cluster as the default. If you have a Parallel Computing Toolbox license, see Discover Clusters and Use Cluster Profiles (Parallel Computing Toolbox). If you have a MATLAB Parallel Server license, see Running Code on Clusters and Clouds (MATLAB Parallel Server). If you do not set your default cluster or have a parallel pool open, the Test Manager uses its default cluster, which is on the local machine.
Open the Test Manager.
On the Test Manager toolstrip, click the Parallel button.
Run a test file. The test file executes using parallel pool.
Note
Baseline, equivalence, custom and assessments criteria evaluation occurs on the host MATLAB and not on the parallel MATLAB workers. Before parallel test execution begins, the base workspace variables from the host MATLAB are transferred to the base workspaces of the parallel MATLAB workers. However, after parallel test execution completes, the base workspace variables are not transferred back to the host MATLAB.
To turn off parallel execution, click the Parallel button to toggle it off.
Starting a parallel pool can take time, which would slow down test execution. To reduce time:
Make sure that the parallel pool is already running before you run a test. By default, the parallel pool shuts down after being idle for a specified number of minutes. To change the setting, see Specify Your Parallel Preferences (Parallel Computing Toolbox).
Load Simulink on all the parallel pool workers.
See Also
Related Topics
- Clusters and Clouds (Parallel Computing Toolbox)