Lightweight modular staging
Tiark Rompf, Martin Odersky · Communications of the ACM · 2012
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.
Cited by 142 works. doi:10.1145/2184319.2184345
Authors
References
- Lecture Notes in Computer Science 1205
- Automated empirical optimizations of software and the ATLAS project
- A fast Fourier transform compiler
- Higher-order abstract syntax
- Template meta-programming for Haskell
- Higher-order abstract syntax
- Modular domain specific languages and tools
- Domain specific embedded compilers
- Spiral: A Generator for Platform-Adapted Libraries of Signal Processing Alogorithms
- Automated Empirical Optimizations of Software and the ATLAS Project (LAPACK Working Note 147)