Lightweight modular staging
Authors:
Open Access
- 1 June 2012
- journal article
- Published by Association for Computing Machinery (ACM) in Communications of the ACM
- Vol. 55 (6) , 121-130
Abstract
Good software engineering practice demands generalization and abstraction, whereas high performance demands specialization and concretization. These goals are at odds, and compilers can only rarely translate expressive high-level programs to modern hardware platforms in a way that makes best use of the available resources. Generative programming is a promising alternative to fully automatic translation. Instead of writing down the target program directly, developers write a program generator, which produces the target program as its output. The generator can be written in a high-level, generic style and can still produce efficient, specialized target programs. In practice, however, developing high-quality program generators requires a very large effort that is often hard to amortize. We present lightweight modular staging (LMS), a generative programming approach that lowers this effort significantly. LMS seamlessly combines program generator logic with the generated code in a single program, using only types to distinguish the two stages of execution. Through extensive use of component technology, LMS makes a reusable and extensible compiler framework available at the library level, allowing programmers to tightly integrate domain-specific abstractions and optimizations into the generation process, with common generic optimizations provided by the framework. LMS is well suited to develop embedded domain-specific languages (DSLs) and has been used to develop powerful performance-oriented DSLs for demanding domains such as machine learning, with code generation for heterogeneous platforms including GPUs. LMS has also been used to generate SQL for embedded database queries and JavaScript for web applications.Keywords
This publication has 21 references indexed in Scilit:
- Building-Blocks for Performance Oriented DSLsElectronic Proceedings in Theoretical Computer Science, 2011
- Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languagesJournal of Functional Programming, 2009
- Scalable component abstractions2005
- Scalable component abstractionsACM SIGPLAN Notices, 2005
- Spiral: A Generator for Platform-Adapted Libraries of Signal Processing AlogorithmsThe International Journal of High Performance Computing Applications, 2004
- Compiling embedded languagesJournal of Functional Programming, 2003
- Implementing Multi-stage Languages Using ASTs, Gensym, and Reflection2003
- Template meta-programming for HaskellACM SIGPLAN Notices, 2002
- Automated empirical optimizations of software and the ATLAS projectParallel Computing, 2001
- MetaML and multi-stage programming with explicit annotationsTheoretical Computer Science, 2000