ABSTRACT
We are investigating ways of introducing just-in-time compilation in a standard-compliant Modelica compiler, the Open-Modelica compiler (OMC). The main motivations are enabling extensions to support dynamically varying model structure, faster compilation, and faster recompilation of models after changes. We are investigating two approaches.
The first approach is to adapt the low-level OpenModelica intermediate representation (IR) before code generation to be compatible with LLVM. In that way we can avoid generating intermediate C-code and instead generate LLVM IR in memory for just-in-time compilation (JIT).
The second approach is to translate OMC itself written in MetaModelica to Julia, and thereby gain access to the JIT capabilities of LLVM. Another benefit of the second approach is the access to the Julia ecosystem, including a rich set of libraries for numerical computing.
We have done a preliminary investigation of both approaches, with measurements on a selected sample of algorithms, and discovered that compilation-time of generated Julia code is slower compared to generating LLVM IR directly. We conclude that providing a standard-compliant Modelica compiler which supports a dynamically varying model structure is feasible and possible, and we believe that such a compiler can be provided by using Julia or MetaModelica.
- Giovanni Agosta, Emanuele Baldino, Francesco Casella, Stefano Cherubin, Alberto Leva, and Federico Terraneo. 2019. Towards a High-Performance Modelica Compiler. In Proceedings of the 13th International Modelica Conference, Regensburg, Germany, March 4--6, 2019. Linköping University Electronic Press. Google ScholarCross Ref
- Jeff Bezanson, Stefan Karpinski, Viral B Shah, and Alan Edelman. 2012. Julia: A fast dynamic language for technical computing. arXiv preprint arXiv:1209.5145 (2012).Google Scholar
- Hilding Elmqvist, Toivo Henningsson, and Martin Otter. 2017. Innovations for future Modelica. In Proceedings of the 12th International Modelica Conference, Prague, Czech Republic, May 15--17, 2017. Linköping University Electronic Press, 693--702. Google ScholarCross Ref
- Simon Eriksson and Patrik Andersson. 2018. Efficient IR for the OpenModelica Compiler. Master's thesis. Linköping University, Department of Computer and Information Science. http://urn.kb.se/resolve?urn=urn:nbn:se:liu:diva-148321Google Scholar
- ESI ITI Gmbh. 2016. SimulationX 3.8 Release Notes. https://cdn.simulationx.de/en/pdf/SimulationX3-8whatisnew.pdf Accessed: 2019-08-25.Google Scholar
- Claus Fieker, William Hart, Tommy Hofmann, and Fredrik Johansson. 2017. Nemo/Hecke: computer algebra and number theory packages for the Julia programming language. In Proceedings of the 2017 acm on international symposium on symbolic and algebraic computation. ACM, 157--164.Google ScholarDigital Library
- Peter Fritzson and Adrian Pop. 2011. Meta-Programming and Language Modeling with MetaModelica 1.0. Technical Report 9. Linköping University, PELAB - Programming Environment Laboratory. http://urn.kb.se/resolve?urn=urn:nbn:se:liu:diva-66440Google Scholar
- Peter Fritzson, Adrian Pop, Martin Sjölund, and Adeel Asghar. 2019. MetaModelica - A Symbolic-Numeric Modelica Language and Comparison to Julia, See [18]. Google ScholarCross Ref
- Peter Fritzson, Pavol Privitzer, Martin Sjölund, and Adrian Pop. 2009. Towards a Text Generation Template Language for Modelica. In Proceedings of the 7th International Modelica Conference, Francesco Casella (Ed.). Linköping University Electronic Press, 193--207. Google ScholarCross Ref
- Joe Groff and Chris Lattner. 2015. https://llvm.org/devmtg/2015-10/slides/GroffLattner-SILHighLevelIR.pdf Accessed: 2019-08-24.Google Scholar
- Christoph Höger. 2014. Dynamic Structural Analysis for DAEs. In Proceedings of the 2014 Summer Simulation Multiconference (SummerSim '14). Society for Computer Simulation International, San Diego, CA, USA, Article 12, 8 pages. http://dl.acm.org/citation.cfm?id=2685617.2685629Google ScholarDigital Library
- Chris Lattner and Vikram Adve. 2004. LLVM: A compilation framework for lifelong program analysis & transformation. In Proceedings of the international symposium on Code generation and optimization: feedback-directed and runtime optimization. IEEE Computer Society, 75.Google ScholarDigital Library
- LLVM Foundation. 2019. Clang: a C language family frontend for LLVM. https://clang.llvm.org/ Accessed: 2019-08-25.Google Scholar
- LLVM Foundation. 2019. Clang Static Analyzer. https://clang-analyzer.llvm.org/ Accessed: 2019-08-25.Google Scholar
- Niko Matsakis. 2016. https://blog.rust-lang.org/2016/04/19/MIR.html Accessed: 2019-08-24.Google Scholar
- Sven Erik Mattsson, Martin Otter, and Hilding Elmqvist. 2015. Multi-Mode DAE Systems with Varying Index. In Proceedings of the 11th International Modelica Conference, Versailles, France, September 21--23, 2015. Linköping University Electronic Press, Linköpings universitet, 89--98. Google ScholarCross Ref
- Sandi Miller. 2018. Julia language co-creators win James H. Wilkinson Prize for Numerical Software. http://news.mit.edu/2018/julia-language-co-creators-win-james-wilkinson-prize-numerical-software-1226. Accessed: 2019-07-21.Google Scholar
- Modelica'2019 2019. Proceedings of the 13th International Modelica Conference. Modelica Association and Linköping University Electronic Press.Google Scholar
- Adrian Pop. 2008. Integrated Model-Driven Development Environments for Equation-Based Object-Oriented Languages. Doctoral thesis No 1183. Department of Computer and Information Science, Linköping University, Sweden.Google Scholar
- Adrian Pop and Peter Fritzson. 2006. MetaModelica: A Unified Equation-Based Semantical and Mathematical Modeling Language. In 7th Joint Modular Languages Conference, JMLC 2006 Oxford, UK, September 13--15, 2006 Proceedings. Springer Berlin Heidelberg, 211--229. 14 Google ScholarCross Ref
- Adrian Pop, Per Östlund, Francesco Casella, Martin Sjölund, and Rüdiger Franke. 2019. A New OpenModelica Compiler High Performance Frontend, See [18]. Google ScholarCross Ref
- Christopher Rackauckas and Qing Nie. 2017. Differentialequations. jl-a performant and feature-rich ecosystem for solving differential equations in julia. Journal of Open Research Software 5, 1 (2017).Google ScholarCross Ref
- Martin Sjölund. 2015. Tools and Methods for Analysis, Debugging, and Performance Improvement of Equation-Based Models. Doctoral thesis No 1664. Linköping University, Department of Computer and Information Science. Google ScholarCross Ref
- Martin Sjölund, Peter Fritzson, and Adrian Pop. 2014. Bootstrapping a Compiler for an Equation-Based Object-Oriented Language. Modeling, Identification and Control 35, 1 (2014), 1--19. Google ScholarCross Ref
- John Tinnerholm. 2019. An LLVM backend for the Open Modelica Compiler. Master's thesis. Linköping University, Department of Computer and Information Science. http://urn.kb.se/resolve?urn=urn:nbn:se:liu:diva-154291Google Scholar
- Dirk Zimmer. 2010. Equation-based modeling of variable-structure systems. Ph.D. Dissertation. ETH Zurich, Zürich. Diss., Eidgenössische Technische Hochschule ETH Zürich, Nr. 18924, 2010. Google ScholarCross Ref
Index Terms
- Towards introducing just-in-time compilation in a Modelica compiler
Recommendations
Implementation of a Modelica compiler using JastAdd attribute grammars
We have implemented a compiler for key parts of Modelica, an object-oriented language supporting equation-based modeling and simulation of complex physical systems. The compiler is extensible, to support experiments with emerging tools for physical ...
Easy::Jit: compiler assisted library to enable just-in-time compilation in C++ codes
Programming '18: Companion Proceedings of the 2nd International Conference on the Art, Science, and Engineering of ProgrammingCompiled languages like C++ generally don't have access to Just-in-Time facilities, which limits the range of possible optimizations. This paper introduces an hybrid approach that combines classical ahead of time compilation with user-specified dynamic ...
Development of a Modelica Compiler Using JastAdd
This paper describes experiences from implementing key parts of a compiler for Modelica, an object-oriented language supporting declarative modeling and simulation of complex physical systems. Our implementation uses the attribute-grammar based tool ...
Comments