Building a Program Generator With Scala Georg Ofenbeck Markus Püschel Computer Science TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAA
Goal Building a prototypical program generator inside Scala “Spiral like” Support for Domain specific languages (algorithm representation) Rewriting (on DSL for structural optimization) Compilation ( DSL, → DSL2, → …. → C)
DSL in Scala: SPL Lightweight Modular Staging [1] F_2 tensor I(4) Rep[F_2] tensor Rep[I(4)] Rep[+T] abstract type constructor Tensor (Exp[F_2], Exp[I(4)]) Symbol X Tensor (Exp[F_2], Exp[I(4)]) [1]: Rompf, Odersky: Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. GPCE’10
DSL in Scala: SPL ( DFT(k) tensor I(m) ) compose T(n, m) compose ( I(k) tensor DFT(m) ) compose L(n, k) Binding times distinguished only by types Full host language available to process the DSL Sharing of DSL infrastructure possible between DSLs
Rewriting Pattern matching in Scala naturally supports this
Compilation DSL to DSL . . . . Subset of C as DSL . . . .
State of the Work Level 1 Straight-line Code PCDI/ICCS 2001 Level 2 Looped Code Sigma SPL PLDI 2005 Level 3 Parallelism Tag based rewriting SC 2006 Level 4 Library Generation Recursion step closure CGO 2009 Markus Püschel, Franz Franchetti and Yevgen Voronenko, Spiral, in Encyclopedia of Parallel Computing, Eds. David Padua, Springer 2011