Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Simulink Performance Advisor Checks

Simulink Performance Advisor Check Overview

Use Performance Advisor checks to improve model simulation time.

See Also

How Performance Advisor Improves Simulation Performance

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

How Performance Advisor Improves Simulation Performance

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

How Performance Advisor Improves Simulation Performance

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

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.

When you enable Inline Parameters optimization,Simulink® uses the numerical values of model parameters instead of their symbolic names. This substitution can improve performance by reducing the parameter tuning computations performed during simulations.

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

Check MATLAB Function block debug settings

After verifying that your MATLAB code works correctly, disable debugging support for MATLAB Function blocks where possible. In the Simulation Target pane of the Configuration Parameters dialog box, disable debugging/animation, overflow detection, and echoing expressions without semicolons.

See Also

How Performance Advisor Improves Simulation Performance

Check Stateflow block debug settings

By default, Stateflow® charts highlight the current active states and transitions as the model runs. This feature is useful for debugging, but it slows the simulation. To accelerate simulations, disable debugging and animation for all Stateflow blocks. Similarly, if you are using Simulink 3D Animation™, SimMechanics™ visualization, FlightGear, or another 3D animation package, consider disabling the animation or reducing scene fidelity to 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 any changes in known dependencies detected.

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 Distributed Computing 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 (the Use circular buffer for state option 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.

If the Delay block is currently using an array buffer, and all of the following conditions are true, Performance Advisor selects a circular buffer:

  • The Delay block is in sample-based mode, i.e,either the 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—equal to the delay length multiplied by the total of all output signal widths—is 1000 or greater.

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

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

Was this topic helpful?