reduce build time for referenced models by using parallel builds -凯发k8网页登录

main content

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® workers. if you also have matlab parallel server™ software, you can distribute the code generation and compilation across remote workers in your matlab parallel server configuration.

build referenced models in parallel

to build referenced models in parallel:

  1. open the configuration parameters dialog box for the top model of the model hierarchy.

  2. select the 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 the drop-down list, select one of these values:

    • none –– simulink® does not initialize workers.

    • copy base workspace –– simulink attempts to copy the base workspace to each matlab worker.

    • load top model –– simulink loads the top model onto each matlab worker.

  4. build your model from the command line or the simulink editor code perspective:

    • command line –– use, for example, slbuild. the build process displays build log messages in the command window.

    • simulink editor code perspective –– click the build button. the build process displays build log messages in the diagnostic viewer.

      if the parallel computing toolbox parallel preference automatically create a parallel pool is selected, a parallel pool of matlab workers is automatically started. for more information, see specify your parallel preferences (parallel computing toolbox).

      if a parallel pool of matlab workers is not running when you build your model, matlab automatically opens a parallel pool of workers by using the default cluster profile. to change the default behaviour of the worker cluster, you can modify properties of the cluster profile. if you have not touched your parallel preferences, the default profile is local. 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 discover clusters and use cluster profiles (parallel computing toolbox).

      for more general information about parallel computing, see (parallel computing toolbox).

monitor parallel building of referenced models

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('model')

  • slbuild('model', ... 'openbuildstatusautomatically',true)

  • slbuild('model','standalonecodertarget', ... 'openbuildstatusautomatically',true)

this example shows how you can monitor the build process for a model hierarchy. in the hierarchy, rtwdemo_parabuild_a_1 references rtwdemo_parabuild_b_1, rtwdemo_parabuild_b_2, and 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 the modeling tab, click on the down arrow to expand the design gallery. under dependencies, click dependency analyzer.

  4. start parallel building of the model hierarchy and open the build status window.

    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 the status column values.

statusdescription

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.

scheduled

in parallel building, the code generator schedules a model build when the build is not blocked by dependencies. the status of the model build is scheduled until a parallel pool worker becomes available.

building

the model is being built on a worker.

completed

when a model is built without errors, the status changes to completed.

error

if the model build fails, the status changes to error.

up to date

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

canceling

when you click the cancel build button, the build process changes the status of incomplete builds to canceling.

canceled

the canceling operation is complete.

the elapsed time 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.

  • increasing the number of workers in the parallel pool.

see also

| |

related topics

    网站地图