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

Introduction of A Lightweight Stage-Programming Framework

Apr 16, 2017

Download

Technology

Yu Liu
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction of A Lightweight Stage-Programming Framework

Introduction of A Light-weight Stage-Programming

Framework

On Considering Designing A DSL for GTA

Yu LIU /2012/06

Page 2: Introduction of A Lightweight Stage-Programming Framework

Overview

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

work● Conclusions about the GTA-DSL Impl.

Page 3: Introduction of A Lightweight Stage-Programming Framework

Staging Programming Approach

● How Delite work with its DSLs

A Heterogeneous Parallel Framework forDomain-Specific Languages,PACT11

Page 4: Introduction of A Lightweight Stage-Programming Framework

Demo

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

generators

Page 5: Introduction of A Lightweight Stage-Programming Framework

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.

Page 6: Introduction of A Lightweight Stage-Programming Framework

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

Page 7: Introduction of A Lightweight Stage-Programming Framework

Scala-Virtualized

● program is expressed in terms of method calls

Page 8: Introduction of A Lightweight Stage-Programming Framework

●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”

Page 9: Introduction of A Lightweight Stage-Programming Framework

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

Page 10: Introduction of A Lightweight Stage-Programming Framework

Embedded DSLs on Delite Framework

A Heterogeneous Parallel Framework forDomain-Specific Languages,PACT11

Page 11: Introduction of A Lightweight Stage-Programming Framework

An example of LMS

Page 12: Introduction of A Lightweight Stage-Programming Framework

An example of LMS (2)

Page 13: Introduction of A Lightweight Stage-Programming Framework

An example of LMS (3)

2

1

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

Page 14: Introduction of A Lightweight Stage-Programming Framework

An example of LMS (4)

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

IR node

Page 15: Introduction of A Lightweight Stage-Programming Framework

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

Page 16: Introduction of A Lightweight Stage-Programming Framework

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

Page 17: Introduction of A Lightweight Stage-Programming Framework

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

Page 18: Introduction of A Lightweight Stage-Programming Framework

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

Page 19: Introduction of A Lightweight Stage-Programming Framework

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

Page 20: Introduction of A Lightweight Stage-Programming Framework

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

Page 21: Introduction of A Lightweight Stage-Programming Framework

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

Page 22: Introduction of A Lightweight Stage-Programming Framework

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