메모리 사용량
생성된 C/C++ 코드에 사용되는 RAM, ROM, 스택 공간 줄이기
생성 코드가 메모리를 더 적게 사용하도록 MATLAB® 코드를 수정하는 방법을 결정합니다. 함수를 호출할 때 입력값과 출력값에 동일한 변수를 사용하여 데이터가 전달되는 방법을 제어합니다. 참조로 전달하면 생성 코드에 사용되는 메모리가 줄어듭니다. 스택 공간 사용에 대한 제한을 설정하고 동적 메모리 할당이 사용되는 시점을 지정하여 메모리가 할당되는 방법을 제어합니다. 추가 코드(예: 정수 오버플로 지원)를 생성하는 기능을 비활성화하여 코드 크기를 최소화합니다.
특정 조건에 맞게 코드를 최적화하는 방법에 대한 자세한 내용은 Optimize Generated C/C++ and MEX Code 항목을 참조하십시오.
함수
coder.areUnboundedVariableSizedArraysSupported | Check if current configuration settings allow unbounded variable-size arrays (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 (R2024a 이후) |
coder.nonInlineCall | Prevent inlining of called function in generated code (R2024a 이후) |
클래스
coder.Constant | Specification of constant value for code generation |
coder.ExternalDependency | Interface to external 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.
조건문
- 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.
함수 호출
- Avoid Data Copies of Function Inputs in Generated Code
Generate code that passes input arguments by reference. - 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.
배열
- 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.
수치적 경계 조건
- Disable Support for Integer Overflow or Nonfinites
Improve performance by suppressing generation of supporting code to handle integer overflow or nonfinites.
사용자 지정 코드 통합
- 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.