Data Copy Reduction
Adjust model parameters to improve code execution speed and reduce memory usage
Reduce RAM and ROM consumption and increase code execution speed by eliminating data copies in the generated code. The code generator eliminates some data copies. You can eliminate other data copies by adjusting certain model parameter settings, specifying the same name for the input and output arguments of MATLAB Function blocks, and by using Simulink signals to specify reuse.
Model Settings
Topics
Data Copy Reduction Basics
- 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.
Data Copy Reduction by Default
- 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. - 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.
Data Copy Reduction by Specification
- Optimize Generated Code by Using Signal Labels to Guide Buffer Reuse
Remove data copies by using signal labels. - Optimize Global Variable Usage
Choose a global variable reference optimization to satisfy your memory usage and execution speed requirements. - Specify Buffer Reuse for MATLAB Function Blocks in a Path
Reuse buffers across MATLAB Function blocks. - Specify Buffer Reuse for Signals in a Path
Use the Reusable storage class to specify buffer reuse for multiple signals in a path. - Generate Efficient Code for Buses
Model buses to maximize efficiency of the generated code. - Control Inlining to Fine-Tune Performance and Readability of Generated Code
Inlining eliminates the overhead of function calls but can produce larger C/C++ code and reduce code readability.