Speichernutzung
Ermitteln Sie, wie Sie Ihren MATLAB® Programmcode modifizieren sollten, sodass der generierte Code weniger Speicher erfordert. Regeln Sie beim Aufrufen von Funktionen, wie Daten übergeben werden, indem Sie für Eingabe und Ausgabe dieselben Variablen verwenden. Eine Übergabe per Referenz reduziert den Speicherbedarf von generiertem Code. Regeln Sie Zuweisung von Speicher, indem Sie Grenzwerte für die Stack-Space-Nutzung setzen und festlegen, wann eine dynamische Speicherzuweisung verwendet werden soll. Minimieren Sie die Code-Größe, indem Sie Funktionen deaktivieren, die zusätzlichen Code generieren, wie beispielsweise die Unterstützung von Integer-Überschreitung.
Weitere Informationen zur Optimierung Ihres Codes für bestimmte Bedingungen finden Sie unter Optimize Generated C/C++ and MEX Code.
Funktionen
coder.areUnboundedVariableSizedArraysSupported | Check if current configuration settings allow unbounded variable-size arrays (Seit R2024a) |
coder.ceval | Call C/C++ function from generated code |
coder.const | Fold expressions into constants in generated code |
coder.inline | Control inlining of current function in generated code |
coder.inlineCall | Inline called function in generated code (Seit R2024a) |
coder.nonInlineCall | Prevent inlining of called function in generated code (Seit R2024a) |
Klassen
coder.Constant | Specification of constant value for code generation |
coder.ExternalDependency | Interface to external code |
Themen
Optimierung von generiertem Code
- Optimize Generated C/C++ and MEX Code
Optimize the execution speed or memory usage of generated C/C++ and MEX code. - Stack Allocation and Performance
Allocate large variables on the heap when you have limited stack space. - MATLAB Coder Optimizations in Generated Code
To improve the performance of generated code, the code generator uses optimizations.
Bedingte Ausdrücke
- Prevent Code Generation for Unused Execution Paths
Make a control-flow variable constant to prevent code generation of unused branches. - Excluding Unused Paths from Generated Code
Make the control-flow variable constant to prevent generation of code for unused branches.
Funktionsaufrufe
- Avoid Data Copies of Function Inputs in Generated Code
Generate code that uses pass-by-reference for input arguments. - 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. - Control Stack Space Usage
Specify the maximum stack space that the generated code can use.
Arrays
- Set Dynamic Memory Allocation Threshold
Disable dynamic memory allocation for arrays less than a certain size. - Reuse Large Arrays and Structures
Specify variable reuse to reduce memory usage. - Code Generation for Sparse Matrices
Use sparse matrices in MATLAB code intended for code generation.
Numerische Edge Cases
- Disable Support for Integer Overflow or Nonfinites
Improve performance by suppressing generation of supporting code to handle integer overflow or nonfinites.
Benutzerdefinierte Code-Integration
- Integrate External/Custom Code
Improve performance by integrating your own optimized code. - Optimize Generated Code for Fast Fourier Transform Functions
Choose the correct fast Fourier transform implementation for your workflow and target hardware. - Speed Up Linear Algebra in Generated Standalone Code by Using LAPACK Calls
Generate LAPACK calls for certain linear algebra functions. Specify LAPACK library to use. - Speed Up Matrix Operations in Generated Standalone Code by Using BLAS Calls
Generate BLAS calls for certain low-level matrix operations. Specify BLAS library to use. - Speed Up Fast Fourier Transforms in Generated Standalone Code by Using FFTW Library Calls
Generate FFTW library calls for fast Fourier transforms. Specify the FFTW library.