Accelerating Simulink Optimization, Code Generation & Test Automation Through Parallelization Ryan Chladny Application Engineering May 13 th, 2014 2014 The MathWorks, Inc. 1
Design Challenge: Electric Vehicle 2
EV Battery Topology Optimization N_cells N_strings 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? 3
19 18 17 0 to 60 mph Time [s] Battery Ratio [%] Multi-Objective 0-60mph + US06 Results 45 40 16 15 14 Cells: 214, 107s2p Drive Ratio: 6.90:1 35 30 13 12 Cells: 424, 106s4p Drive Ratio: 8.01:1 25 20 11 75 80 85 90 95 SOC [%] Parallelization reduced the simulation time from 70 days to 2!!! 4
Motivation for Simulink Parallelization Processor frequencies are flat Number of cores are increasing Parallelization is essential 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 Simulink can be parallelized Control tuning, design and optimization Code generation Test automation 5
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 6
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 7
Parallel Computing Toolbox MATLAB Distributed Computing Server 8
Parallel Computing Toolbox Desktop Computer Local Workers Enables explicit use of multi-core processors Full MATLAB MATLAB Desktop (Client) Provides high-level tools and infrastructure for: creation and monitoring of jobs allocating hardware resources Provides a bridge to cluster hardware 9
Parallel Computing Toolbox Desktop Computer Local Workers Enables explicit use of multi-core processors Full MATLAB MATLAB Desktop (Client) Provides high-level tools and infrastructure for: creation and monitoring of jobs allocating hardware resources Provides a bridge to cluster hardware 10
MATLAB Distributed Computing Server Desktop Computer Local Computer Cluster Cluster 1. Prototype local parallel code 2. Access an enabled cluster Simulink, Blocksets, and Other Toolboxes MATLAB Profile (Local) Scheduler Profile (Cluster) 3. Switch local parallel profile to cluster profile 11
Code Generation 12
Code Generation & Parallel Computing M. Goto, Innovation of automotive software development, Denso Corporation Keynote Address, International Software Product Line Conference, 2013 http://splc2013.net/splc2013-keynote-goto.pdf 13
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 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 Parallel build time: 438s 15
Test Automation 16
Test Automation & Parallel Computing Example Fault tolerant fuel rate controller Simulink Design Verifier generated test harness & vectors Serial execution: 457s 17
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 18
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 19
2014 The MathWorks, Inc. 20