1© 2014 The MathWorks, Inc.
Accelerating Simulink Optimization, Code
Generation & Test Automation Through
Parallelization
Ryan Chladny
Application Engineering
May 13th, 2014
2
Design Challenge: Electric Vehicle
3
EV Battery Topology Optimization
Independently minimize 0-60 mph time and maximize range
Combined 0-60 mph & US06 drive cycle: ~ 20min simulation
Genetic algorithm “rules of thumb”: ~70 days to converge
Is this problem feasible?
N_cells
N_strings
4
75 80 85 90 9511
12
13
14
15
16
17
18
19
SOC [%]
0 t
o 6
0 m
ph
Tim
e [
s]
20
25
30
35
40
45
Multi-Objective 0-60mph + US06 Results
Cells: 424, 106s4p
Drive Ratio: 8.01:1
Ba
tte
ry R
atio
[%
]
Cells: 214, 107s2p
Drive Ratio: 6.90:1
Parallelization reduced the simulation time from 70 days to 2 !!!
5
Motivation for Simulink Parallelization
Processor frequencies are flat
Number of cores are increasing
Parallelization is essential
Simulink can be parallelized
– Control tuning, design and optimization
– Code generation
– Test automation
M. Horowitz, F. Labonte, O. Shacham, K. Olukotun, L. Hammond, C. Batten
Extrapolations by C. Moore in:
http://www.lanl.gov/orgs/hpc/salishan/salishan2011/3moore.pdf
6
EV Example: What is needed to solve the problem?
Drive cycle(s)
– Combined 0-60mph + US06
Model
– Operator, control and plant
– Variables, objectives & constraints
Algorithm
– Genetic algorithm & cost functions
Command scripts
– Initialize model & hardware
– Update dependent variables
– Collect, post-process & plot results
7
EV Example: What is needed to parallelize?
Prototype on laptop and remote
desktop
Deploy to ad-hoc cluster
– 16 quad-core workstations
– 80 generations, populations of 64
Serial computation: ~70 days
Parallel computation: ~2 days
8
Parallel Computing Toolbox
MATLAB Distributed Computing Server
9
Parallel Computing Toolbox
MATLAB
Desktop (Client)
Local
Desktop Computer
Workers
Full MATLAB
Enables explicit use of
multi-core processors
Provides high-level tools
and infrastructure for:– creation and monitoring of jobs
– allocating hardware resources
Provides a bridge to
cluster hardware
10
Parallel Computing Toolbox
MATLAB
Desktop (Client)
Local
Desktop Computer
Workers
Full MATLAB
Enables explicit use of
multi-core processors
Provides high-level tools
and infrastructure for:– creation and monitoring of jobs
– allocating hardware resources
Provides a bridge to
cluster hardware
11
Simulink, Blocksets,
and Other Toolboxes
Local
Desktop Computer
MATLAB
……
MATLAB Distributed Computing Server
Cluster
Scheduler
Computer Cluster
…
…
…
…
…
…
… … …
Profile
(Local)Profile
(Cluster)
1. Prototype local parallel
code
2. Access an enabled
cluster
3. Switch local parallel
profile to cluster profile
12
Code Generation
13
M. Goto, “Innovation of automotive software development, Denso Corporation Keynote Address”, International Software Product Line Conference, 2013
http://splc2013.net/SPLC2013-keynote-Goto.pdf
Code Generation & Parallel Computing
14
Code Generation & Parallel Computing Example
Industrial control software
– Reference models > 10
– Stateflow charts > 50
– Block count > 70,000
Intel i7-3520M, 2 (real) cores,
2.9GHz, 16Gb RAM, 5400rpm
Serial build time: 763s
15
Code Generation & Parallel Computing Example
Industrial control software
– Reference models > 10
– Stateflow charts > 50
– Block count > 70,000
Intel i7-3520M, 2 (real) cores,
2.9GHz, 16Gb RAM, 5400rpm
Serial build time: 763s
Parallel build time: 438s
16
Test Automation
17
Test Automation & Parallel Computing Example
Fault tolerant fuel rate controller
Simulink Design Verifier generated test
harness & vectors
Serial execution: 457s
18
Test Automation & Parallel Computing Example
Fault tolerant fuel rate controller
Simulink Design Verifier generated test
harness & vectors
Serial execution: 457s
Minor script adjustments
Parallel execution: 252s, ~2x faster
19
Summary
System and software complexity are increasing
MathWorks parallel solutions enable full processing power of
multicore computers
Simulink can be parallelized for:
– design exploration, calibration & optimization
– code generation
– test automation
Increased throughput is equivalent to opportunity
20© 2014 The MathWorks, Inc.