How are Extrinsic Functions Handled When Executing Parallel Simulations with parsim() ?
23 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Suppose a Simulink simulation that contains a Matlab Function block that calls another function declared as extrinsic with @doc:coder.extrinsic.
If multiple simulations are executed in parallel with @doc:parsim, a) does each worker get its own instance of the Matlab engine in which the extrinsic function is executed? Or b) do all of the workers share a common Matlab engine and share the extrinsic function? Seems like the latter could be problematic if the extrinsic function contains persistent data.
As best I can tell, @doc:parfor operates in accordance with (a), but I couldn't find anything on point in the doc for @doc:parsim.
2 Commenti
Raymond Norris
il 20 Giu 2025 alle 22:56
@Paul let me see if I have this right.
parpool(nworkers);
in = Simulink.SimulationInput(mdl);
out = parsim(in);
mdl has a MATLAB Function block that calls a function declared as extrinsic, thereby using a MATLAB engine (different than the workers).
Have you tried it and if so, aside from the workers, do you see 1 MATLAB Engine starting or multiple? I'm inclined to think only 1 Engine is started. Another way to test this is if MATLAB tried running two different functions that were both extrinsic (the calls would be serial, as MATLAB is), then only one Engine would be launched.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Simulink Functions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!