class x { public int a; class x { float b; public int func (int a,int b); int a; class x { Asa asad float b; public Asda ad int func int a; Asd (int ad a,int cc b); class x { Asa asad float b; Aac sdscfcc c a public Asda ad int func (int a,int Ascccv b); ca int a; Asd ad Asa asad Ascc cac float b; Aac sdscfcc Asda ad } c a int func Asd (int ad a,int Ascccv cc b); ca Asa asad Ascc cac Aac sdscfcc c a Asda ad } Ascccv ca Asd ad Ascc cac Aac sdscfcc } c a Ascccv ca Ascc cac } Research in Model-Based Product Development at PELAB in the MODPROD Center Presentation at MODPROD'2012 PELAB Programming Environment Laboratory Department of Computer and Information Science Linköping University 2012-02-07 Peter Fritzson
Examples of Complex Systems in Engineering Robotics Automotive Aircraft Mobile Phone Systems Business Software Power plants Heavy Vehicles Process industry 2 Peter Fritzson
Vision of Integrated Model-Based Product Development Business Process Control Requirements Capture Model-Driven Design (PIM) Feedback Compilation &Code Gen (PSM) System Simulation Process models Requirements models Product models Platform models Software & Syst Product Unified Modeling: Meta-modeling& Modelica& UML & OWL Vision of unified modeling framework for model-driven product development from platform independent models (PIM) to platform specific models (PSM) 3 Peter Fritzson
Open Source Modelica Consortium Open Source Effort 4 Peter Fritzson
The OpenModelica Open Source Enviroment www.openmodelica.org Advanced Interactive Modelica compiler (OMC) Supports most of the Modelica Language Basic environment for creating models OMShell an interactive command handler OMNotebook a literate programming notebook MDT an advanced textual environment in Eclipse OMEdit graphic Editor OMOptim optimization subsyste ModelicaML UML Profile MetaModelica extension ParModelica extension 5 Peter Fritzson 5
OSMC International Consortium for Open Source Model-based Development Tools, 40 members Feb 2012 Founded Dec 4, 2007 Open-source community services Website and Support Forum Version-controlled source base Bug database Development courses www.openmodelica.org Code Statistics 6 Peter Fritzson Industrial members (22) ABB Corp Research, Sweden Bosch Rexroth AG, Germany Siemens PLM, California, USA Siemens Turbo, Sweden CDAC Centre, Kerala, India Creative Connections, Prague DHI, Aarhus, Denmark Evonik, Dehli, India Equa Simulation AB, Sweden Fraunhofer FIRST, Berlin Frontway AB, Sweden IFP, Paris, France InterCAX, Atlanta, USA ISID Dentsu, Tokyo, Japan MathCore Engineering/ Wolfram, Sweden Maplesoft, Canada TLK Thermo, Germany Sozhou Tongyuan, China VI-grade, Italy VTI, Linköping, Sweden VTT, Finland XRG Simulation, Germany University members (18) Linköping University, Sweden TU Berlin, Institute of UEBB, Germany FH Bielefeld, Bielefeld, Germany TU Braunschweig, Institute of Thermodynamics, Germany TU Dortmund, Proc. Dynamics, Germany Technical University Dresden, Germany Université Laval, modeleau, Canada Georgia Institute of Technology, USA Ghent University, Belgium Griffith University, Australia Hamburg Univ. Technology/TuTech, Institute of Thermo- Fluid, Germany University of Ljubljana, Slovenia University of Maryland, Inst. Systems Engineering, USA University of Maryland, CEEE, USA Politecnico di Milano, Italy Ecoles des Mines, ParisTech, CEP, France Mälardalen University, Sweden Telemark University College, Norway
OpenModelica Connection Editor OMEdit Supports MSL 3.1 Easy to use First released fall Dec 2010 Implemented in C++ Qt library 7 Peter Fritzson
New OpenModelica MDT Debugger (Eclipse-based) Using Japanese Characters 8 Peter Fritzson
OpenModelica Optimization Subsystem OMOptim Parameter optimization Currently using genetic optimization algorithms in OMOptim 0.9. Work on more parameter optimization Work on dynamic optimization using multi-core computers 9 Peter Fritzson
Web Server Based Teaching/Learning Subsystem OMWeb Runs on ordinary web server Teachers provide modeling exercises Students send in solutions Text-based models; soon graphic models. Running of simulations through server Lila EU project 10 Peter Fritzson
Research Modeling-Language Design Model-based Optimization Fault Analysis Bayesian Networks Debugging Modeling Support Environments 11 Peter Fritzson
Important Questions Design of modeling languages for modeling complex (physical) systems (Modelica) including precise semantics, extensibility, etc. How to engineer complex engineering systems of both hardware and software in a consistent and safe manner? Compilation of models for efficient (real-time) execution on multi-core architectures Traceability from requirements to models to implementation 12 Peter Fritzson
Modeling Language and Tool Research How can a modeling language be designed with precise semantics to avoid errors? Can the language be made extensible? Can it model itself (meta-modeling)? How should a user-supportive modeling environment be designed? 13 Peter Fritzson
Approach to Modelica 4 Simplify and generalize language features Partly Library-based definition Define many Modelica language features by modeling the language features in a Core Library This needs core language extensions symbolic recursive data structures (trees, lists) pattern matching for transformations some higher-order language features. Ongoing design work in Modelica Association Advantages improved correctness language modularity and extensibility 14 Peter Fritzson
Language Features and Symbolic Data Structures Needed for Modelica 4 More higher-order functions (function arguments to functions, returning functions, etc.) Subtyping polymorphism Recursive data structures (trees, lists, etc.) Pattern-matching for model transformations Such language features have been designed in the MetaModelica language extension One version implemented in the OpenModelica compiler Bootstrapping Paper in Modelica conference, March 2011 Innovative application, Paper Debugging Symbolic Transformations in Equation Systems, EOOLT, Sept 2011. 15 Peter Fritzson
OpenModelica Compiler Performance Compiled Using Itself Large application for symbolic operations, the OpenModelica compiler, >150 000 lines Very large (and difficult) test model! First object-oriented equation-based language compiler that compiles itself = bootstrapping Flattening small models Task MMC OMC Factor drmodelica, 104 flattening 2.136s 2.049s 0.96x tests mofiles, 548 flattening 12.770s 13.409s 1.05x tests msl 1.5, 60 flattening tests 1.726s 1.578s 0.91x mosfiles, 120 simulation test 110.67s 107.96s 1.03x OMC compiling itself Task MMC OMC Factor Translate sources to C 98.8s 49.7s 0.50x Compile C, gcc O3 233.3s 152.0s 0.65x Executable size 18.7MB 5.43MB 0.29x Compile C, gcc Os 218.9s 102.8s 0.47x Executable size 10.3MB 5.10MB 0.50x Debug version, gcc g O3 1405s 152.5s 0.11x Executable size 125MB 25MB 0.20x 16 Peter Fritzson
Efficient Traceable Model-Based Dynamic Optimization EDOp Research Project Integrated modeling & optimization in OpenModelica Equation oriented tool, generation of efficient parallel code Based on OpenModelica, cooperation with Open-Source Consortium Including model error traceability and localization Efficient solution methods for model-based optimization problems Methods can exploit structure of the problem and their equations Exploit models for parallel computing Utilize equations to analytically compute gradients and hessians, faster search routines Optimized Heavy Industrial Applications Trucks (Scania), Wheel Loaders (Volvo CE) Bearing applications in mechanical systems (e.g. wind power, SKF) Siemens: Gas turbines, Frontway: Process industry 17 Peter Fritzson
Bayesian Network Based Fault and Failure Analysis Cooperation with Scania, Mattias Nyberg Developing a Fault and Failure analysis tool for the engineers, containing the following features: Modelica/UML/SysML-like intuitive GUI design interface with simulation Functionality Generate Failure Mode and Effect Analysis, FMEA table Generate Fault Tree, FTA table Answer to Queries Probability of hazards Root cause of hazards Infer hazards, given the root cause 18 Peter Fritzson
Bayesian Network Based Fault and Failure Analysis Association of Services to the Components Legend 19 Peter Fritzson
Bayesian Network Based Fault and Failure Analysis Illustration of the Work-Flow Modelica Model Model Parser Equation Type Equations System Reference Systems struct Interfacing Evaluate Parsed Model and Generate the Causal Network SMILE & GeNIe Interfacing 20 Peter Fritzson Bayesian Network FMEA FTA
The new MDT Debugger for Large Algorithmic Modelica/MetaModelica algorithmic codes MDT (Modelica Development Tooling) is the integrated development environment. The new debugger is implemented as a debug plugin within MDT. 21 Peter Fritzson 21
Breakpoint Support in the Debugger 22 Peter Fritzson 22
Equation Model Transformation Debugger Complicated to understand source of some errors Trace transformations through the compiler 0 = y + der(x * time * z); z = 1.0; (1) subst: y + der(x * (time * z)) => y + der(x * (time * 1.0)) (2) simplify: y + der(x * (time * 1.0)) => y + der(x * time) (3) expand derivative (symbolic diff): y + der(x * time) => y + (x + der(x) * time) (4) solve: 0.0 = y + (x + der(x) * time) => der(x) = ((-y) - x) / time time <> 0 23 Peter Fritzson
Integrated Hardware-Software Modeling ModelicaML UML Profile for Modelica SysML-Modelica Integration 24 Peter Fritzson
Using ECLIPSE as Integration Platform OpenUP/Basic Capacity Sub- Process Areas UML-Modelica Plug-in OpenModelica MDT ECLIPSE Process Framework (EPF) Composer Specific components Graphical Modeling Framework ECLIPSE Modeling Framework ECLIPSE Rich Client Platform (RCP) Runtime Java runtime C/C++ runtime OpenModelica runtime MetaModelica runtime 25 Peter Fritzson
ModelicaML UML Profile for Modelica 1st Generation (2006-2008) Extension of SysML subset Features: Supports Modelica constructs Modelica generic class modeling Modelica syntax in definitions Equation-based modeling Simulation modeling 26 Peter Fritzson
ModelicaML UML Profile, 2nd Generation SysML/UML to Modelica OMG Standardization (with Wladimir Schamai, 2009 Now) ModelicaML is a UML Profile for SW/HW modeling Applicable to pure UML or to other UML profiles, e.g. SysML Standardized Mapping UML/SysML to Modelica Defines transformation/mapping for executable models Being standardized by OMG ModelicaML Defines graphical concrete syntax (graphical notation for diagram) for representing Modelica constructs integrated with UML Includes graphical formalisms (e.g. State Machines, Activities, Requirements) Which do not exist in Modelica language Which are translated into executable Modelica code Is defined towards generation of executable Modelica code Current implementation based on the Papyrus UML tool + OpenModelica 27 Peter Fritzson
ModelicaML: Graphical Notation Structure Requirements Behavior 28 Peter Fritzson
Example: Representation of System Structure Interconnections Inheritance Components 29 Peter Fritzson
Example: Representation of System Behavior State Machine of the Controller State Machine of the Tank Conditional Algorithm (Activity Diagram) 30 Peter Fritzson
Example: Representation of System Requirements Textual Requirement Formalized Requirement 31 Peter Fritzson
Example: Simulation and Requirements Evaluation Req. 001 is instantiated 2 times (there are 2 tanks in the system) tank-height is 0.6m Req. 001 for the tank2 is violated Req. 001 for the tank1 is not violated 32 Peter Fritzson
vvdr virtual Verification of Design Requirements vvdr Roles and Tasks Requirements Analyst -1. Select requirements to be verified using simulations (or logic tools) -2. Formalize textual requirements System Designer - Support Requirements Analyst in selecting requirements -3. Create system design models to be verified against requirements - Support System Tester in deciding which requirements are to be verified using which test cases - Support System Tester in linking requirement properties to design model properties System Tester - 4. Create test modes including test cases and decide which requirement are to be verified using which test cases -5. Link requirements to design models -6. Simulate and observe requirement violations -7. Analyze simulation results and create a Simulation Summary Report 33 Peter Fritzson
Parallel Execution Compilation to MultiCore 34 Peter Fritzson
Towards High-Level Parallel Modeling and Simulation Simulations are time-consuming Moore s Law : (since 1965) #devices per chip area doubles every 18 months CPU clock rate also doubled every 18 months until 2003, then: heat and power issues, limited ILP,... superscalar technology has reached its limits, only (thread-level) parallelism can increase throughput substantially The consequence: Chip multiprocessors (+ clusters) Multi-core, PIM,... (for general-purpose computing) Need parallel programming/modeling/parallelization Automatic parallelization Explicit parallel modeling and parallel programming Log2 Speedup 16.0 14.0 12.0 10.0 8.0 6.0 4.0 2.0 0.0 Single-processor Performance Scaling Throughput incr. 55%/year Source: Doug Burger, UT Austin 2005 Limit: RISC ILP Limit: Clock rate 1984 1986 1988 1990 1992 1994 1996 1998 2000 2002 2004 2006 2008 2010 2012 2014 2016 2018 2020 90 nm Device speed Pipelining RISC/CISC CPI 2006 Parallelism Assumed increase 17%/year possible 65 nm 45 nm 32nm 22nm 35 Peter Fritzson
Integrating Parallelism and Mathematical Models Three Approaches Automatic Parallelization of Mathematical Models (ModPar) Parallelism over the numeric solver method. Parallelism over time. Parallelism over the model equation system... with fine-grained task scheduling Coarse-Grained Explicit Parallelization Using Components The programmer partitions the application into computational components using strongly-typed communication interfaces. Co-Simulation, Transmission-Line Modeling (TLM) Explicit Parallel Programming Providing general, easy-to-use explicit parallel programming constructs within the algorithmic part of the modeling language. NestStepModelica 36 Peter Fritzson
Modelica Simulations Parallelization Approach Simulation = solution of (hybrid) DAEs from models g( X, X, Y, t) 0 h( X, Y, t) 0 In each step of numerical solver: Calculate in g (and Y in h) X Parallelization approach: perform the calculation of in parallel Called parallelization over the system. X Drawback: Numeric solver might become bottle-neck 37 Peter Fritzson
Example Task Graphs and Parallelized Application 2 1 0 0 4 1 1 5 2 0 5 2 3 2 0 6 2 Speedup 3 2.5 2 1.5 1 0 7 10 8 0 1 1 0.5 1 2 4 8 16 # Proc Clustered Task Graph Thermofluid Pipe Application 38 Peter Fritzson
ParModelica Modelica Parallel Algorithmic Programming Here: parglobal and parlocal Variables; Execution on GPUs Modelica + OpenCL = ParModelica function parvar Integer m = 1024; Integer A[m]; Integer B[m]; parglobal Integer pm; parglobal Integer pn; parglobal Integer pa[m]; parglobal Integer pb[m]; parlocal Integer ps; parlocal Integer pss[10]; algorithm B := A; pa := A; B := pa; pb := pa; pm := m; n := pm; pn := pm; end parvar; //copy to device //copy from device //copy device to device Memory Regions Global Memory Constant Memory Local Memory Accessible by All work-items in all workgroups All work-items in all workgroups All work-items in a workgroup 39 Peter Fritzson 39 Private Memory Priavte to a work-item 2012-
ParModelica Matrix Multiplication using Kernel function Gained speedup Intel Xeon E5520 CPU (16 cores) 26 NVIDIA Fermi-Tesla M2050 GPU (448 cores) 115 Speedup comparison to sequential algorithm on Intel Xeon E5520 CPU 4,36 13,41 0,61 4,61 Speedup CPU E5520 GPU M2050 35,95 24,76 26,34 64 128 256 512 Parameter M (Matrix sizes MxM) 114,67 512 256 128 64 32 16 8 4 2 1 0,5 0,25 0,125 0,0625 32 64 128 256 512 CPU E5520 (Serial) 0,093 0,741 5,875 58,426 465,234 Simulation Time (second) CPU E5520 (Parallel) 0,137 0,17 0,438 2,36 17,66 GPU M2050 (Parallel) 1,215 1,217 1,274 1,625 4,057 40 Peter Fritzson 40 2012-
New Scalable OpenModelica Parallel Code Generator Ongoing work Both task parallelism and data parallelism Handling non-expanded arrays efficiently Includes use of TLM-partitioning for more parallelism OPENMP based parallelization prototype for equationbased models in OpenModelica ParModelica - Generating OpenCL code for platform independence Template based code generator 41 Peter Fritzson
Summary of MODPROD Research at PELAB Modeling language design (semantics, type systems, meta-modeling, extensibility) Model-based efficient optimization (multi-core) Fault estimation & traceability; Bayesian networks Modelica-UMLSysML integration Requirements traceability Debugging of models Compilation to multi-core platforms Compilation and performance measurements for real-time simulation 42 Peter Fritzson