执行速度
代码生成器通过以下途径尽可能提高生成的代码的执行速度:用局部变量替换全局变量,删除数据副本,使用 memset
和 memcpy
函数,以及减少用于存储数据的内存量。您可以实施特定于编译器和处理器的优化,指定缓冲区重用以及删除可能不需要的代码,以此提高生成的代码的执行速度。
主题
- Optimize Generated Code by Combining Multiple for Constructs
The code generator uses data dependency analysis to combine
for
constructs to reduce static code size and runtime branching. - Configure Loop Unrolling Threshold
Starting at a default value of 5, the code generator begins to use a
for
loop instead of separate statements to assign values to the elements of a signal or parameter array. - Eliminate Dead Code Paths in Generated Code
The code generator eliminates dead (that is, unused) code paths from the generated code.
- Floating-Point Multiplication to Handle a Net Slope Correction
For processors that support efficient multiplication, improve code efficiency by using floating-point multiplication to handle a net slope correction.
- Inline Numeric Values of Block Parameters
Reduce global RAM usage by inlining the literal numeric values of block parameters.
- Optimize Generated Code Using Fixed-Point Data with Simulink, Stateflow, and MATLAB
Generate fixed-point code in Simulink®, Stateflow®, and MATLAB®.
- Generate Target Optimizations Within Algorithm Code
Customize generated algorithm code with target-specific optimizations.
- Use Conditional Input Branch Execution
For Switch and Multiport Switch blocks, Simulink executes only blocks that compute the control input and the data input that the control input selects.
- Optimize Generated Code for Complex Signals
The code generator performs various optimizations on the structures that represent signals in the generated code.
- Speed Up Linear Algebra in Code Generated from a MATLAB Function Block
Generate LAPACK calls for certain linear algebra functions in a MATLAB function block. Specify LAPACK library to use.
- Speed Up Matrix Operations in Code Generated from a MATLAB Function Block
Generate BLAS calls for certain low-level matrix operations. Specify BLAS library to use.
- Speed Up Fast Fourier Transforms in Code Generated from a MATLAB Function Block
Generate FFTW library calls for fast Fourier transforms in a MATLAB Function block. Specify the FFTW library.
- Synchronize Multithreaded FFTW Planning in Code Generated from a MATLAB Function Block
Implement FFT library callback class methods and provide supporting C code to prevent concurrent access to FFTW planning.
- 控制 MATLAB Function 模块中可变大小数组的内存分配
禁用动态内存分配或为 MATLAB Function 模块指定动态内存分配阈值。
- Generate SIMD Code from Simulink Blocks for Intel Platforms
Improve the execution speed of the generated code using Intel® SSE and Intel AVX technology.
- Optimize Code for Reduction Operations by Using SIMD
Generate optimized code for reduction operations using SIMD instruction sets.