skip to main content
10.1145/3365984.3365990acmotherconferencesArticle/Chapter ViewAbstractPublication PageseooltConference Proceedingsconference-collections
research-article

Towards introducing just-in-time compilation in a Modelica compiler

Published:06 February 2020Publication History

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.

References

  1. 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 ScholarGoogle ScholarCross RefCross Ref
  2. 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 ScholarGoogle Scholar
  3. 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 ScholarGoogle ScholarCross RefCross Ref
  4. 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 ScholarGoogle Scholar
  5. ESI ITI Gmbh. 2016. SimulationX 3.8 Release Notes. https://cdn.simulationx.de/en/pdf/SimulationX3-8whatisnew.pdf Accessed: 2019-08-25.Google ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle Scholar
  8. Peter Fritzson, Adrian Pop, Martin Sjölund, and Adeel Asghar. 2019. MetaModelica - A Symbolic-Numeric Modelica Language and Comparison to Julia, See [18]. Google ScholarGoogle ScholarCross RefCross Ref
  9. 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 ScholarGoogle ScholarCross RefCross Ref
  10. Joe Groff and Chris Lattner. 2015. https://llvm.org/devmtg/2015-10/slides/GroffLattner-SILHighLevelIR.pdf Accessed: 2019-08-24.Google ScholarGoogle Scholar
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. LLVM Foundation. 2019. Clang: a C language family frontend for LLVM. https://clang.llvm.org/ Accessed: 2019-08-25.Google ScholarGoogle Scholar
  14. LLVM Foundation. 2019. Clang Static Analyzer. https://clang-analyzer.llvm.org/ Accessed: 2019-08-25.Google ScholarGoogle Scholar
  15. Niko Matsakis. 2016. https://blog.rust-lang.org/2016/04/19/MIR.html Accessed: 2019-08-24.Google ScholarGoogle Scholar
  16. 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 ScholarGoogle ScholarCross RefCross Ref
  17. 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 ScholarGoogle Scholar
  18. Modelica'2019 2019. Proceedings of the 13th International Modelica Conference. Modelica Association and Linköping University Electronic Press.Google ScholarGoogle Scholar
  19. 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 ScholarGoogle Scholar
  20. 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 ScholarGoogle ScholarCross RefCross Ref
  21. Adrian Pop, Per Östlund, Francesco Casella, Martin Sjölund, and Rüdiger Franke. 2019. A New OpenModelica Compiler High Performance Frontend, See [18]. Google ScholarGoogle ScholarCross RefCross Ref
  22. 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 ScholarGoogle ScholarCross RefCross Ref
  23. 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 ScholarGoogle ScholarCross RefCross Ref
  24. 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 ScholarGoogle ScholarCross RefCross Ref
  25. 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 ScholarGoogle Scholar
  26. 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 ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. Towards introducing just-in-time compilation in a Modelica compiler

              Recommendations

              Comments

              Login options

              Check if you have access through your login credentials or your institution to get full access on this article.

              Sign in
              • Published in

                cover image ACM Other conferences
                EOOLT '19: Proceedings of the 9th International Workshop on Equation-based Object-oriented Modeling Languages and Tools
                November 2019
                78 pages
                ISBN:9781450377133
                DOI:10.1145/3365984

                Copyright © 2019 ACM

                Publication rights licensed to ACM. ACM acknowledges that this contribution was authored or co-authored by an employee, contractor or affiliate of a national government. As such, the Government retains a nonexclusive, royalty-free right to publish or reproduce this article, or to allow others to do so, for Government purposes only.

                Publisher

                Association for Computing Machinery

                New York, NY, United States

                Publication History

                • Published: 6 February 2020

                Permissions

                Request permissions about this article.

                Request Permissions

                Check for updates

                Qualifiers

                • research-article

                Acceptance Rates

                Overall Acceptance Rate10of11submissions,91%

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader