introduction of a lightweight stage-programming framework

22
Introduction of A Light- weight Stage-Programming Framework On Considering Designing A DSL for GTA Yu LIU /2012/06

Upload: yu-liu

Post on 16-Apr-2017

237 views

Category:

Technology


0 download

TRANSCRIPT

Introduction of A Light-weight Stage-Programming

Framework

On Considering Designing A DSL for GTA

Yu LIU /2012/06

Overview

● A simple demo of GTA ● Introduction of the Delite/LMS Frame-

work● Conclusions about the GTA-DSL Impl.

Staging Programming Approach

● How Delite work with its DSLs

A Heterogeneous Parallel Framework forDomain-Specific Languages,PACT11

Demo

● A G+A implementation on Delite/LMS● Runnable (please omit the results)● Not finished part is only the actual code-

generators

Language Virtualization

H. Chafi et al., ‘‘Language Virtualization for Heterogeneous Parallel Com-puting,’’ Proc. ACM Int’l Conf. Object Oriented Programming Systems Languages and Applications,ACM Press, 2010, pp. 835-847.

Internal Implementation

● Scala-Virtualized (Tool Demo: Scala-Virtualized, EPFL2012)

– Scala-Virtualized extends the Scala language and compiler with a small number of features that enable combining the benefits of shallow and deep embeddings of DSLs

Scala-Virtualized

● program is expressed in terms of method calls

●Lightweight Module Stage

● The ideas of LMS are:– A library-based multi-stage programming ap-

proach

– The DLSs are implemented as “librarys” on hosted languages, i.e., internal DSLs

– Based on the approach of “language virtual-ization”

DLSs on Delite Are Embedded DSLs

● Delite is framework for heterogeneous parallel framework for DSLs (multi-core, GPU)

● Delite is based on LMS● Delite/LMS use Scala as host-language

Embedded DSLs on Delite Framework

A Heterogeneous Parallel Framework forDomain-Specific Languages,PACT11

An example of LMS

An example of LMS (2)

An example of LMS (3)

2

1

- Rewrite the “fusion_body” function as “multi-method”- the rest thing is to implement the code-generator

An example of LMS (4)

The code-generator generates the real code, e.g., Scala code

IR node

Naive GTA

generateSubList (list)

filterWith ascending

aggregateBy maxSumAggregator ● Yellows are functions, reds are objects

● generateSubList (list:List[Int]) will produce a Generator instance

● Generator has a method: filterWith(Test):[Bag]

● aggregateBy is an infix operator of class Aggregatexxx

● maxSumAggregator is an object of Aggregatexxx

DLSs on Delite Are Embedded DSLs

1.Defining abstract front-end language types that are independent from our back-end datastructures

2.Defining separate packages for abstract operations, IR nodes and code generators

3.Declaring which parts of Scala we want to allow DSL applications to use (in this case, everything)

4.Telling Delite how to access our code generators

5.Providing a utility method to map the data structure we defined earlier to one that will be used from generated code

Some Details of Delite/LMS

● LSM framework provides basic means to construct IR nodes for DSL operations

● The Delite compiler framework provide high-level repsentations of execution patterns through DeliteOp IR

Some Details of LMS

● The DSL will be firstly compiled to IR nodes

– IR nodes are instances of DSL operations

– IR nodes are connected by their depen-dency

– Each IR node is a symbol and its definition

● A CFG(control flow graph) also generated● After IR-optimization, code generator will

generate codes for IR representation

Optimization and Parallelization

● LMS based on Scala-Virtualized which provides a special Scala complier by which some contral flows can be translated to function-calls

● By stage programming functions can be generated to CUDA/OpenCL/Scala/C/Matlab... and parallelized

Delite Collections and Ops

● Delite can automaticly parallelize ops on some collection types

– Provide multiloop/map/reduce … as primitive operations

– DSLs built on Delite can enjoy this parallel operations

The DSL for GTA

● Design DSLs on Delite/LMS are just design expressive scala-libraries

● Semantics and syntax of the GTA-DSL– Thinking as a library, the paradigm is simple

– But … more about language-design is under considering

Conclusions

● GTA can be expressed as a DSL using Delite● Such GTA-DSL can be optimized and

parallelized (also translated to mapreduce)● Still cannot run on clusters● Similar approaches of Delite may be

implemented by compiler-plugins of Scala