Main Content

Model Configuration Parameters: Code Generation Optimization

The Code Generation > Optimization category includes parameters for improving the simulation speed of your models and improving the performance of the generated code. Model configuration parameters to improve the generated code require Simulink® Coder™ or Embedded Coder®.

Optimization ParameterDescriptionReference
Inlined Parameter Behavior Transform numeric block parameters into constant inlined values in the generated code. This optimizes default parameter behavior.Default parameter behavior (Simulink Coder)

Optimization Priority

Control application of optimizations based on priority. This parameter applies code generation settings to maximize execution.Priority (Embedded Coder)

Turn off customize optimizations

Enable the option to choose individual optimization parameters. This parameter disables the parameters in the Details section, preventing you from individually selecting or clearing them.Specify custom optimizations (Embedded Coder)

Inline invariant signals

Transform symbolic names of Invariant signals in generated code. This uses the numerical values of model parameters, instead of their symbolic names, in generated code Inline invariant signals (Simulink Coder)

Removes code from floating-point to integer conversions with saturation that maps NaN to zero

Control generation of protective code that handles floating-point to integer conversion for NaN values. This parameter removes code that handles floating-point to integer conversion results for NaN values. Remove code from floating-point to integer conversions with saturation that maps NaN to zero (Simulink Coder)
Support: absolute time Code generation for model that includes blocks that depend on absolute or elapsed time.Support: absolute time (Embedded Coder)

Support: Complex numbers

Code generation for complex data. The Support: complex numbers parameter specifies whether to generate complex data and operations.Support: complex numbers (Embedded Coder)

Support: non-finite numbers

Code generation for complex data. This causes the support for blocks that depend on absolute time. Support: complex numbers (Embedded Coder)
Application lifespan (days) Duration in days before timer overflow occurs. The parameter specifies how long, in days, an application that depends on elapsed time can execute before timer overflow occurs. Application lifespan (days)

Simulink Optimization

Inlined Parameter Behavior

 Boost performance by changing Configuration Parameters > Code Generation > Optimization > Default parameter behavior to Inlined, optimizing default parameter behavior. For more information, see Default parameter behavior (Simulink Coder).

Optimization Priority

Change Configuration Parameters > Code Generation > Optimization > Optimization levels > Priority to Maximize Execution Speed. This applies code generation settings to maximize execution speed. For more information, see Priority (Embedded Coder).

Turn off customize optimizations

Uncheck the Specify custom optimizations in Configuration Parameters > Code Generation > Optimization > Optimization levels. This disables the parameters in the Details section, so that you cannot individually select or clear these parameters. For more information, see Specify custom optimizations (Embedded Coder).

Inline invariant signals

Select the Inline invariant signals parameter in Configuration Parameters > Code Generation > Optimization > Advanced parameters. This uses the numerical values of model parameters, instead of their symbolic names, in generated code. For more information, see Inline invariant signals (Simulink Coder).

Remove code from floating-point to integer conversions with saturation that maps NaN to zero

Select the Remove code from floating-point to integer conversions with saturation that maps NaN to zero parameter in Configuration Parameters > Code Generation > Optimization > Advanced parameters. The parameter removes code that handles floating-point to integer conversion results for NaN values. For more information, see Remove code from floating-point to integer conversions with saturation that maps NaN to zero (Simulink Coder).

Support: absolute time

Uncheck the Support: absolute time checkbox in Configuration Parameters > Interface > Software environment. This causes the support for blocks that depend on absolute time. For more information, see Support: absolute time (Embedded Coder).

Support: Complex numbers

Uncheck the Support: complex numbers checkbox in Configuration Parameters > Interface > Software environment. This causes the support for blocks that depend on absolute time. For more information, see Support: complex numbers (Embedded Coder).

Support: non-finite numbers

Uncheck the Support: non-finite numbers checkbox in Configuration Parameters > Interface > Software environment. This causes the support for blocks that depend on absolute time. For more information, see Support: complex numbers (Embedded Coder).

Application lifespan (days)

Set the Application lifespan (days) field in Configuration Parameters > Math and Data Types > Advanced parameters. This specifies how long, in days, an application that depends on elapsed time can execute before timer overflow occurs. For more information, see Application lifespan (days).

Identify Model Optimizations

Follow these steps to identify the Simulink model optimizations.

  1. In Code Generation->Code Generation Objectives->Prioritized Objectives, set Set Objectives to Execution Efficiency.

  2. Click Check Model to generate a report. Ensure you make changes to the optimization techniques that do not affect the model's performance and functioning.

See Also

|