Performance
Guidelines for improving generated code performance
Blocks
MATLAB Function | IncludeMATLABcode in models that generate embeddable C code |
Functions
coder.inline |
Control inlining of a specific function in generated code |
coder.unroll |
Unrollfor -loop by making a copy of the loop body for each loop iteration |
coder.const |
Fold expressions into constants in generated code |
Examples and How To
- Unroll for-Loops and parfor-Loops
Control loop unrolling.
- Inline Code
Inlining eliminates the overhead of a function call by replacing the function call with the body of the function.
- Avoid Data Copies of Function Inputs in Generated Code
Generate code that passes input arguments by reference.
- Generate Reusable Code
To reuse functions, save them in files or integrate external functions into generated code.
- Control Run-Time Checks
Improve performance by disabling run-time checks.
Concepts
- LAPACK Calls for Linear Algebra in a MATLAB Function Block
LAPACK function calls improve the simulation speed ofMATLAB Functionblock algorithms that call certain linear algebra functions.
- BLAS Calls for Matrix Operations in a MATLAB Function Block
BLAS function calls improve the simulation speed ofMATLAB Functionblock algorithms that call certain low-level vector and matrix functions.
- FFTW calls for fast Fourier transform functions in a MATLAB Function Block
FFTW function calls improve the simulation speed ofMATLAB Function块调用MATLAB的算法®fast Fourier transform (FFT) functions.