Guy on Simulink

Simulink & Model-Based Design

Parallel Computing with Simulink: Model Reference Builds 6

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.

6 CommentsOldest to Newest

Dan replied on : 1 of 6
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 6
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 6
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 6
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?
Guy Rouleau replied on : 5 of 6
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.
Jalpa replied on : 6 of 6
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