主要内容

Reduce Build Time for Referenced Models by Using Parallel Builds

为models that contain large model reference hierarchies, you can reduce code generation and compilation time by building the referenced models in parallel. With Parallel Computing Toolbox™ software, you can distribute the code generation and compilation for referenced models across a parallel pool of MATLAB®工作人员。如果你还有MATLAB并行服务器™软件,您可以在遥控器中分发代码生成和编译MATLAB Parallel Serverconfiguration.

并行构建引用的模型

To build referenced models in parallel:

  1. 打开模型层次结构顶部模型的配置参数对话框。

  2. 选择启用并行模型引用构建check box.

  3. 为each MATLAB worker, you can set up a MATLAB environment that is consistent with the MATLAB environment of the client. From theMATLAB工人初始化构建drop-down list, select one of these values:

    • 没有- 金宝appSimulink.®不初始化工人。

    • Copy base workspace- 金宝appSimulink.attempts to copy the base workspace to each MATLAB worker.

    • Load top model- 金宝appSimulink将顶部模型加载到每个Matlab工作者上。

  4. 建造your model from the command line or the Simulink Editor Code perspective:

    • Command line –– Use, for example,slbuild。构建过程显示命令窗口中的构建日志消息。

    • Simulink Editor Code perspective –– Click the建造按钮。构建过程显示诊断查看器中的构建日志消息。

      如果并行计算工具箱并行偏好Automatically create a parallel poolis selected, a parallel pool of MATLAB workers is automatically started. For more information, see指定您的并行偏好(Parallel Computing Toolbox)

      如果在构建模型时不运行Patlab Worker的并行池,则Matlab使用默认群集配置文件自动打开并行工人池。要更改工作群集的默认行为,可以修改群集配置文件的属性。如果您尚未触摸并行首选项,则默认配置文件是当地的。Control parallel behavior with the parallel preferences, including scaling up to a cluster, automatic pool creation, and preferred number of workers. For more information, see发现群集并使用群集配置文件(Parallel Computing Toolbox)

      为more general information about parallel computing, see使用自动并行支持运行MATLAB功能金宝app(Parallel Computing Toolbox)

监控引用模型的并行建筑

Through the Build Status window, you can:

  • View the overall build progress for a model hierarchy.

  • View the build status of individual models in the model hierarchy.

  • Cancel the parallel build process.

Note

The Build Status window supports only parallel building of model hierarchies. Do not use the Build Status window for serial builds.

To open the Build Status window, use one of these line commands:

  • 编码器.BuildStatus.Open('model')

  • slbuild('model',...'OpenBuildStatusautomical',True)

  • slbuild('model','standalonecodertargargar',...'OpenBuildStatusautomication',True)

This example shows how you can monitor the build process for a model hierarchy. In the hierarchy,rtwdemo_parabuild_a_1参考文献rtwdemo_parabuild_b_1,rtwdemo_parabuild_b_2, 和rtwdemo_parabuild_b_3

  1. Copy the model files to a local folder.

    src_dir = ... fullfile(matlabroot,'toolbox','rtw','rtwdemos'); if exist(fullfile('.','myTempFolder'),'dir') rmdir('myTempFolder','s') end mkdir myTempFolder copyfile(fullfile(src_dir,'rtwdemo_parabuild_a_1.slx'), ... 'myTempFolder'); copyfile(fullfile(src_dir,'rtwdemo_parabuild_b_1.slx'), ... 'myTempFolder'); copyfile(fullfile(src_dir,'rtwdemo_parabuild_b_2.slx'), ... 'myTempFolder'); copyfile(fullfile(src_dir,'rtwdemo_parabuild_b_3.slx'), ... 'myTempFolder'); cd myTempFolder

  2. Open the top model.

    Open_System('rtwdemo_parabuild_a_1')

  3. View the model dependencies with the Dependency Analyzer.

    On theModelingtab, click on the down arrow to expand the设计画廊。在下面Dependencies, 点击Dependency Analyzer

  4. 启动模型层次结构的并行构建并打开“构建状态”窗口。

    slbuild('rtwdemo_parabuild_a_1','OpenBuildStatusAutomatically',true)

    The Build Status window displays the overall build progress and the build status for models as the code generator works through the model hierarchy.

This table explains theStatuscolumn values.

Status 描述

Blocked

The code generator cannot schedule the model build because the build is blocked by dependencies. For example, a child model build is not complete.

预定

在并行构建中,代码生成器在构建不被依赖项阻止时调度模型构建。模型构建的状态是预定直到平行池工人可用。

建造ing

该模型正在建立在工人身上。

完全的

在没有错误的情况下建立模型时,状态更改为完全的

错误

如果模型构建失败,则状态更改为错误

Up To Date

Code generation is not required for the model because the current generated code is up to date.

Canceling

当你点击时Cancel Buildbutton, the build process changes the status of incomplete builds toCanceling

Canceled

取消操作完成。

The经过时间column shows the build times for models in the hierarchy. To reduce the total build time, analyse the build times for referenced models together with model dependency information. Then, consider, for example:

  • Restructuring the referenced model hierarchy.

  • 增加并行池中的工人数量。

See Also

||

相关话题