提升编译性能
用于加快大型模型编译的工作流、方法和示例
用于加快大型模型编译的优化方法包括模型编译工件的可扩展编译、增量编译和内存或磁盘缓存。
可扩展编译只需编译一次重复组件,然后会针对相同组件的其他实例重用这些编译工件,因此有助于减少由重复组件(如传输线或电池组)模式组成的模型的编译时间。可扩展编译可提升编译性能,但并不会减少模型的仿真时间。
增量编译会针对后续编译重用可重用组件的编译工件,除非在仿真运行之间修改了组件。增量编译和内存缓存可以提升同一 MATLAB® 会话中重复模型仿真和模块图更新的性能。
要利用可扩展编译和增量编译,您需要指定可重用组件并启用组件重用。内存缓存自动执行。
您可以选择将缓存的编译工件存储在磁盘上,而不是存储在内存缓存中。磁盘缓存在 MATLAB 会话之间持续存在,因此提高了给定会话中首次编译模型的性能。
函数
sscScalableAdvisor | Analyze model for scalable compilation advisability (自 R2021b 起) |
模型设置
| 编译过程中重用组件 | Option to specify whether to enable component reuse for scalable and incremental compilation (自 R2021b 起) |
| 将缓存的编译工件存储在磁盘上 | Option to specify whether to store cached compilation artifacts on disk or in memory (自 R2024b 起) |
| 缓存编译工件 | Option to specify whether to use multithreaded compilation on multicore machine (自 R2023b 起) |
| 启用多线程编译 | Option to disable caching of compilation artifacts (自 R2025a 起) |
主题
组件重用
- Enable Component Reuse During Compilation
Workflows, techniques, and examples of speeding up compilation of large models. - Reuse Compilation Artifacts of Individual Simscape Blocks
Speed up compilation by selectively reusing artifacts of individual blocks for scalable compilation. - Reuse Compilation Artifacts of Textual Components
Speed up compilation of models that use complex textual components.
可扩展编译
- About Scalable Compilation
General workflow and types of models that can benefit from scalable compilation. - Prepare Your Model for Scalable Compilation
This example shows how to evaluate a model and prepare it for scalable compilation. - Determine Optimal Complexity Level for Reusable Components
Guidelines and considerations for determining the optimal model configuration for scalable compilation.
其他优化方法
- Disk Caching of Compilation Artifacts
Speed up compilation and simulation of models between sessions. - Multithreaded Compilation
Speed up compilation of models on multicore machines.