Uso de memoria
Reduzca la RAM, la ROM y el espacio de pila utilizados por el código generado en C/C++
Determine cómo modificar su código de MATLAB® para que el código generado utilice menos memoria. Al llamar a funciones, controle cómo se pasan los datos utilizando las mismas variables para la entrada y la salida. Pasar por referencia reduce la memoria utilizada en el código generado. Controle cómo se asigna la memoria estableciendo límites para el uso del espacio de pila y especificando cuándo se utiliza la asignación dinámica de memoria. Reduzca el tamaño del código deshabilitando las características que generan código adicional, como la compatibilidad con el desbordamiento de enteros.
Para obtener más información sobre cómo optimizar su código para condiciones específicas, consulte Optimize Generated C/C++ and MEX Code.
Funciones
coder.areUnboundedVariableSizedArraysSupported | Check if current configuration settings allow unbounded variable-size arrays (Desde 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 (Desde R2024a) |
coder.nonInlineCall | Prevent inlining of called function in generated code (Desde R2024a) |
Clases
coder.Constant | Specification of constant value for code generation |
coder.ExternalDependency | Interface to external code |
Temas
Optimizaciones de código generado
- 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.
Instrucciones condicionales
- 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.
Llamadas a función
- 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.
Arreglos
- 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.
Casos extremos numéricos
- Disable Support for Integer Overflow or Nonfinites
Improve performance by suppressing generation of supporting code to handle integer overflow or nonfinites.
Integración de código personalizado
- 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.