When do I need to call "Simulink.​BlockDiagr​am.buildRa​pidAcceler​atorTarget​" when using "parsim" or "batchsim"?

17 visualizaciones (últimos 30 días)
I see that in the following example "Simulink.BlockDiagram.buildRapidAcceleratorTarget" is called inside the "SetupFcn" callback, however I am confused on when this needs to be called in my own code.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 4 de Feb. de 2025
Editada: MathWorks Support Team el 4 de Feb. de 2025

What is "Simulink.BlockDiagram.buildRapidAcceleratorTarget"?

"Simulink.BlockDiagram.buildRapidAcceleratorTarget" generates or regenerates the rapid accelerator executable for the model. For more details on what a rapid accelerator executable is, see How Acceleration Modes Work. In most situations, you do not need to call "Simulink.BlockDiagram.buildRapidAcceleratorTarget" manually.  It depends on the setting "RapidAcceleratorUpToDateCheck" which controls whether Simulink skips the "Up-To-Date" check on the Rapid Accelerator executable and will not rebuild the Rapid Accelerator executable. This can improve performance but can lead to errors or incorrect results if a rebuild is required but is skipped due to this option.

When to call "Simulink.BlockDiagram.buildRapidAcceleratorTarget"

In R2025a and later: Consider using the "UseFastRestart"="on" parameter of parsim/batchsim with Rapid Accelerator, instead of "RapidAcceleratorUpToDateCheck"="off". It provides similar performance benefit to  "RapidAcceleratorUpToDateCheck"="off", with increased diagnostics. It will automatically handle Rapid Accelerator target building so there is no need to call "Simulink.BlockDiagram.buildRapidAcceleratorTarget" on client or workers. 
In R2024b or earlier, "RapidAcceleratorUpToDateCheck" is set to "on" (default):
you do not need to make sure the Rapid Accelerator target is built beforehand, Simulink will automatically rebuild the model if needed. 
In R2024b or earlier, "RapidAcceleratorUpToDateCheck" is set to "off":
, we need to make sure the rapid accelerator target is built and accessible to the workers before running the simulations. This means:
  • For local pools and remote clusters that are the same platform as the client: The Rapid Accelerator target needs to be built on the client before running a "parsim"/"batchsim" simulation with "RapidAcceleratorUpToDateCheck" set to "off". This can mean the model was previously simulated serially in Rapid Accelerator mode or "buildRapidAcceleratorTarget" was called before the call to "parsim"/"batchsim" (this could even be in a prior MATLAB session, just make sure to rebuild when any structural changes are made). The Rapid Accelerator target that exists in the slprj folders will then be automatically transferred to the workers.  "Simulink.BlockDiagram.buildRapidAcceleratorTarget" does not have to be called in the SetupFcn of "parsim"/"batchsim" as long as the model was built prior to the call to "parsim"/"batchsim".
  • For remote clusters that are a different platform than the client (ex: client is windows, cluster is linux): We MUST call "buildRapidAcceleratorTarget" in the SetupFcn of parsim. This is because the Rapid Accelerator target on the client is a binary file that cannot run on different architectures. Thus it must be rebuilt on the cluster. To do this use a SetupFcn like below.
out = parsim(in, 'SetupFcn', @() mySetupFcn(mdl));
function mySetupFcn(mdl)
    Simulink.BlockDiagram.buildRapidAcceleratorTarget(mdl);
end

Más respuestas (0)

Categorías

Más información sobre Run Multiple Simulations en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by