Main Content

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

Checks that Require Update Diagram

These checks require that Update Diagram occurs in order to run.

See Also

Improve Simulation Performance Using Performance Advisor

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 Simulation Modes Settings

These checks evaluate simulation modes (Normal, Accelerator, Rapid Accelerator, Rapid Accelerator with up-to-date check off) and identify the optimal mode to achieve fastest simulation.

See Also

What Is Acceleration?

Check Compiler Optimization Settings

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

See Also

Compiler optimization level

Check Hardware Acceleration Settings

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

See Also

Hardware acceleration

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 (signals logged). 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

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 simulations.

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 C compiler used for Accelerator and Rapid Accelerator modes also affects the time required in the compile step.

See Also

Identify inefficient lookup table blocks

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

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 an Interpreted MATLAB Function, an Interpreted MATLAB Function block 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 to improve simulation speed.

See Also

Check model reference rebuild setting

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

See Also

Identify Scope blocks

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 select 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

Check model reference parallel build

To improve simulation, verify the number of referenced models in the model. If there are two or more referenced models, build the model in parallel if possible.

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 discrete and continuous rates, the coupling between these rates can slow down simulation. Performance Advisor checks for these conditions in your model.

  • The model is using a variable step solver.

  • The model contains both continuous and discrete rates.

  • The fastest discrete rate is relatively smaller than Max step size determined by the solver.

Setting the DecoupledContinuousIntegration parameter to on 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.

Setting the MinimalZcImpactIntegration parameter to On might speed up simulation.

See Also

Check discrete signals driving derivative port

Run this check if your simulation has many unnecessary resets. A discrete signal 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 around the discovered discrete signals that drive these blocks to remove such cases. For example, inserting a Zero Order Hold block between the discrete signal and the corresponding block with continuous states might help resolve the issue.

See Also

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 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 multi-thread co-simulation setting on or off

Adjust co-simulation settings for better performance and accuracy.

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

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

Tip

You can use the tic and toc functions to measure the simulation time.

See Also

Identify co-simulation signals for numerical compensation

Identify co-simulation signals that may 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

You can use the tic and toc functions to measure the simulation time.

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

Select simulation mode

To achieve fastest simulation time, use this check to evaluate the following modes and identify the optimal selection:

  • 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 it requires no separate compilation step. 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 supports the debugger and profiler, but not runtime diagnostics.

In Rapid Accelerator mode, simulation speeds are fastest but this mode only works with models where C-code is available for all blocks in the model. Also, this mode does not support the debugger or profiler.

When choosing Rapid Accelerator with up-to-date check off, Performance Advisor does not perform an up-to-date check during simulation. You can run the Rapid Accelerator executable repeatedly while tuning parameters without incurring the overhead of up-to-date checks. For instance, if you have a large model or a model that makes extensive use of model reference, this method of execution can increase efficiency.

For models with 3–D signals, Normal or Accelerator modes work best.

See Also

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 will be skipped if MATLAB is not configured to use an optimizing compiler.

See Also

Select hardware acceleration setting

This check will compare 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 may 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