Have you seen the MATLAB
Channel on YouTube?? I like the way you can express an idea using video, describe
how things work, and then watch it work. That is why I asked my friend Doug to
help me make a video this week. (Thanks Doug! Check out Doug’s MATLAB Video Tutorials.)
The topic today is the Simulink R2009a feature for Parallel
Model Reference builds. Model reference blocks run in normal (interpreted)
mode or accelerated mode. Simulink has to generate SimTargets for the
accelerated reference models during update diagram. In R2009a you can use the
Parallel Computing Toolbox to start a pool of local MATLAB workers and
distribute the generation of the SimTargets across the available cores on your
system. Model Reference parallel build also speeds up Real-Time Workshop code
generation. All you need to distribute your build across all the cores on your
multi-core machine is to start a local pool of MATLAB workers:
>> matlabpool
Starting matlabpool using the 'local' configuration ...
connected to 4 labs.
Watch the video. Try it out. Leave a comment below and
tell me how it worked.
Updated the video player which was broken on IE.
Files used in this video are available from the File Exchange here
Very nice video. I liked how you brought up the window task manager performance consistently to demonstrate the workings of the PCT toolbox. Hope to see more great videos like this.
I tried using this in R2012a with the rtwbuild command, and it didn’t seem to work at all. Task Manager only showed 1 core running (out of 2), and total execution time didn’t change. I have a top level model with 113 reference models that are in normal mode. Here is what I used:
set_param(cs,’EnableParallelModelReferenceBuilds’,'on’);
set_param(cs,’ParallelModelReferenceMATLABWorkerInit’,'Copy Base Workspace’);
The command window indicated that the pool had indeed started by displaying:
Starting matlabpool using the ‘local’ profile … connected to 2 labs.
The Help indicates that I also should have seen output to the command window like:
### Initializing parallel workers for parallel model reference build.
### Parallel worker initialization complete.
### Starting parallel model reference SIM build for ‘bot_model001′
### Starting parallel model reference SIM build for ‘bot_model002′
### Starting parallel model reference SIM build for ‘bot_model003′
### Starting parallel model reference SIM build for ‘bot_model004′
### Finished parallel model reference SIM build for ‘bot_model001′
### Finished parallel model reference SIM build for ‘bot_model002′
……….
but there was no output like this. What am I missing? Does this only work for Sim builds in accelerator mode, and not for RTW builds?
For the curious, Peter was using an Embedded Coder custom target.
When creating your custom target, you need to declare model reference compliance and adapt your template makefile to comply with the build folder used by the parallel workers.
Guy Rouleau and Seth Popinchalk are Application Engineers for MathWorks. They write here about Simulink and other MathWorks tools used in Model-Based Design.
Very nice video. I liked how you brought up the window task manager performance consistently to demonstrate the workings of the PCT toolbox. Hope to see more great videos like this.
Does this toolbox support building Model References across several machines?
i.e. Using a Team’s Matlab/Simulink installed desktops to perform model reference builds, controlled by a single ‘build’ user?
Make sure you turn on “Enable parallel model reference builds” in the Model Referencing Pane of the configuration parameters.
I tried using this in R2012a with the rtwbuild command, and it didn’t seem to work at all. Task Manager only showed 1 core running (out of 2), and total execution time didn’t change. I have a top level model with 113 reference models that are in normal mode. Here is what I used:
set_param(cs,’EnableParallelModelReferenceBuilds’,'on’);
set_param(cs,’ParallelModelReferenceMATLABWorkerInit’,'Copy Base Workspace’);
tic;
matlabpool
rtwbuild([model_root '/ECU']);
rtwbuild_time = toc;
The command window indicated that the pool had indeed started by displaying:
Starting matlabpool using the ‘local’ profile … connected to 2 labs.
The Help indicates that I also should have seen output to the command window like:
### Initializing parallel workers for parallel model reference build.
### Parallel worker initialization complete.
### Starting parallel model reference SIM build for ‘bot_model001′
### Starting parallel model reference SIM build for ‘bot_model002′
### Starting parallel model reference SIM build for ‘bot_model003′
### Starting parallel model reference SIM build for ‘bot_model004′
### Finished parallel model reference SIM build for ‘bot_model001′
### Finished parallel model reference SIM build for ‘bot_model002′
……….
but there was no output like this. What am I missing? Does this only work for Sim builds in accelerator mode, and not for RTW builds?
For the curious, Peter was using an Embedded Coder custom target.
When creating your custom target, you need to declare model reference compliance and adapt your template makefile to comply with the build folder used by the parallel workers.
The procedure is explained here:
http://www.mathworks.com/help/toolbox/rtw/ug/bse3c9v-1.html#bru4now-1
The link:
http://www.mathworks.com/help/toolbox/rtw/ug/bse3c9v-1.html#bru4now-1
is broken…
@Andreas,
I apologize for that. The link changed when R2012b got released. You cna find the relevant information here:
http://www.mathworks.com/help/rtw/ug/supporting-optional-features.html#bru4now-1