skip to main content
article

Specialization through dynamic staging

Published:15 September 2014Publication History
Skip Abstract Section

Abstract

Partial evaluation allows for specialization of program fragments. This can be realized by staging, where one fragment is executed earlier than its surrounding code. However, taking advantage of these capabilities is often a cumbersome endeavor. In this paper, we present a new metaprogramming concept using staging parameters that are first-class citizen entities and define the order of execution of the program. Staging parameters can be used to define MetaML-like quotations, but can also allow stages to be created and resolved dynamically. The programmer can write generic, polyvariant code which can be reused in the context of different stages. We demonstrate how our approach can be used to define and apply domain-specific optimizations. Our implementation of the proposed metaprogramming concept generates code which is on a par with templated C++ code in terms of execution time.

References

  1. A. W. Appel. Compiling with Continuations. Cambridge University Press, 1992. ISBN 0-521-41695-7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. C. Calcagno, W. Taha, L. Huang, and X. Leroy. Implementing Multistage Languages using ASTs, Gensym, and Reflection. In Proceedings of the 2nd International Conference on Generative Programming and Component Engineering (GPCE), pages 57–76. Springer, Sept. 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. J. W. Cooley and J. W. Tukey. An Algorithm for the Machine Calculation of Complex Fourier Series. Mathematics of Computation, 19(90):297–301, 1965.Google ScholarGoogle ScholarCross RefCross Ref
  4. Z. DeVito, J. Hegarty, A. Aiken, P. Hanrahan, and J. Vitek. Terra: A Multi-Stage Language for High-Performance Computing. In Proceedings of the 34th annual ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 105–116. ACM, June 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. D. R. Engler, W. C. Hsieh, and M. F. Kaashoek. ‘C: A Language for High-level, Efficient, and Machine-independent Dynamic Code Generation. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pages 131–144. ACM, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. C. Lattner and V. Adve. LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation. In Proceedings of the 2004 International Symposium on Code Generation and Optimization (CGO), pages 75––86. IEEE, Mar. 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. J. Levine, T. Mason, and D. Brown. Lex & Yacc. O’’Reilly & Associates, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. E. Moggi, W. Taha, Z.-E.-A. Benaissa, and T. Sheard. An Idealized MetaML: Simpler, and More Expressive. Lecture Notes in Computer Science, pages 193–207. Springer, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. B. C. Pierce. Types and Programming Languages. MIT Press, 2002. ISBN 0-262-16209-1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. T. Rompf and M. Odersky. Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In Proceedings of the 9th International Conference on Generative Programming and Component Engineering (GPCE), pages 127–136. ACM, Oct. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. T. Sheard and S. P. Jones. Template Meta-programming for Haskell. In Proceedings of the 2002 ACM SIGPLAN Workshop on Haskell, pages 1–16. ACM, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. G. Sussman and G. Steele. Scheme: An Interpreter for Extended Lambda Calculus. Massachusetts Institute of Technology, Artificial Intelligence Laboratory, 1975.Google ScholarGoogle Scholar
  13. W. Taha and T. Sheard. Multi-Stage Programming with Explicit Annotations. ACM SIGPLAN Notices, 32(12):203–217, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. W. Taha and T. Sheard. MetaML and Multi-Stage Programming with Explicit Annotations. In Theoretical Computer Science, pages 203–217. ACM Press, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. A. M. Turing. On Computable Numbers, With an Application to the Entscheidungsproblem. Proceedings of the London Mathematical Society, 42(2):230–265, 1936.Google ScholarGoogle Scholar

Index Terms

  1. Specialization through dynamic staging

          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

          Full Access

          • Published in

            cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 50, Issue 3
            GPCE '14
            March 2015
            141 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/2775053
            • Editor:
            • Andy Gill
            Issue’s Table of Contents
            • cover image ACM Conferences
              GPCE 2014: Proceedings of the 2014 International Conference on Generative Programming: Concepts and Experiences
              September 2014
              141 pages
              ISBN:9781450331616
              DOI:10.1145/2658761

            Copyright © 2014 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 15 September 2014

            Check for updates

            Qualifiers

            • article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!