Google Search
Login & Blog Feeds
Blogroll
Recent Comments
- Engineering, Control Systems and Statistics | Blog at ControlTheoryPro.com on Observations on Control System Modeling
- spradlig on MATLAB Pricing (Final Part in the Mathworks is behaving like Microsoft series)
- spradlig on MATLAB Pricing (Final Part in the Mathworks is behaving like Microsoft series)
- PointOnePA on MATLAB Pricing (Final Part in the Mathworks is behaving like Microsoft series)
- spradlig on Observations on Control System Modeling
Archives
Categories
23rd November 2008
What finally worked
I have a quad core machine at my desk so I run multiple MATLAB windows. These multiple windows allowed me to test some distributed computing processes. As a result I set up a script for allowing the multiple windows to run. I was using Stateflow in the model which requires a compile before each run. As a result the model had to be run from a temporary directory.
This temporary directory was the first sign that the function, when distributed, is working. The second sign was when the output file is saved.
Long story short, the batch command worked. The batch command works but only with the PathDependencies and FileDependencies properties set. The function is something like this
jj = batch(’monte_sim_loop’, ‘matlabpool’, 0, ‘PathDependencies’, {…}, ‘FileDependencies’, {…});
The matlabpool set to 0 is important. I tried to using a matlabpool of 3 for my initial runs. It tied up 4 nodes but only run 1 instance of the sim. Then I created a loop
for ii = 1:15
jj = batch(…
end
The reason that a matlabpool of 3 tied up 4 nodes was that the matlabpool property is for how many additional nodes you want running. It originally appeared to be an overhead function that was created. A coworker discovered the matlabpool command already assumes 1 node and so anything higher than 0 ties up that many extra PCs for the 1 job task. Since I just want my jobs distributed (not parallel) I set the property to 0. When I ran the loop above, 15 computers were tied up and 15 nodes worth of results were produced.
If you know more, please share
I invite anyone and everyone who knows more about how to use the Parallel Computing Toolbox to share. Use the comments to share. Or if you like I welcome guest bloggers.
Thanks
Previous, related, posting
20th November 2008
Monte Carlo Runs
For work I’ve been asked to run a Monte Carlo analysis. The analysis is one where I vary a large set of parameters in a large Simulink simulation. Any given simulation will take between 40 minutes and a few hours. So obivously generating thousands of runs with a single computer would take months.
In the lead up to this analysis I asked a few questions. First, I found a bank of parallel computing resources at work. I asked them if it was possible and the answer was “Yes” with my take away being that it was doable and easy. It may be doable, it is not easy. Second, I went to Mathworks training (on modeling for aerospace system which had a session on parallel computing) and asked some questions about how to run parallel operations. I also left this session thinking it would be easy.
The online help is worthless
When you are running a model of any complexity there are a lot of parameters to set. If you are building models correctly you will be setting these parameters via variables not hard coding. This means that the simulation workspace must have all those variables.
The Mathworks help with regard to the Parallel Toolbox and Simulink simulations is pretty meager. One of the easiest means of distributing the simulation is through the use of the parfor keyword instead of the for keyword. The meager help suggests that simulation must be run from within a function because parfor requires a static workspace and Simulink creates variables in whatever workspace it runs from. So the help suggests using a dummy function as a wrapper for the sim command.
The help forgets to mention that running a simulation from a function’s workspace is simple - once you find that help but finding that help was a little buried. (If you want to know how look up the simset function and the SrcWorkspace and DstWorkspace properties.) I have run several simulations from within a function’s workspace on a single PC. However, doing so from within a dummy function called from a parfor loop doesn’t work like it does from a single PC. And the error messages are obtuse.
Obtuse Error Messages
I spent days attempting to get the simulations distributed to the various nodes. The error messages provided at this stage were reasonably straight forward. However, once the simulation was distributed to the nodes the error became far less useful. The first couple of times there was no obvious error. After digging through a long log file a cowroker found the errors and helped me fix them. That said, I think they were listed as warnings in the log file not errors.