Utilizzo della memoria
Determinare come modificare il codice MATLAB® in modo che il codice generato utilizzi meno memoria. Quando si chiamano le funzioni, si può controllare il modo in cui vengono passati i dati utilizzando le stesse variabili per l'input e l'output. Il passaggio per riferimento riduce la memoria utilizzata nel codice generato. Controllare il modo in cui la memoria viene allocata, impostando limiti per l'uso dello spazio dello stack e specificando quando viene utilizzata l'allocazione dinamica della memoria. Minimizzare la grandezza del codice disabilitando le feature che generano codice supplementare, come il supporto per l'overflow dei numeri interi.
Per ulteriori informazioni su come ottimizzare il codice per condizioni specifiche, vedere Optimize Generated C/C++ and MEX Code.
Funzioni
coder.areUnboundedVariableSizedArraysSupported | Check if current configuration settings allow unbounded variable-size arrays (Da 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 (Da R2024a) |
coder.nonInlineCall | Prevent inlining of called function in generated code (Da R2024a) |
Classi
coder.Constant | Specification of constant value for code generation |
coder.ExternalDependency | Interface to external code |
Argomenti
Ottimizzazioni del codice generato
- 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.
Dichiarazioni condizionali
- 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.
Chiamate della funzione
- 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.
Array
- 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.
Casi limite numerici
- Disable Support for Integer Overflow or Nonfinites
Improve performance by suppressing generation of supporting code to handle integer overflow or nonfinites.
Integrazione del codice personalizzato
- 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.