layout |
---|
landing |
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:
- Delite: domain-specific languages for heterogeneous parallel computing.
- Spiral: library generators for high-performance numerical kernels.
- LegoBase: query compilation in database systems.
We've been holding tutorials at major conferences and summer schools:
- PLDI 2017: Barcelona, June 23. More info: scala-lms.github.io/pldi2017
- DSLDISS 2015: Lausanne, July 14. More info: vjovanov.github.io/dsldi-summer-school
- CGO 2015: San Francisco, February 7. More info:
- SPLASH 2014: Portland, October 22. More info: 2014.splashcon.org
- CUFP 2014: Gothenburg, September 5. More info: scala-lms.github.io/cufp2014
- ECOOP 2013: Montpellier, July 3-5. More info: scala-lms.github.io/ecoop2013
- PLDI 2013: Seattle, June 16. More info: scala-lms.github.io/pldi2013
Slides and additional materials are available from the links above.
The Summer of LMS: We have conducted focused hackathons with specific themes:
- 2014: stability, polishing, documentation.
- 2015: reimplement Scala-Virtualized compiler fork using macros
- 2016: focus on C generation, including specs for static verification
Turn nice high-level programs into fast low-level code. Strip abstraction overhead from generic programs. Add domain-specific optimizations.
{% highlight scala %} class Vector[T:Numeric:Manifest](val data: Rep[Array[T]]) { def foreach(f: Rep[T] => Rep[Unit]): Rep[Unit] = for (i <- 0 until data.length) f(data(i)) def sumIf(f: Rep[T] => Rep[Boolean]) = { var n = zero[T]; foreach(x => if (f(x)) n += x); n } }
val v: Vector[Double] = ... println(v.sumIf(_ > 0)) {% endhighlight %}
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.