主要内容

Reduce Build Time for Referenced Models by Using Parallel Builds

For 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 Parallel Server™软件,您可以在您的远程工人中分发代码生成和编译MATLABParallel Serverconfiguration.

并行构建参考模型

To build referenced models in parallel:

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

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

  3. For 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- 金宝appSimulinkattempts 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建造按钮。构建过程在诊断查看器中显示构建日志消息。

      如果并行计算工具箱并行偏好自动创建平行池is selected, a parallel pool of MATLAB workers is automatically started. For more information, see指定您的平行首选项(Parallel Computing Toolbox)

      如果构建模型时未运行的MATLAB工人的并行池,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)

      For 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:

  • coder.buildstatus.open('模型')

  • slbuild('模型',...'OpenBuildStatusautomely',true)

  • slbuild('模型','natdalonecodertarget',...'openbuildStatusautomationally',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 theStatus列值。

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

||

相关话题