Lightweight Modular Staging (LMS) is a runtime code generation approach. The framework provides a library of core components for building high performance code generators and embedded compilers in Scala.
LMS is used by several other projects, including:
We’ve been holding tutorials at major conferences and summer schools:
Slides and additional materials are available from the links above.
The Summer of LMS: We have conducted focused hackathons with specific themes:
Turn nice high-level programs into fast low-level code. Strip abstraction overhead from generic programs. Add domain-specific optimizations.
Running the snippet above will generate the program on the left: All functions are inlined,
all generics specialized, all type class instances removed.
All of this is guaranteed by the type system: Expressions of type Rep[T]
become
part of the generated program, everything else is evaluated when the original
snippet is run.
Actually this is only half of the story: The output on the left is not produced directly, but going through an extensible intermediate representation (IR) that can be further transformed and optimized. Read more…
Generate code for heterogenenous targets. Compile Scala to JavaScript, SQL, CUDA, C…
Clone the GitHub repo. It contains an extensive test suite with examples.
git clone git://github.com/TiarkRompf/virtualization-lms-core.git
Be sure to check out the docs!
LMS is developed and used by researchers and practitioners from EPFL, Stanford, ETH, Purdue, University of Rennes, Barcelona Supercomputing Center, Oracle Labs, Huawei Labs, and other institutions.