Utilisation de la mémoire
Déterminez comment modifier votre code MATLAB® pour que le code généré utilise moins de mémoire. Lors de l’appel de fonctions, contrôlez la façon dont les données sont transmises en utilisant les mêmes variables en entrée et en sortie. Le passage par référence réduit la mémoire utilisée par le code généré. Contrôlez la façon d’allouer la mémoire en définissant des limites d’utilisation de l’espace de la stack et en spécifiant quand utiliser l’allocation dynamique. Minimisez la taille du code en désactivant les fonctionnalités qui génèrent du code supplémentaire, telles que le support du dépassement d’entier.
Pour plus d’informations sur l’optimisation du code pour des conditions particulières, consultez Optimize Generated C/C++ and MEX Code.
Fonctions
coder.areUnboundedVariableSizedArraysSupported | Check if current configuration settings allow unbounded variable-size arrays (depuis R2024a) |
coder.ceval | Appeler une fonction C/C++ à partir du code généré |
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 (depuis R2024a) |
coder.nonInlineCall | Prevent inlining of called function in generated code (depuis R2024a) |
Classes
coder.Constant | Specification of constant value for code generation |
coder.ExternalDependency | Interface to external code |
Rubriques
Optimisation du code généré
- 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.
Instructions conditionnelles
- 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.
Appels de fonctions
- 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.
Tableaux
- 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.
Cas numériques extrêmes
- Disable Support for Integer Overflow or Nonfinites
Improve performance by suppressing generation of supporting code to handle integer overflow or nonfinites.
Intégration de code personnalisé
- 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.