> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/rt-lab/model-and-simulation/single-core-and-multi-core-simulation.md).

# Single-Core & Multi-Core Simulation

Simulators are equipped with multi-core CPUs. By default, Simulink models run on a **single core**: during compilation, the model is automatically grouped into **sm\_computation** and executed as a single-core simulation.

To increase performance, partition the Simulink model at the root level into multiple computation subsystems and apply the required **RT-LAB naming conventions.** Each computation subsystem will then run on a separate core, allowing parallel execution and significantly reducing overall computation time.

## Requirements for real-time simulation

The Simulink model must use a fixed-step solver.

{% hint style="danger" %}
It is recommended to uncheck **Block reduction** and **Signal storage reuse** in the Simulink model Configuration Parameters.
{% endhint %}

## Requirements for multi-core simulation

* The simulator must have enough physical cores available (see your **System Description Document**). The maximum usable cores are always one less than the total physical cores. For example, a 4-core simulator can run a multi-core simulation on up to 3 cores.
* Your simulator’s license must include the required number of cores. [Check the value of *RTLAB\_NUM\_CORES* in the license](https://www.opal-rt.com/docs/rt-lab/licensing-reference/simulator-license.md) to confirm.

## Steps for multi-core simulation

{% stepper %}
{% step %}

### Plan the partition

Decide how many subsystems to have and identify logical parts (e.g., *Plant*, *Controller*, etc). Target equal-ish computational load per subsystem where possible.
{% endstep %}

{% step %}

### Create computation subsystems

Create subsystems respecting **RT-LAB naming conventions:**

* **sm\_\<descriptive\_name>:** One subsystem must be named sm\_\<descriptive\_name>. Any subsystem can serve as the sm\_ subsystem; the choice is arbitrary.
* **ss\_\<descriptive\_name>:** All additional computation subsytems must be named ss\_\<descriptive\_name>. Each name must be unique.

Example of multi-core naming: sm\_controller, ss\_plant1, ss\_plant2

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-111711c22315267a7db08df5f8aa742c3db705ba%2Frtlab-execution-multicore.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Insert OpComm blocks (required)

All inputs to top-level subsystems must first go through an **OpComm** block. OpComm blocks communicate signal type and size to RT-LAB and emulate real-time behavior within Simulink.

To insert an OpComm block:

1. Open the **Simulink Library Browser**.
2. Navigate to **RT-LAB**.
3. Drag an **OpComm** block and place it immediately after the subsystem inputs.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-4166cda081015e055f1cbd13561d8790ee4f7588%2Fproject-add-opcomm-block.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Break algebraic dependencies

To maximize parallel execution and prevent algebraic loops or deadlocks, ensure that no two computation nodes are mutually waiting at any step. Achieve this by:

* Partitioning subsystems so that state variable blocks (e.g., Integrator) are placed just before the subsystem outputs.
* Inserting Memory or Delay blocks in models that do not already include state variables. This introduces a small, controlled delay but ensures proper execution.

{% hint style="info" %}
**State variable** is a signal whose value at the current simulation step depends **only on past inputs or past outputs**, not on other signals being computed at the same step.

In other words, it “remembers” a previous value so the system can proceed without waiting for other computations in the current step.
{% endhint %}

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-8dc17cdc7a50a01adc32f12967338426699766b2%2Fbreak-algebraic-dependencies.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Save, build, load and execute the model

1. Save and run the Simulink model to confirm that everything works as expected.
2. In RT-LAB, build, load and execute the model.
   {% endstep %}
   {% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/rt-lab/model-and-simulation/single-core-and-multi-core-simulation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
