Speicherauslastung
Optimieren der Auslastung von RAM, ROM und Stack-Space durch generierten Code
Steuern Sie die Speicherauslastung, indem Sie festlegen, ob der Codegenerator Variablen lokal oder global definiert und wie Daten an Subsystem-Funktionen übergeben werden. Modifizieren Sie die Konfigurationseinstellungen, um die Speicherauslastung durch Datenspeicherung zu reduzieren.
Der Codegenerator reduziert die ROM-Auslastung durch Kombination von Kontrollstrukturen-Konstrukten und Entfernung toter Codepfade und Code für Blöcke, die keine Auswirkungen auf die Rechenergebnisse haben. Sie können die ROM-Auslastung weiter reduzieren, indem Sie nicht benötigten Code entfernen, wie Initialisierungscode, die Reset- und Disable-Funktionen und defensiven Code.
Modelleinstellungen
Themen
Grundlagen der Optimierung der Speicherauslastung
- Design Techniques to Optimize Models for Efficient Code Generation
Apply design tools and techniques to optimize a model for code generation. - Optimize Generated Code Using Code Efficiency Tools and Techniques
When generating production code from your model to deploy into a real-time embedded system, code efficiency is an important consideration. - Configure Model for Code Generation Objectives by Using Code Generation Advisor
Use the Code Generation Advisor to check your model against code generation objectives. - Generate Efficient Code by Setting Model Configuration Parameters
Choose the efficiency level and priorities for your generated code.
Lokale oder globale Variablendefinition
- Customize Stack Space Allocation
Control the maximum allowable stack size to provide some control over whether data is defined locally or globally in the generated code. - Enable and Reuse Local Block Outputs in Generated Code
Where possible, the code generator declares block outputs as local variables, so that it can potentially reuse these variables. - Reuse Global Block Outputs in the Generated Code
The code generator attempts to reuse global variables. - Optimize Global Variable Usage
Choose a global variable reference optimization to satisfy your memory usage and execution speed requirements. - Optimize Generated Code by Passing Reusable Subsystem Outputs as Individual Arguments
The code generator eliminates data copies from local variables back to global block I/O structures by passing reusable subsystem outputs as individual arguments instead of as a pointer to a structure stored in global memory. - Reduce Global Variables in Nonreusable Subsystem Functions
To reduce global RAM for a nonreusable subsystem, generate a function interface that passes data through arguments instead of global variables. - Reduce Memory Usage for Models Containing Referenced Models
Reduce RAM usage for a referenced model by generating optimized code that reuses buffers or generates reusable temporary buffers to hold referenced model outputs.
Reduzieren des Codevolumens
- Remove Zero-Initialization Code
Control whether to initialize internal data (blocks states and block outputs) and external data (root inports and outports) whose value is zero in the generated code. - Remove Reset and Disable Functions from the Generated Code
Remove unreachable (dead-code) instances of the reset and disable functions from the generated code for ERT-based systems that include model referencing hierarchies. - Inline Numeric Values of Block Parameters
Reduce global RAM usage by inlining the literal numeric values of block parameters. - Optimize Generated Code by Consolidating Redundant If-Else Statements
The code generator optimizes the generated code by combiningif-elsestatements that share the same condition. - Control Generation of Initialization Code for Local Variables Set to Zero
By default, the code generator does not explicitly initialize local variables to zero.
Reduzieren des Speichers zur Datenspeicherung
- Reuse Buffers of Different Sizes and Dimensions
Reuse buffers for matrices that have different sizes and shapes. - Optimize Memory Usage for Time Counters
Optimize memory that the code generator allocates for an elapsed time counter. - Optimize Generated Code Using Boolean Data for Logical Signals
The code generator optimizes the generated code by storing logical signals asBooleandata types. - Optimize Generated Code by Packing Boolean Data into Bitfields
The code generator reduces RAM consumption by packing boolean data into 1-bit bitfields. - Represent Integer and Fixed-Point Data Using Bit Field Storage Class
Optimize memory by representing integer and fixed-point data using bit field storage classes in the Embedded Coder Dictionary. - Specify Single-Precision Data Type for Embedded Application
Generate code whose floating-point data types are only single precision, for example, for targeting a single-precision processor. - Generate Efficient Code by Specifying Data Types for Block Parameters
To generate more efficient code, match parameter data types with signal data types or store parameters in smaller data types. - Control Operator Type in Generated Code
Generate code with Logical or Bitwise Operators or a combination of both operators. - Generate Efficient Code Using Unified Analysis
Reduce RAM usage and data copies performing unified analysis at model-level.