skip to main content
research-article

Terra: a multi-stage language for high-performance computing

Published:16 June 2013Publication History
Skip Abstract Section

Abstract

High-performance computing applications, such as auto-tuners and domain-specific languages, rely on generative programming techniques to achieve high performance and portability. However, these systems are often implemented in multiple disparate languages and perform code generation in a separate process from program execution, making certain optimizations difficult to engineer. We leverage a popular scripting language, Lua, to stage the execution of a novel low-level language, Terra. Users can implement optimizations in the high-level language, and use built-in constructs to generate and execute high-performance Terra code. To simplify meta-programming, Lua and Terra share the same lexical environment, but, to ensure performance, Terra code can execute independently of Lua's runtime. We evaluate our design by reimplementing existing multi-language systems entirely in Terra. Our Terra-based auto-tuner for BLAS routines performs within 20% of ATLAS, and our DSL for stencil computations runs 2.3x faster than hand-written C.

References

  1. The LuaJIT project. http://http://luajit.org/.Google ScholarGoogle Scholar
  2. A. Bawden and J. Rees. Syntactic closures. In LFP, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. S. Behnel, R. Bradshaw, C. Citro, L. Dalcin, D. S. Seljebotn, and K. Smith. Cython: The best of both worlds. Computing in Science and Engineering, 13.2:31--39, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. K. J. Brown, A. K. Sujeeth, H. J. Lee, T. Rompf, H. Chafi,M. Odersky, and K. Olukotun. A heterogeneous parallel framework for domainspecific languages. In PACT, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. J. Carette. Gaussian elimination: A case study in efficient genericity with MetaOCaml. Sci. Comput. Program., 62(1):3--24, Sept. 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. B. Catanzaro, M. Garland, and K. Keutzer. Copperhead: Compiling an embedded data parallel language. In PPoPP, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. H. Chafi, A. K. Sujeeth, K. J. Brown, H. Lee, A. R. Atreya, and K. Olukotun. A domain-specific approach to heterogeneous parallelism. In PPoPP, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. A. Cohen, S. Donadio, M. Garzaran, C. Herrmann, and D. Padua. In search of a program generator to implement generic transformations for high-performance computing. In MetaOCaml Workshop, 2004.Google ScholarGoogle Scholar
  9. Z. DeVito, N. Joubert, F. Palacios, S. Oakley, M. Medina, M. Barrientos, E. Elsen, F. Ham, A. Aiken, K. Duraisamy, E. Darve, J. Alonso, and P. Hanrahan. Liszt: A domain specific language for building portable mesh-based PDE solvers. In SC, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. J. Eckhardt, R. Kaiabachev, E. Pasalic, K. Swadi, and W. Taha. Implicitly heterogeneous multi-stage programming. New Gen. Comput., 25(3):305--336, Jan. 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Flatt. Composable and compilable macros: You want it when? In ICFP, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. M. Frigo and S. Johnson. The design and implementation of FFTW3. Proc. of the IEEE, 93(2):216--231, 2005.Google ScholarGoogle ScholarCross RefCross Ref
  13. R. Garcia and A. Lumsdaine. Toward foundations for type-reflective metaprogramming. In GPCE, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. R. Ierusalimschy, L. H. de Figueiredo, and W. C. Filho. Lua - an extensible extension language. Software: Practice and Experience, 26, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. R. Ierusalimschy, L. H. De Figueiredo, and W. Celes. Passing a language through the eye of a needle. CACM, 54(7):38--43, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. S. Jones, T. Nordin, and D. Oliva. C--: A portable assembly language.In Workshop on Implementing Functional Languages, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. C. Lattner and V. Adve. LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation. In CGO, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. G. Mainland. Explicitly heterogeneous metaprogramming with metahaskell. In ICFP, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. R. Meyers. X macros. C/C++ Users J., 19(5):52--56, May 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. G. Neverov and P. Roe. Metaphor: A multi-staged, object-oriented programming language. In GPCE, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  21. C. Newburn, B. So, Z. Liu, M. McCool, A. Ghuloum, S. Toit, Z. G. Wang, Z. H. Du, Y. Chen, G. Wu, P. Guo, Z. Liu, and D. Zhang. Intel's Array Building Blocks: A retargetable, dynamic compiler and embedded language. In CGO, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. M. Poletto,W. C. Hsieh, D. R. Engler, and M. F. Kaashoek. C and tcc: A language and compiler for dynamic code generation. TOPLAS, 21 :1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. M. Püschel, J. M. F. Moura, B. Singer, J. Xiong, J. Johnson, D. Padua, M. Veloso, and R. W. Johnson. Spiral: A generator for platformadapted libraries of signal processing algorithms. Int. J. High Perform. Comput. Appl., 18(1):2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. J. Ragan-Kelley, A. Adams, S. Paris, M. Levoy, S. Amarasinghe, and F. Durand. Decoupling algorithms from schedules for easy optimization of image processing pipelines. In SIGGRAPH, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. T. Rompf and M. Odersky. Lightweight modular staging: A pragmatic approach to runtime code generation and compiled DSLs. In GPCE, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. J. Stam. Real-time fluid dynamics for games. In GDC, 2003.Google ScholarGoogle Scholar
  27. B. Stroustrup. Multiple inheritance for C++. In European Unix Systems Users's Group Conference, 1987.Google ScholarGoogle Scholar
  28. D. Syme, K. Battocchi, K. Takeda, D.Malayeri, J. Fisher, J. Hu, T. Liu, B. McNamara, D. Quirk, M. Taveggia, W. Chae, U. Matsveyeu, and T. Petricek. F#3.0 -- Strongly-typed language support for internet-scale information sources. Technical report, 2012.Google ScholarGoogle Scholar
  29. W. Taha. A gentle introduction to multi-stage programming. In Domain-Specific Program Generation, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  30. W. Taha and T. Sheard. MetaML and multi-stage programming with explicit annotations. In Theoretical Computer Science, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. S. Tobin-Hochstadt, V. St-Amour, R. Culpepper, M. Flatt, and M. Felleisen. Languages as libraries. In PLDI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Z. Wan, W. Taha, and P. Hudak. Real-time FRP. In ICFP, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. R. C. Whaley and A. Petitet. Minimizing development and maintenance costs in supporting persistently optimized BLAS. Softw. Pract. Exper., 35(2):101--121, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Terra: a multi-stage language for high-performance computing

    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 48, Issue 6
      PLDI '13
      June 2013
      515 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2499370
      Issue’s Table of Contents
      • cover image ACM Conferences
        PLDI '13: Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation
        June 2013
        546 pages
        ISBN:9781450320146
        DOI:10.1145/2491956

      Copyright © 2013 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 16 June 2013

      Check for updates

      Qualifiers

      • research-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!