Contenido principal

Simulink Performance Advisor Checks

Simulink Performance Advisor Check Overview

Use Performance Advisor checks to improve model simulation time.

See Also

Improve Simulation Performance Using Performance Advisor

Baseline

Establish a measurement to compare the performance of a simulation after Performance Advisor implements improvements.

See Also

Create a Performance Advisor Baseline Measurement

Create baseline

Select this check to create a baseline when Performance Advisor runs. You can also create a baseline manually. A baseline is the measurement of simulation performance before you run checks in Performance Advisor. The baseline includes the time to run the simulation and the simulation results. Before you create a baseline for a model, in the Data Import/Export pane of the Configuration Parameters dialog box:

  • Select the States check box.

  • Set the Format parameter to Structure with time.

See Also

Create a Performance Advisor Baseline Measurement

Simulation

These checks relate to the simulation phase. Subcategories include checks occurring before update, checks that require update diagram, and checks that require simulation to run.

See Also

Improve Simulation Performance Using Performance Advisor

Identify resource-intensive diagnostic settings

To improve simulation speed, disable diagnostics where possible. For example, some diagnostics, such as Solver data inconsistency or Array bounds exceeded, incur run-time overheads during simulation.

See Also

Check optimization settings

To improve simulation speed, enable optimizations where possible. For example, if some optimizations, such as block reduction, are disabled, enable these optimizations to improve simulation speed.

You can also trade off compile-time speed for simulation speed by setting the compiler optimization level. Compiler optimizations for accelerations are disabled by default. Enabling them accelerates simulation runs but results in longer build times. The speed and efficiency of the compiler used to generate the simulation target for accelerator and rapid accelerator modes also affects the time required to compile the model for normal mode simulation.

See Also

Check MATLAB System block simulation mode

In general, to improve simulation speed, choose Code generation for the Simulate using parameter of the MATLAB System block. Because data exchange between MATLAB® and Simulink® passes through several software layers, Interpreted execution usually slows simulations, particularly if the model needs many data exchanges.

This check identifies which MATLAB System blocks can generate code and changes the Simulate using parameter value to Code generation where possible.

While Code generation does not support all MATLAB functions, the subset of the MATLAB language that it does support is extensive. By using this Code generation, you can improve performance.

See Also

Identify Interpreted MATLAB Function blocks

To improve simulation speed, replace Interpreted MATLAB Function blocks with MATLAB Function blocks where possible. Because data exchange between MATLAB and Simulink passes through several software layers, Interpreted MATLAB Function blocks usually slow simulations, particularly if the model needs many data exchanges.

Additionally, because you cannot compile interpreted MATLAB code, Interpreted MATLAB Function blocks impedes attempts to use an acceleration mode to speed up simulations.

While MATLAB Function blocks do not support all MATLAB functions, the subset of the MATLAB language that it does support is extensive. By replacing your interpreted MATLAB code with code that uses only this embeddable MATLAB subset, you can improve performance.

See Also

Identify simulation target settings

To improve simulation speed, disable simulation target settings where possible. For example, in the Configuration Parameters dialog box, clear the Simulation Target > Echo expression without semicolons check box.

See Also

Check model reference rebuild setting

To improve simulation speed, in the Configuration Parameters dialog box, check that the Model Referencing > Rebuild parameter is set to If changes in known dependencies detected.

See Also

Identify Scopes

Opened and uncommented Scope blocks can impact simulation performance. To improve simulation performance, close and comment out Scope blocks. Right-click a Scope block, and then click Comment Out .

For opened Scopes, you can improve simulation speed by reducing updates. From the Scope Simulation menu, select Reduce Updates to Improve Performance.

See Also

Identify active instrumentation settings on the model

Identify active instrumentation settings on the model. The fixed-point instrumentation mode controls which objects log minimum, maximum, and overflow data during simulation. Instrumentation is required to collect simulation ranges using the Fixed-Point Tool. These ranges are used to propose data types for the model (requires Fixed-Point Designer™). When you are not actively converting your model to fixed point, disable the fixed-point instrumentation to restore the maximum simulation speed to your model.

