Build Simulink Real-Time Applications in Parallel

17 visualizzazioni (ultimi 30 giorni)
James
James il 17 Feb 2021
Commentato: James il 30 Dic 2022
I have a large number of simulink real-time applications that I am trying to build to run on a Speedgoat system. I would like to decrease the build time by running the builds in parallel. It takes 30 minutes to build one application and there are 600+ applications so you can see that building them serially is not a good solution. The models are not dependent on eachother and they are not referenced so the standard built in functionality for parallel model reference bulids with slbuild will not work. The models use data from the base workspace (parameters, configuration reference, bus objects, etc.). I have tried to create a parfor loop detailed below where I save the workspace to a mat file and then load it on each worker before I run slbuild, but I receive the following error.
Error using parallelBuild (line 8)
Unable to find configuration: 'Model_CnfgRef' referenced by 'TC225'.
This configuration exists in the base workspace which I am loading on to each worker. Any thoughts on what I am doing wrong?
Code:
parfor i=1:length(buildCandidates)
l = load('workspace.mat');
evalin('base',['slbuild(TC',num2str(buildCandidates(i)),')']);
end
Also tried this:
parfor i=1:length(bulidCandidates)
l = load('workspace.mat');
slbuild(['TC',num2str(buildCandidates(i))]);
end
  2 Commenti
Brian Iwatake
Brian Iwatake il 17 Feb 2021
Sorry, this is a lame answer, but I would contact the Speedgoat people directly. They may have some tips.
James
James il 17 Feb 2021
Thanks for the suggestion. I could reach out to them, but I feel this is really an issue on the MathWorks side because it is building the Simulink Real-Time application. The Speedgoat group generally focuses on the hardware part of the setup.

Accedi per commentare.

Risposte (1)

Raymond Norris
Raymond Norris il 17 Feb 2021
I'm not a Simulink expert, so I'm assuming that loading the workspace (which is the same for all?) will introduce, for example, Model_CnfgRef? If so, try this.
...
parfor i=1:length(bulidCandidates)
build_model(bulidCandidates,i)
end
...
function build_model(bulidCandidates,i)
l = load('workspace.mat');
slbuild(['TC',num2str(bulidCandidates(i))]);
end
  9 Commenti
Jon Lobo
Jon Lobo il 19 Dic 2022
Hi James,
I'm going to reopen this thread if thats ok. I worked on something similar for another customer and have a few tips for how to get this to work.
  • Use projects if you aren't already.
  • I highly recommend using data dictionaries as well because relying on base workspace is difficult to debug in parallel workers.
  • Ultimtaely, the first two bullets are because each worker needs to know everything. It's significantly easier if each worker just needs to open a project.
  • I recommend using parfeval rather than parfor. parfeval will have your workers work on the builds while enabling you to continue to do things in MATLAB desktop.
  • Lastly, having each worker build in the same folder is risky as each worker will need access to some common files during code generation and compilation. I find it better to use Simulink.filegencontrol and have each worker do a build in their own directory so they can work in isolation.
Based on the type of problem and your other posts, I'm assuming this is all part of a Simulink Test and Simulink Real-Time workflow.
From the fields in the post, I thikn you are using R2019b. I have an example for using parallel computing toolbox to build all external test harnesses used in a test suite. The code queries the test suite to identfy the models it needs to build, builds the first one in MATLAB desktop and builds the rest using parfeval. The idea is that once the model required by first test is built, you can start running the tests in Simulink test while the other models build.
Please let me know if this is of interest and I can post the example here. Likewise, if you need this in a new release, please let me know and I can update it.
-Jon
James
James il 30 Dic 2022
Hi Jon,
I appreciate the reply. I would be interested in seeing your example if you have it.
Thanks!
James

Accedi per commentare.

Categorie

Scopri di più su Multicore Processor Targets 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!

Translated by