文档

Performance

减少内存使用量并提高生成代码的执行速度

When developing Simulink®您打算从中生成代码的模型,使用配置选项和优化来提高性能。这些选项减少了RAM和ROM的消耗,并加快了代码执行。如果您想要更多的防御代码,以某种效率为代价,则可以禁用其中一个或多个选项。

You can configure code execution profiling to determine whether the generated code meets the real-time requirements of your target hardware and code sections that require performance improvements. You can also use the Code Generation Advisor to check if a model’s current configuration is optimized for debugging or code execution.

Simulink Configuration Parameters

话题

Code Optimization Basics

提高代码生成速度

Alter a model to increase the speed at which the code generator generates code.

Optimization Tools and Techniques

应用工具,例如模型顾问和技术来优化代码生成的模型。

控制编译器优化

在simulink UI级别上为您的makefile进行控制编译器优化。万博1manbetx

防御性编程

Subnormal Number Performance

最大程度地减少由于亚正态数量计算延迟而导致的执行减速或超支的可能性。

将代码从浮点数转换为包装端外值的整数转换

If the input values in your application are in the range of the output type, remove code for out-of-range floating-point to integer conversions.

Remove Code That Maps NaN to Integer Zero

如果没有输入值的in your application, specify that the code generator remove code that maps到整数零。

禁用非线检查或插入数学功能

使用代码替换库(CRL)自定义条目,以选择性地禁用数学功能和数学函数内部的非精彩检查。

Data Copy Reduction

Minimize Computations and Storage for Intermediate Results at Block Outputs

代码生成器将块计算折叠到单个表达式中,而不是为模型中每个块生成单独的代码语句和存储声明。

在生成的代码中启用并重用本地块输出

在可能的情况下,代码生成器将块输出声明为局部变量,因此它可以重复使用这些变量。

为总线信号生成有效的代码

Model buses to maximize efficiency of the generated code.

Inline Invariant Signals

Use the numerical values of invariant signals instead of their symbolic names in the generated code.

使用memcpy函数来优化矢量分配的生成代码

这code generator optimizes the generated code for vector assignments by replacing为了loops withmemcpyfunction calls.

为总线信号生成有效的代码

Model buses to maximize efficiency of the generated code.

Memory Usage

Vector Operation Optimization

这code generator reduces stack memory by replacing temporary local arrays with local variables.

减少布尔和状态配置变量的内存使用率

Reduce the amount of memory that stores state configuration variables andBoolean变量。

Optimize Generated Code Using memset Function

memset清除内部存储函数,不管泰pe, to the integer bit pattern 0 (that is, all bits are off).

自定义堆栈空间分配

控制最大允许堆栈大小,以提供对数据是在生成代码中本地或全球定义的一定控制权。

配置循环展开阈值

Starting at a default value of 5, the code generator begins to use a为了loop instead of separate statements to assign values to the elements of a signal or parameter array.

为嵌入式应用程序指定单位数据类型

生成其浮点数据类型的代码仅是单个精度,例如,用于针对单精度处理器。

通过为块参数指定数据类型来生成有效的代码

To generate more efficient code, match parameter data types with signal data types or store parameters in smaller data types.

使用布尔数据来优化生成的代码,以获取逻辑信号

这code generator optimizes the generated code by storing logical signals asBoolean数据类型。

优化时间计数器的内存使用率

Optimize memory that the code generator allocates for elapsed time or absolute time.

Optimize Speed and Size of Signal Processing Algorithm by Using Fixed-Point Data

Model a fixed-point acoustic noise canceller.

执行速度

Optimize Generated Code by Combining Multiple for Constructs

代码生成器使用数据依赖性分析来组合为了构造以减少静态代码大小和运行时分支。

配置循环展开阈值

Starting at a default value of 5, the code generator begins to use a为了loop instead of separate statements to assign values to the elements of a signal or parameter array.

消除生成代码中的死亡代码路径

这code generator eliminates dead (that is, unused) code paths from the generated code.

浮点乘法以处理净斜率校正

为了processors that support efficient multiplication, improve code efficiency by using floating-point multiplication to handle a net slope correction.

Remove Code for Blocks That Have No Effect on Computational Results

代码生成器通过删除不影响计算结果的代码来提高执行速度并降低ROM消耗。

Inline Numeric Values of Block Parameters

通过嵌入块参数的文字数值来减少全局RAM使用。

使用Simulink®,StateFlow®和MATLAB®优化生成的代码万博1manbetx

Generate fixed-point code in Simulink, Stateflow®, and MATLAB®

在算法代码中生成目标优化

自定义具有特定于目标的优化的生成算法代码。

Use Conditional Input Branch Execution

为了SwitchandMultiport Switch块,Simuli万博1manbetxnk仅执行计算控件输入和控件输入选择的数据输入的块。

Optimize Generated Code for Complex Signals

代码生成器对代表生成代码中信号的结构进行各种优化。

加快从MATLAB功能块生成的代码中的线性代数

在MATLAB功能块中生成Lapack调用某些线性代数函数。指定要使用的拉帕克库。

加快从MATLAB功能块生成的代码中快速傅立叶变换

Generate FFTW library calls for fast Fourier transforms in aMATLAB Function堵塞。指定FFTW库。

同步从MATLAB功能块生成的代码中的多线程FFTW计划

实现FFT库回调类方法,并提供支持的C代码,以防止同时访问FFTW计划。万博1manbetx

Control Memory Allocation for Variable-Size Arrays in a MATLAB Function Block

Disable dynamic memory allocation or specify a dynamic memory allocation threshold forMATLAB Functionblocks.

代码执行分析

Execution Profiling for Generated Code

Use code execution profiling to observe performance.

Was this topic helpful?