Block reduction

Description

Reduce execution time by collapsing or removing groups of blocks.

Category: Simulation Target

Settings

Default: On

On

Simulink® software searches for and reduces the following block patterns:

  • Redundant type conversions — Unnecessary type conversion blocks, such as an int type conversion block with an input and output of type int.

  • Dead code — Blocks or signals in an unused code path.

  • Fast-to-slow Rate Transition block in a single-tasking system — Rate Transition blocks with an input frequency faster than its output frequency.

Off

Simulink software does not search for block patterns that can be optimized. Simulation and generated code are not optimized.

Tips

  • When you select Block reduction, Simulink software collapses certain groups of blocks into a single, more efficient block, or removes them entirely. This results in faster execution during model simulation and in generated code.

  • Block reduction does not change the appearance of the source model.

  • Tunable parameters do not prevent a block from being reduced by dead code elimination.

  • Once block reduction takes place, Simulink software does not display the sorted order for blocks that have been removed.

  • If you have a Simulink Coder™ license, block reduction is intended to remove only the generated code that represents execution of a block. Other supporting data, such as definitions for sample time and data types might remain in the generated code.

Dead Code Elimination

Any blocks or signals in an unused code path are eliminated from generated code.

  • The following conditions need to be met for a block to be considered part of an unused code path:

    • All signal paths for the block end with a block that does not execute. Examples of blocks that do not execute include Terminator blocks, disabled Assertion blocks, S-Function blocks configured for block reduction, and To Workspace blocks when MAT-file logging is disabled for code generation.

    • No signal paths for the block include global signal storage downstream from the block.

  • Tunable parameters do not prevent a block from being reduced by dead code elimination.

  • Consider the signal paths in the following block diagram.

    If you check Block reduction, Simulink Coder software responds to each signal path as follows:

    For Signal Path...Simulink Coder Software...
    In1 to Out1Generates code because dead code elimination conditions are not met.
    In2 to TerminatorDoes not generate code because dead code elimination conditions are met.
    In3 to ScopeGenerates code if MAT-file logging is enabled and eliminates code if MAT-file logging is disabled.

Command-Line Information

Parameter: BlockReduction
Value: 'on' | 'off'
Default: 'on'

Recommended Settings

ApplicationSetting
DebuggingOff for simulation or during development
No impact for production code generation
TraceabilityOff
EfficiencyOn
Safety precautionOff

Related Topics