Skip to content

Latest commit

 

History

History
121 lines (89 loc) · 4.6 KB

index.md

File metadata and controls

121 lines (89 loc) · 4.6 KB
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.

Recent Events

We've been holding tutorials at major conferences and summer schools:

scala-lms.github.io/cgo2015

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

Abstraction Without Regret

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 %}

{% highlight scala %} var n: Double = 0.0 var i: Int = 0 val end = data.length while (i < end) { val x = data(i) val c = x > 0 if (c) n += x } println(n) {% 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...

Run Scala Anywhere

Generate code for heterogenenous targets. Compile Scala to JavaScript, SQL, CUDA, C...

Getting Started {#docs}

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!

Community

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.