In the Apps tab, select Fixed-Point Tool. Under System under design, click Continue.

In the Model Hierarchy pane, the Fixed-Point Tool denotes systems that currently have instrumentation turned on with (mmo), or (o). Right-click the system in the model hierarchy and, under Fixed-point instrumentation mode, select Use local settings or Force off.

See Also

Checks That Require Update Diagram

These checks require updating the model in order to run.

See Also

Improve Simulation Performance Using Performance Advisor

Check model componentization

Since R2026a

To speed up compilation, check whether your model hierarchy compiles faster with referenced models instead of subsystems.

This check finds identical subsystems that have the same block diagram and interface. The check determines whether the subsystems satisfy at least one threshold criteria and converts the subsystems to referenced models where beneficial. The threshold criteria are the specified minimum number of copies and minimum number of constituent blocks.

For instance, suppose you set Minimum number of subsystem copies in parent model to 3 and Minimum number of blocks in subsystem to 100. This table describes four subsystems and identifies whether the check converts these subsystems to referenced models.

SubsystemNumber of Subsystem Copies in Parent ModelNumber of Blocks in SubsystemResult
A1 (threshold not met)99 (threshold not met)

The check leaves the subsystems as is.

B2 (threshold not met)100 (threshold met)

The check converts the subsystem to a model and replaces each corresponding Subsystem block with a Model block that references the new model.

C10 (threshold met)50 (threshold not met)
D3 (threshold met)200 (threshold met)

This check is not run by default because it compiles the model hierarchy multiple times, which can be time consuming.

See Also

Check model reference parallel build

When you simulate a model hierarchy that references two or more models, you can improve compilation performance by building the referenced models in parallel.

Performance Advisor analyzes the model and estimates the build time on the current computer as if it were using several cores. It also estimates the parallel build time for the model in the same way an estimation would be performed if Parallel Computing Toolbox™ or MATLAB Parallel Server™ software were installed on the computer. Performance Advisor performs this estimate as follows:

  1. Search the model for referenced models that do not refer to other referenced models.

  2. Calculate the average number of blocks in each of the referenced models that do not refer to other referenced models.

  3. Of the list of referenced models that do not refer to others, select a referenced model whose number of blocks is closest to the calculated average.

  4. Build this model to obtain the build time.

  5. Based on the number of blocks and the build time for this referenced model, estimate the build time for all other referenced models.

  6. Based on these build times, estimate the parallel build time for the top model.

To calculate the overhead time introduced by the parallel build mechanism, set the Parallel Build Overhead Time Estimation Factor. Performance Advisor calculates the estimated build time with overhead as:

(1 + Parallel Build Overhead Time Estimation Factor)*(Build time on a single machine)

See Also

Check Delay block circular buffer setting

To improve simulation, check that each Delay block in the model uses the appropriate buffer type. By default, the block uses an array buffer, and the Use circular buffer for state parameter for the block is not selected. However, when the delay length is large, a circular buffer can improve execution speed by keeping the number of copy operations constant.

The Performance Advisor selects a circular buffer if the Delay block currently uses an array buffer and all of these conditions are met:

  • The Delay block Input processing parameter is set to Elements as channels (sample based), or the input signal type is set to Sample based.

  • The value or upper limit of the delay length is 10 or greater.

  • The size of the state, which is equal to the delay length multiplied by the total of all output signal widths, is 1000 or greater.

See Also

Check continuous and discrete rate coupling

If your model contains both periodic and continuous sample times, the coupling between these types of sample time can slow down simulation. Performance Advisor checks for these conditions in your model.

  • The model uses a variable-step solver.

  • The model contains both continuous and periodic sample times.

  • The fastest periodic sample time is smaller than the Max step size of the variable-step solver.

When these conditions are met, selecting the Enable decoupled continuous integration configuration parameter might speed up simulation.

