Skip to main content

Mixed-Level Embedding and JIT Compilation for an Iteratively Staged DSL

  • Conference paper
Functional and Constraint Logic Programming (WFLP 2010)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 6559))

Included in the following conference series:

Abstract

This paper explores how to implement an iteratively staged domain-specific language (DSL) by embedding into a functional language. The domain is modelling and simulation of physical systems where models are expressed in terms of non-causal differential-algebraic equations; i.e., sets of constraints solved through numerical simulation. What distinguishes our language is that the equational constraints are first class entities allowing for an evolving model structure characterised by repeated generation of updated constraints. Hence iteratively staged. Our DSL can thus be seen as a combined functional and constraint programming language, albeit a two-level one, with the functional language chiefly serving as a meta language. However, the two levels do interact throughout the simulation. The embedding strategy we pursue is a mixture of deep and shallow, with the deep embedding enabling just-in-time (JIT) compilation of the constraints as they are generated for efficiency, while the shallow embedding is used for the remainder for maximum leverage of the host language. The paper is organised around a specific DSL, but our implementation strategy should be applicable for iteratively staged languages in general. Our DSL itself is further a novel variation of a declarative constraint programming language.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Augustsson, L., Mansell, H., Sittampalam, G.: Paradise: a two-stage DSL embedded in Haskell. In: Proceeding of the 13th ACM SIGPLAN International Conference on Functional Programming (ICFP 2008), pp. 225–228. ACM Press, New York (2008)

    Chapter  Google Scholar 

  2. Broman, D., Fritzson, P.: Higher-order acausal models. In: Fritzson, P., Cellier, F., Broman, D. (eds.) Proceedings of the 2nd International Workshop on Equation-Based Object-Oriented Languages and Tools, Paphos, Cyprus. Linköping Electronic Conference Proceedings, vol. 29, pp. 59–69. Linköping University Electronic Press (2008)

    Google Scholar 

  3. Cellier, F.E.: Object-oriented modelling: Means for dealing with system complexity. In: Proceedings of the 15th Benelux Meeting on Systems and Control, pp. 53–64 (1996)

    Google Scholar 

  4. Elliott, C., Finne, S., de Moor, O.: Compiling embedded languages. In: Taha, W. (ed.) SAIG 2000. LNCS, vol. 1924, pp. 9–27. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  5. Elliott, C., Hudak, P.: Functional reactive animation. In: Proceedings of International Conference on Functional Programming, pp. 163–173 (June 1997)

    Google Scholar 

  6. Giorgidze, G., Nilsson, H.: Embedding a functional hybrid modelling language in Haskell. In: Proceedings of the 20th International Symposium on the Implementation and Application of Functional Languages. University of Hertfordshire, Hatfield (September 2008)

    Google Scholar 

  7. Giorgidze, G., Nilsson, H.: Higher-order non-causal modelling and simulation of structurally dynamic systems. In: Proceedings of the 7th International Modelica Conference, Como, Italy. Linköping Electronic Conference Proceedings, Linköping University Electronic Press (September 2009)

    Google Scholar 

  8. Guillemette, L.-J., Monnier, S.: A type-preserving compiler in Haskell. In: ICFP 2008: Proceeding of the 13th ACM SIGPLAN International Conference on Functional Programming, pp. 75–86. ACM, New York (2008)

    Google Scholar 

  9. Hanus, M., Kuchen, H., Moreno-Navarro, J.J.: Curry: A truly functional logic language. In: Proceedings Workshop on Visions for the Future of Logic Programming, Portland, Oregon, USA, pp. 95–107 (December 1995)

    Google Scholar 

  10. Hindmarsh, A.C., Brown, P.N., Grant, K.E., Lee, S.L., Serban, R., Shumaker, D.E., Woodward, C.S.: Sundials: Suite of nonlinear and differential/algebraic equation solvers. ACM Trans. Math. Softw. 31(3), 363–396 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  11. Hudak, P.: Modular domain specific languages and tools. In: Proceedings of Fifth International Conference on Software Reuse, pp. 134–142 (June 1998)

    Google Scholar 

  12. Lattner, C.: LLVM: An infrastructure for multi-stage optimization. Master’s thesis, Computer Science Dept., University of Illinois at Urbana-Champaign, Urbana, IL (December 2002), http://llvm.org

  13. Lee, S., Chakravarty, M., Grover, V., Keller, G.: GPU kernels as data-parallel array computations in Haskell. In: Workshop on Exploiting Parallelism using GPUs and other Hardware-Assisted Methods (2009)

    Google Scholar 

  14. Mainland, G.: Why it’s nice to be quoted: quasiquoting for Haskell. In: Proceedings of the ACM SIGPLAN Workshop on Haskell Workshop, pp. 73–82. ACM, New York (2007)

    Chapter  Google Scholar 

  15. Mainland, G., Morrisett, G., Welsh, M.: Flask: Staged functional programming for sensor networks. In: Proceedings of the Thirteenth ACM SIGPLAN International Conference on Functional Programming, Victoria, British Columbia, Canada. ACM Press, New York (September 2008)

    Google Scholar 

  16. The Modelica Association. Modelica – A Unified Object-Oriented Language for Physical Systems Modeling: Tutorial version 1.4 (December 2000)

    Google Scholar 

  17. The Modelica Association: Modelica – A Unified Object-Oriented Language for Physical Systems Modeling: Language Specification version 3.0 (September 2007), http://www.modelica.org/documents/ModelicaSpec30.pdf

  18. Nilsson, H., Courtney, A., Peterson, J.: Functional reactive programming, continued. In: Proceedings of the 2002 ACM SIGPLAN Haskell Workshop, Pittsburgh, Pennsylvania, USA, pp. 51–64. ACM Press, New York (October 2002)

    Google Scholar 

  19. Nilsson, H., Giorgidze, G.: Exploiting structural dynamism in Functional Hybrid Modelling for simulation of ideal diodes. In: Proceedings of the 7th EUROSIM Congress on Modelling and Simulation, Prague, Czech Republic. Czech Technical University Publishing House (September 2010)

    Google Scholar 

  20. Nilsson, H., Peterson, J., Hudak, P.: Functional hybrid modeling. In: Dahl, V. (ed.) PADL 2003. LNCS, vol. 2562, pp. 376–390. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  21. Nilsson, H., Peterson, J., Hudak, P.: Functional hybrid modeling from an object-oriented perspective. In: Fritzson, P., Cellier, F., Nytsch-Geusen, C. (eds.) Proceedings of the 1st International Workshop on Equation-Based Object-Oriented Languages and Tools (EOOLT), Berlin, Germany. Linköping Electronic Conference Proceedings, vol. 24, pp. 71–87. Linköping University Electronic Press (2007)

    Google Scholar 

  22. Nytsch-Geusen, C., Ernst, T., Nordwig, A., Schwarz, P., Schneider, P., Vetter, M., Wittwer, C., Nouidui, T., Holm, A., Leopold, J., Schmidt, G., Mattes, A., Doll, U.: MOSILAB: Development of a Modelica based generic simulation tool supporting model structural dynamics. In: Proceedings of the 4th International Modelica Conference, Hamburg, Germany, pp. 527–535 (2005)

    Google Scholar 

  23. Rhiger, M.: A foundation for embedded languages. ACM Trans. Program. Lang. Syst. 25(3), 291–315 (2003)

    Article  Google Scholar 

  24. Taha, W.: A gentle introduction to multi-stage programming. In: Lengauer, C., Batory, D., Blum, A., Vetta, A. (eds.) Domain-Specific Program Generation. LNCS, vol. 3016, pp. 30–50. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  25. Zimmer, D.: Introducing Sol: A general methodology for equation-based modeling of variable-structure systems. In: Proceedings of the 6th International Modelica Conference, Bielefeld, Germany, pp. 47–56 (2008)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2011 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Giorgidze, G., Nilsson, H. (2011). Mixed-Level Embedding and JIT Compilation for an Iteratively Staged DSL. In: Mariño, J. (eds) Functional and Constraint Logic Programming. WFLP 2010. Lecture Notes in Computer Science, vol 6559. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-20775-4_3

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-20775-4_3

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-20774-7

  • Online ISBN: 978-3-642-20775-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics