Parallel Computing with Simulink: Model Reference Builds8

Posted by Seth Popinchalk,

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.

Updated the video player which was broken on IE.
Files used in this video are available from the File Exchange here

Dan replied on : 1 of 8

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.

Jay replied on : 2 of 8

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?

eric replied on : 3 of 8

Make sure you turn on “Enable parallel model reference builds” in the Model Referencing Pane of the configuration parameters.

Peter Murphy replied on : 4 of 8

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?

Jalpa replied on : 8 of 8

In reference to the video 2 about 3:32, you have mentioned that matlab workers load simulink/model references at the first instance and hence the comparison doesn’t yield a whole lot of improvement in elapsed time. But wouldn’t that apply for the case where parallel build is turned off? if we run the case with no workers second time, the elapsed time is fairly low aswell.
Q1. Why have your compared the builds for different instance of runs.
Q2. In my case, I am seeing a worsen situation with 4 workers as compared to no workers, what can I be doing wrong. I have verified all the above possibilities. Also I think I should be comparing the first run as our test requirements ask for model loading each time.

Thanks,
Jalpa

What is 1 + 2?

Preview: hide