skip to main content
10.1145/1863543.1863587acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Scrapping your inefficient engine: using partial evaluation to improve domain-specific language implementation

Published:27 September 2010Publication History

ABSTRACT

Partial evaluation aims to improve the efficiency of a program by specialising it with respect to some known inputs. In this paper, we show that partial evaluation can be an effective and, unusually, easy to use technique for the efficient implementation of embedded domain-specific languages. We achieve this by exploiting dependent types and by following some simple rules in the definition of the interpreter for the domain-specific language. We present experimental evidence that partial evaluation of programs in domain-specific languages can yield efficient residual programs whose performance is competitive with their Java and C equivalents and which are also, through the use of dependent types, verifiably resource-safe. Using our technique, it follows that a verifiably correct and resource-safe program can also be an efficient program

Skip Supplemental Material Section

Supplemental Material

icfp-weds-1400-brady.mov

mov

110 MB

References

  1. }}P. H. Andersen and C. K. Holst. Termination analysis for offline partial evaluation of a higher order functional language. In Proc. SAS ’96: Intl. Symp. on Static Analysis, pages 67--82. Springer, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. }}L. Augustsson and M. Carlsson. An exercise in dependent types: A well-typed interpreter. In Workshop on Dependent Types in Programming, Gothenburg, 1999. Available from http://www.cs.chalmers.se/ augustss/cayenne/interp.ps.Google ScholarGoogle Scholar
  3. }}L. Augustsson, H. Mansell, and G. Sittampalam. Paradise: a two-stage DSL embedded in Haskell. In Proc. ICFP 2008: International Conf. on Functional Programming, pages 225--228. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. }}S. Bhatti, E. Brady, K. Hammond, and J. McKinna. Domain specific languages (DSLs) for network protocols. In International Workshop on Next Generation Network Architecture (NGNA 2009), 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. }}H.-J. Boehm, A. J. Demers, Xerox Corporation Silicon Graphic, and Hewlett-Packard Company. A garbage collector for C and CGoogle ScholarGoogle Scholar
  6. }}. http://www.hpl.hp.com/personal/Hans_Boehm/gc/, 2001.Google ScholarGoogle Scholar
  7. }}E. Brady. Practical Implementation of a Dependently Typed Functional Programming Language. PhD thesis, University of Durham, 2005.Google ScholarGoogle Scholar
  8. }}E. Brady. Ivor, a proof engine. In Implementation and Application of Functional Languages 2006, volume 4449 of LNCS, pages 145--162. Springer, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. }}E. Brady and K. Hammond. A verified staged interpreter is a verified compiler. In Proc. GPCE ’06: Conf. on Generative Programming and Component Engineering, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. }}E. Brady, C. McBride, and J. McKinna. Inductive families need not store their indices. In S. Berardi, M. Coppo, and F. Damiani, editors, Types for Proofs and Programs 2003, volume 3085, pages 115--129. Springer, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  11. }}J. Carette, O. Kiselyov, and C.-c. Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. J. Funct. Program., 19(5):509--543, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. }}T. Coquand. An algorithm for type-checking dependent types. Science of Computer Programming, 26(1--3):167--177, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. }}S. Debois. Imperative program optimization by partial evaluation. In Proc. PEPM ’04: ACM Symp. on Partial Evaluation and Semantics-Based Program Manipulation, pages 113--122. ACM, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. }}B. Delaware and W. R. Cook. Generic operations and partial evaluation using models, 2009. Draft.Google ScholarGoogle Scholar
  15. }}C. Elliott, S. Finne, and O. De Moor. Compiling embedded languages. J. Funct. Program., 13(3):455--481, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. }}S. Fogarty, E. Pasalic, J. Siek, and W. Taha. Concoqtion: indexed types now! In Proc. PEPM ’07: ACM Symp. on Partial Evaluation and Semantics-Based Program Manipulation, pages 112--121, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. }}Y. Futamura. Partial evaluation of computation process --- an approach to a compiler-compiler. Systems, Comps., Controls, 2(5):45---50, 1971.Google ScholarGoogle Scholar
  18. }}A. Gill. Cheap deforestation for non-strict functional languages. PhD thesis, University of Glasgow, January 1996.Google ScholarGoogle Scholar
  19. }}P. Hancock and A. Setzer. Interactive programs in dependent type theory. In P. Clote and H. Schwichtenberg, editors, Proc. CSL 2000: 14th Ann.\ Conf.\ of EACSL, Fischbau, Germany, 21--26 Aug 2000, LNCS 1862, pages 317--331. 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. }}P. Hudak. Building domain-specific embedded languages. ACM Computing Surveys, 28A(4), December 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. }}N. Jones, C. Gomard, and P. Sestoft. Partial Evaluation and Automatic Program Generation. Prentice Hall International, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. }}N. D. Jones. Challenging problems in partial evaluation and mixed computation. New Gen. Comput., 6(2--3):291--302, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. }}O. Kiselyov and C.-c. Shan. Lightweight monadic regions. In Proc. Haskell ’08: ACM SIGPLAN Symp. on Haskell, pages 1--12, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. }}C. Lattner. LLVM: An infrastructure for multi-stage optimization. Master’s thesis, Computer Science Dept., University of Illinois at Urbana-Champaign, December 2002.Google ScholarGoogle Scholar
  25. }}S. Lee, M. M. T. Chakravarty, V. Grover, and G. Keller. GPU kernels as data-parallel array computations in Haskell. In Workshop on Exploiting Parallelism using GPUs and other Hardware-Assisted Methods (EPAHM 2009), 2009.Google ScholarGoogle Scholar
  26. }}A. Löh, C. McBride, and W. Swierstra. A tutorial implementation of a dependently typed lambda calculus, 2010. To appear in Fundam. Inf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. }}C. McBride and J. McKinna. The view from the left. Journal of Functional Programming, 14(1):69--111, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. }}N. Mitchell. Transformation and Analysis of Functional Programs. PhD thesis, University of York, June 2008.Google ScholarGoogle Scholar
  29. }}N. Mitchell and C. Runciman. A supercompiler for core Haskell. In Implementation and Application of Functional Languages 2007, volume 5083 of LNCS, pages 147--164. Springer, May 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. }}U. Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Department of Computer Science and Engineering, Chalmers University of Technology, SE-412 96 Göteborg, Sweden, September 2007.Google ScholarGoogle Scholar
  31. }}W. Partain. The nofib benchmark suite of Haskell programs. In J. Launchbury and P. Sansom, editors, Functional Programming, Workshops in Computing, pages 195--202. Springer, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. }}E. Pa\vsalíc, W. Taha, and T. Sheard. Tagless staged interpreters for typed languages. In Proc. 2002 International Conf. on Functional Programming (ICFP 2002). ACM, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. }}S. Peyton Jones and S. Marlow. Secrets of the Glasgow Haskell Compiler inliner. Journal of Functional Programming, 12(4):393--434, September 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. }}T. Schrijvers, S. Peyton Jones, M. Chakravarty, and M. Sulzmann. Type checking with open type functions. In International Conf. on Functional Programming (ICFP 2008), pages 51--62, New York, NY, USA, 2008. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. }}S. Seefried, M. Chakravarty, and G. Keller. Optimising embedded DSLs using Template Haskell. In Proc. GPCE ’04: Conf. Generative Prog. and Component Eng., LNCS. Springer, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  36. }}T. Sheard and S. Peyton Jones. Template metaprogramming for Haskell. In ACM Haskell Workshop, pages 1--16, Oct. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. }}K. Swadi, W. Taha, O. Kiselyov, and E. Pasalic. A monadic approach for avoiding code duplication when staging memoized functions. In Proc. PEPM ’06: ACM Symp. on Partial Evaluation and Semantics-based Program Manipulation, pages 160--169, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. }}W. Taha. Multi-stage Programming: Its Theory and Applications. PhD thesis, Oregon Graduate Inst. of Science and Technology, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. }}W. Taha. A Gentle Introduction to Multi-stage Programming, 2003. Available from http://www.cs.rice.edu/ taha.Google ScholarGoogle Scholar
  40. }}W. Taha and H. Makholm. Tag elimination -- or -- type specialisation is a type indexed effect. In Subtyping and Dependent Types in Programming, APPSEM Workshop, 2000.Google ScholarGoogle Scholar
  41. }}W. Taha, H. Makholm, and J. Hughes. Tag elimination and jones-optimality. In PADO ’01: Proceedings of the Second Symposium on Programs as Data Objects, pages 257--275, London, UK, 2001. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. }}D. Terei. Low level virtual machine for Glasgow Haskell Compiler. Bachelor’s Thesis, Computer Science and Engineering Dept., The University of New South Wales, Sydney, Australia, 2009.Google ScholarGoogle Scholar
  43. }}A. van Deursen, P. Klint, and J. Visser. Domain-specific languages -- an annotated bibliography. http://homepages.cwi.nl/ arie/papers/dslbib/, 2000.Google ScholarGoogle Scholar
  44. }}P. Wadler. Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science, 73:231--248, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Scrapping your inefficient engine: using partial evaluation to improve domain-specific language implementation

      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 Conferences
        ICFP '10: Proceedings of the 15th ACM SIGPLAN international conference on Functional programming
        September 2010
        398 pages
        ISBN:9781605587943
        DOI:10.1145/1863543
        • cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 45, Issue 9
          ICFP '10
          September 2010
          382 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/1932681
          Issue’s Table of Contents

        Copyright © 2010 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 27 September 2010

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        Overall Acceptance Rate333of1,064submissions,31%

        Upcoming Conference

        ICFP '24

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      ePub

      View this article in ePub.

      View ePub