How can I use the Parallel Computing Toolbox to run multiple Simulink simulations in a parallel or distributed fashion?

I would like to know whether it is possible to use the Parallel Computing Toolbox to do either of the following:
1) Run multiple instances of one Simulink model on different cores, processors, or cluster machines. The instances would be running according to different, independent sets of parameters, or operating on different, independent data sets.
2) Run different Simulink models on different cores, processors, or cluster machines.

 Accepted Answer

1. Running a single simulation on multiple cores

A single Simulink simulation is primarily single-threaded, but specific parts of the simulation can execute in parallel when the model and configuration allow. Key mechanisms include:
Many built-in Simulink blocks (e.g., matrix operations, linear algebra) rely on multithreaded BLAS/LAPACK libraries. These automatically use multiple CPU cores when performing large computations.
LAPACK in MATLAB - MATLAB & Simulink
The Dataflow domain enables concurrent execution of independent parts of a model using a data-driven execution model.
For Each Subsystems can be configured to process elements of an array or signal in parallel.
Certain co-simulation workflows (e.g., FMU import, external solvers, or model references in accelerator modes) can execute concurrently depending on solver and partitioning setup.
Summary:
You cannot generally parallelize an entire single simulation automatically, but there are limited features for parallel execution in specific parts of the model using Dataflow, For Each subsystems, and multithreaded libraries.

2. Running multiple simulations in parallel (recommended approach)

If your goal is to sweep parameters, run test cases, or evaluate scenarios, the recommended modern approach is to run independent simulations in parallel.
Use parsim to run multiple simulations concurrently in a parallel pool.
in(1:10) = Simulink.SimulationInput("myModel");
for i = 1:10
    in(i) = in(i).setVariable("K", i);
end
out = parsim(in);
Key benefits:
  • Easy parameter sweeps
  • Works with Parallel Computing Toolbox
  • Supports fast restart and model reuse
Use batchsim when you want to run simulations:
  • On a cluster
  • In the background
Summary:
For most workflows (parameter sweeps, Monte Carlo, regression testing), parallel simulations using parsim or batchsim are the preferred and most scalable solution.

More Answers (0)

Categories

Products

Release

R2008a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!