Main Content

About Scalable Compilation

What Is Scalable Compilation?

Large models often take a long time to compile and simulate. Scalable compilation helps reduce compilation time for models that consist of a pattern of repeated components by compiling a repeated component once and then reusing these compilation artifacts for other instances of the same component. Scalable compilation improves compilation performance, it does not reduce the simulation time of the model.

Scalable compilation supports these types of reusable components:

  • Referenced subsystems — Subsystem instances using a subsystem reference, where you save the contents of a subsystem in a separate file and reference it using a Subsystem Reference block. You can create multiple instances referencing the same subsystem file. For more information, see Subsystem Reference.

  • Linked subsystems — Subsystem instances created from Simulink® library Subsystem blocks with link to the source. Note that if you create copies from Subsystem blocks, with LinkStatus set to none, they are not linked subsystems.

  • Individual blocks where simscape.scalable.getBlockConfig returns on. For more information, see Reuse Compilation Artifacts of Individual Simscape Blocks.

  • Textual components with the CompileReuse attribute set to true. For more information, see Reuse Compilation Artifacts of Textual Components.

If you have a slow-to-compile model, determine whether it can benefit from scalable compilation by asking yourself the following questions:

  • Does the model consist of a pattern of repeated components, such as a transmission line or a battery pack? Can you easily turn these components into reusable components, such as referenced subsystems or linked subsystems?

  • How much does the Simscape™ part of the model contribute to total model compilation time? Some models have complicated controllers that take a long time to compile. In such cases, even if scalable compilation can significantly reduce the compilation time of the Simscape part of the model, the impact on the entire model could be less noticeable.

  • Does the model use unsupported patterns, optimizations, or simulation modes? For example, scalable compilation does not support code generation, including rapid accelerator mode, or the Partitioning local solver. For more information, see Scalable Compilation Limitations.

The Advisory tool can provide information about unsupported patterns or workflows in your model, as well as guidance regarding subsystem reusability and compilation statistics. For more information, see Analyze the Model Using the Advisory Tool.

The complexity level of the repeated components has significant impact on the scalable compilation results. You can try different ways of restructuring your model into repeated components to determine the optimal configuration. For more information, see Determining Optimal Complexity Level for Reusable Components.

Scalable Compilation Workflow

The flowchart represents the scalable compilation workflow.

If you have a slow-to-compile model:

  1. Determine whether the model is a suitable candidate for scalable compilation. Does it have a repeated pattern of components consisting of Simscape blocks?

  2. If yes, identify a way to restructure the model into repeated components. Some models do not need restructuring because they already consist of a pattern of repeating subsystems. Other models may need reorganization into repeating subsystems. You do not have to create referenced subsystems or linked subsystems at this point. The Advisory tool lets you analyze your model as if it already contained reusable components.

  3. Analyze the model using the Advisory tool and review the results.

    If the performance improvement from scalable compilation is not satisfactory, consider whether there are other possible ways to restructure the model. The complexity level of the repeated components has significant impact on scalable compilation results. You can try different ways of restructuring your model into repeated components and use the Advisory tool to determine the optimal configuration.

  4. Once you are satisfied with the results, turn the repeated components in your model into reusable components. For example, convert one of the repeated components into a referenced subsystem, and then replace all instances of this component in the model with Subsystem Reference blocks. For more information, see Subsystem Reference.

Related Topics