See Also

Check zero-crossing impact on continuous integration

If your model contains zero-crossings which do not impact the continuous integration, the simulation might slow down when all the following conditions are satisfied:

  • The model uses a variable-step solver.

  • The model contains blocks that have continuous states and zero-crossings.

  • Some of the zero-crossings do not affect the integration of the continuous states.

When these conditions are met, selecting the Enable minimal zero-crossing impact integration configuration parameter might speed up simulation.

See Also

Check discrete signals that drive derivative ports

Run this check if your simulation has many unnecessary resets. A signal with a periodic sample time driving a block with continuous states triggers a reset at every sample time hit of the block. These resets are computationally expensive. Performance Advisor checks for these signals and blocks and provides a list of the same.

You can edit the model to eliminate the identified instances of signals with periodic sample times driving blocks with continuous states. For example, inserting a Zero-Order Hold block between the signal and the block with continuous states might help resolve the issue.

See Also

Identify inefficient lookup table blocks

To improve simulation speed, use properly configured lookup table blocks.

See Also

Checks That Require Simulation to Run

These checks require simulation to run in order to collect sufficient performance data. Performance Advisor reports the results after simulation completes.

See Also

Improve Simulation Performance Using Performance Advisor

Check solver type selection

To improve simulation, check that the model uses the appropriate solver type.

Explicit vs. Implicit Solvers

Selecting a solver depends on the approximation of the model stiffness at the beginning of the simulation. A stiff system has both slowly and quickly varying continuous dynamics. Implicit solvers are specifically designed for stiff problems, whereas explicit solvers are designed for non-stiff problems. Using non-stiff solvers to solve stiff systems is inefficient and can lead to incorrect results. If a non-stiff solver uses a very small step size to solve your model, check to see if you have a stiff system.

ModelRecommended Solver
Represents a stiff systemode15s
Does not represent a stiff systemode45

Performance Advisor uses the heuristic shown in the table to choose between explicit and implicit solvers.

Original SolverPerformance Advisor Action
Variable-step continuous solver

Calculates the system stiffness at 0 first. Then:

  • If the stiffness is greater than 1000, Performance Advisor chooses ode15s.

  • If the stiffness is less than 1000, Performance Advisor chooses ode45.

Fixed-step continuous solver
  • If the stiffness is greater than 1000, Performance Advisor chooses ode14x.

  • If the stiffness is less than 1000, Performance Advisor chooses ode3.

This heuristic works best if the system stiffness does not vary during simulation. If the system stiffness varies with time, choose the most appropriate solver for that system rather than the one Performance Advisor suggests.

See Also

Select multithread co-simulation setting

Run this check to help select the optimal multithreaded co-simulation mode for a model that contains thread-safe Simulink components. This check compares the simulation time for the model when the model parameter Multithreadedsim is set as auto and force.

  • auto - Allows the software to select the optimal setting based on computational load for the first time step.

  • force - Enables multithreading for the model.

Performance advisor check to help select multithreaded co-simulation setting

To set the parameter as auto for the model, use this command:

set_param(gcs,Multithreadedsim="auto")

To disable multithreading, set this parameter to off.

See Also

Multithreaded co-simulation diagnosis

Run this check to retrieve a list of all the blocks that are eligible for multithreaded co-simulation. The list specifies if multithreaded co-simulation is enabled each block and provides additional information to help resolve blockers or increase simulation efficiency.

Performance advisor check to help resolve multithreaded co-simulation blockers

See Also

Identify co-simulation signals for numerical compensation

Identify co-simulation signals that might need explicit numerical compensation.

  • Validate and revert changes if time of simulation increases — Performance Advisor reverts previous co-simulation settings the simulation time increases.

  • Validate and revert changes if degree of accuracy is greater than tolerance — Performance Advisor reverts co-simulations if the degree of accuracy is greater than tolerance.

Tip

To evaluate the timing of a simulation, check the TimingInfo structure in the ExecutionInfo property of the Simulink.SimulationMetadata object returned with the simulation results.

