Main Content

Priority

Description

Optimize the generated code for increased execution efficiency, decreased RAM consumption, or a balance between execution efficiency and RAM consumption.

Settings

Default:Balance RAM and speed

Balance RAM and speed

Configure code generation settings to balance RAM and execution speed.

Maximize execution speed

Apply code generation settings to maximize execution speed.

Minimize RAM

Configure code generation settings to minimize RAM consumption.

Dependencies

  • Enable this parameter by setting theLevelparameter toMaximum.

  • This parameter requires an Embedded Coder®license.

  • This parameter appears only for ERT-based targets.

提示

For eachPriorityandLevelparameter value, there are corresponding values for the parameters in theDetailssection. These are some important differences among these various settings:

  • If you set theLevelparameter toMinimum (debugging), the parameters in theDetailssection are set to off. The code generator does not implement optimizations that remove variables or code making it easier to debug the generated code.

  • The parameter settings forBalanced with ReadabilityandBalance RAM and speedare the same except for these three parameters:

    • Reuse buffers of different sizes and dimensions

    • Optimize global data access

    • 优化块operation order in the generated code

    The above optimizations can potentially hurt readability because they cross atomic subsystem boundaries and优化块operation order in the generated codemight change the block execution order in the generated code so that it is different than in simulation.

  • If you have limited RAM, choose theMinimize RAMsetting. This setting enables these optimizations that reduce RAM at the expense of a potential slow-down in execution speed:

    • Pack Boolean data into bitfields

    • Reuse buffers of different sizes and dimensions

    • Use bitsets for storing state configuration

    • Use bitsets for storing Boolean data

    This setting also changes the优化块operation order in the generated codefromImproved Code Execution Speedtooff.

For eachPriorityandLevelparameter value, this table lists the corresponding values for the parameters in theDetailssection.

Parameters Settings Example
Level Minimum (debugging) Balanced with readability Maximum
Priority Not Applicable (N/A) N/A Balance RAM and speed Maximize execution speed Minimize RAM
Details
Use memcpy for vector assignment Off On On On On Use memcpy Function to Optimize Generated Code for Vector Assignments
Memcpy threshold (bytes) Off 64 64 64 64 Use memcpy Function to Optimize Generated Code for Vector Assignments
Enable local block outputs Off On On On On Enable and Reuse Local Block Outputs in Generated Code
重用本地块输出 Off On On On On Enable and Reuse Local Block Outputs in Generated Code
Eliminate superfluous local variables (expression folding) Off On On On On Minimize Computations and Storage for Intermediate Results at Block Outputs
Reuse global block outputs Off On On On On Reuse Global Block Outputs in the Generated Code
Perform in-place updates for Assignment and Bus Assignment blocks Off On on On On Data copy reduction for Bus Assignment block
Reuse buffers for Data Store Read and Data Store Write blocks Off On On On On Data Copy Reduction for Data Store Read and Data Store Write Blocks
Simplify array indexing Off Off Off On Off Simplify Multiply Operations in Array Indexing
Pack Boolean data into bitfields Off Off Off Off On Optimize Generated Code by Packing Boolean Data into Bitfields
Reuse buffers of different sizes and dimensions Off Off On Off On Reuse Buffers of Different Sizes and Dimensions
Optimize global data access 没有一个 没有一个 Use global to hold temporary results 没有一个 Use global to hold temporary results Optimize Global Variable Usage
优化块operation order in the generated code Off Off Improved Code Execution Speed Improved Code Execution Speed Off Remove Data Copies by Reordering Block Operations in the Generated Code
Use bitsets for storing state configuration Off Off Off Off On Reduce Memory Usage for Boolean and State Configuration Variables
Use bitsets for storing Boolean data Off Off Off Off On Reduce Memory Usage for Boolean and State Configuration Variables

If you plan on upgrading your software, be aware that:

  • Setting theLevelandPriorityparameters enables the latest optimizations corresponding with the above parameter settings for each subsequent release.

  • Selecting theSpecify custom optimizationsparameter enables you to select individual parameters in theDetailssection. When you load a model in a future release, optimization parameters that were introduced in releases after you adopted the software to when you upgrade are set tooff. If you want to reduce the number of changes in the generated code when you upgrade your software, this option can be a good choice.

Command-Line Information

Parameter:OptimizationPriority
Value:'Balanced'|'Speed'|'RAM'
Default:'Balanced'

Recommended Settings

Application Setting
Debugging No impact
Traceability No impact
Efficiency Minimize RAM(RAM),Maximum execution speed(Speed),Balance RAM and speed(Balanced)
Safety precaution No impact

See Also

|

Related Topics