See Also

Check Dataflow Domain Settings

To increase the throughput of a dataflow domain, it can be advantageous to increase the latency of the system. The Performance Advisor analyzes the dataflow domains in your model and finds the optimal latency settings. The analysis also identifies any other multithreading limitations in the dataflow domains.

The dataflow analysis is a multistep process where the analysis may simulate the model with run-time profiling enabled for each block inside the dataflow domains before running partitioning analysis.

After the analysis completes, the Performance Advisor suggests a latency value that optimizes the throughput of the system for the multicore CPU architecture of the host computer and identifies any other multithreading limitations in the dataflow domains

See Also

Simulation Targets

These checks relate to the mode selected for the simulation as well as compiler optimization settings. You can select normal, accelerator, or rapid accelerator as the mode for the simulation.

See Also

What Is Acceleration?

Check Simulation Mode Settings

These checks identify the optimal mode to achieve the fastest simulations by evaluating these simulation modes and configurations:

  • Normal

  • Accelerator

  • Rapid accelerator

  • Rapid accelerator with up-to-date check off

See Also

What Is Acceleration?

Select simulation mode

This check helps you optimize the simulation mode configuration for your model to achieve the fastest simulation time. The check analyzes these simulation modes and configurations:

  • Normal

  • Accelerator

  • Rapid accelerator

  • Rapid accelerator with up-to-date check off

In normal mode, Simulink interprets your model during each simulation run. If you change the model frequently, this is generally the preferred mode to use because the compilation time is faster compared to other simulation modes. It also offers the most flexibility to make changes to your model.

In accelerator mode, Simulink compiles a model into a binary shared library or DLL where possible, eliminating the block-to-block overhead of an interpreted simulation in normal mode. Accelerator mode provides some support for interacting with the simulation, such as stepping through time steps, but does not support some features, such as runtime diagnostics.

Rapid accelerator mode provides the fastest execution time but provides the least flexibility and support for interactivity. Not all blocks support rapid accelerator simulation.

When the Performance Advisor evaluates rapid accelerator mode with the up-to-date check disabled, the software does not check whether the rapid accelerator simulation target is up to date before running the simulation. Tuning run-to-run and runtime tunable parameters in your model does not require rebuilding the rapid accelerator simulation target. Skipping the up-to-date check improves simulation efficiency in workflows that modify only tunable parameters between simulations. This configuration improves simulation efficiency for large models and models that make extensive use of model references.

For models with 3–D signals, normal or accelerator modes work best.

See Also

Check Compiler Optimization Settings

Use these checks to select compiler optimization settings for improved performance.

See Also

Compiler optimization level

Select compiler optimizations on or off

Use this check to determine whether performing compiler optimization can help improve simulation speed. The optimization can only be performed in accelerator or rapid accelerator modes.

Note

This check is skipped if MATLAB is not configured to use an optimizing compiler.

See Also

Check Hardware Acceleration Settings

Use the check to compare three hardware acceleration options based on their simulation times.

See Also

Hardware acceleration

Select hardware acceleration setting

This check compares three hardware acceleration options based on their simulation times.

  • Off — Hardware acceleration is disabled and no SIMD is used.

  • Leverage generic hardware (Faster, no rebuild) — Leverage SIMD instructions for hardware generic to Simulink system requirements. This option does not require rebuilding the model for simulation when the host computer changes.

  • Leverage native hardware (Fastest, rebuild allowed) — Leverage SIMD instructions for hardware native to the host computer. This option might require rebuilding the model for simulation when the host computer changes.

You can select the hardware acceleration based on the comparison.

See Also

Final Validation

This check validates the overall performance improvement of simulation time and accuracy in a model. If the performance is worse than the original model, Performance Advisor discards all changes to the model and loads the original model.

Global settings for validation do not apply to this check. If you have not validated the performance improvement from changes resulting from other checks, use this check to perform a final validation of all changes to a model.

See Also