Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 4, 2008 DF4-1http://csg.csail.mit.edu/arvind/ From Id/pH to Dataflow Graphs Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute.

Similar presentations


Presentation on theme: "March 4, 2008 DF4-1http://csg.csail.mit.edu/arvind/ From Id/pH to Dataflow Graphs Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute."— Presentation transcript:

1 March 4, 2008 DF4-1http://csg.csail.mit.edu/arvind/ From Id/pH to Dataflow Graphs Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology

2 March 4, 2008 DF4-2http://csg.csail.mit.edu/arvind/ Parallel Language Model Global Heap of Shared Objects Tree of Activation Frames h:g: f: loop active threads asynchronous and parallel at all levels

3 March 4, 2008 DF4-3http://csg.csail.mit.edu/arvind/ Dataflow Graphs + I-Structures +... TTDA Monsoon *T *T-Voyager Id World implicit parallelism Id

4 March 4, 2008 DF4-4http://csg.csail.mit.edu/arvind/ Id Compiler Phases  Id   Kernel Id   Parallel Three Address Code, P-TAC   Dataflow Graphs/Threads   Machine Graphs  von Neumann  code   Reduction  desugar  select representations  Fixed Program Semantics of each intermediate language is important to show the correctness of each module

5 March 4, 2008 DF4-5http://csg.csail.mit.edu/arvind/ Choosing Representations: Arrays lower upper lower upper bounds lower upper lower upper bounds 1. 2. 3. bounds array 4.

6 March 4, 2008 DF4-6http://csg.csail.mit.edu/arvind/ type list *0 = nil | cons *0 (list *0) 1. nil tag=0 tag=1 cons 2. nil cons tag Boxed Unboxed Implicit Assumption: Pointers can be distinguished from small integers Similar issues arise for all Algebraic Types Choosing Representations: Lists

7 March 4, 2008 DF4-7http://csg.csail.mit.edu/arvind/ Case Expression and Tags type foo.. = C1... | C2... |... | Cn... The case expression for type foo foo-case(d,e 1,...,e n ) is implemented using the case construct: case k (i,e 1,...,e k )e i where i = ifetch(d);

8 March 4, 2008 DF4-8http://csg.csail.mit.edu/arvind/ Top Level Functions f = k (x 1,...,x k ).e Do not contain any free variables except the names of other top level functions. In general, its arguments can be supplied in one of two ways: 1. As a data structure which is built incrementally F = xs.{ (x 1,...,x k ) = destruct(xs); in e } 2. All at once - fast call F fc = k (x 1,...,x k ).e

9 March 4, 2008 DF4-9http://csg.csail.mit.edu/arvind/ Multi-arity Functions def f x 1... x k = e can be translated as f = x 1.x 2.... x k.e However, most implementation use k-arity s f = k (x 1,...,x k ).e with the rules: ( k (x 1,...,x k ).e) a  { x’ 1 = a in (( k (x 1,...,x k ).e) x’ 1 )} if k > 1 (( k (x 1,...,x k ).e) x’ 1... x’ n ) a  { x’ n+1 = a in (( k (x 1,...,x k ).e) x’ 1... x’ n+1 )} if n < k-1 (( k (x 1,...,x k ).e) x’ 1... x’ n ) a  { x’ n+1 = a in e[x’ 1 /x 1 ]... [x’ k /x k ]} if n = k-1 Partial applications are values and thus substitutable

10 March 4, 2008 DF4-10http://csg.csail.mit.edu/arvind/ Loop Translation TE[{while e p do S finally e f } = { p= k (x 1,...,x k ).TE[e p ] ; b= k (x 1,...,x k ). { TS[S] in nextx 1,...,nextx k }; t p = p x ; t = Wloop k (p,b,x,t p ) ; t f = TE[e f ][t/x] ; in t f } where x = (x 1,...,x k ) and x i ’s are the “nextified” variables of S and “next x” is replaced by “nextx” everywhere

11 March 4, 2008 DF4-11http://csg.csail.mit.edu/arvind/ Loop Rules Wloop k (p, b, x, true)  { t = b x; t p = p t; t’ = Wloop k (p, b, t, t p ) in t’ } Wloop k (p, b, x, false) x

12 March 4, 2008 DF4-12http://csg.csail.mit.edu/arvind/ KId - The Kernel Id Language An extended S -calculus E ::= x | k (x 1,...,x k ).E | SE SE | { S in SE } | Case k (SE, E 1,...,E k ) | PF k (SE 1,...,SE k ) | CN 0 | CN k (SE 1,...,SE k ) | allocate() | Wloop(E p,E b,x,bool) S ::= x = E | S; S | S --- S | store(SE,SE,SE) PF 2 ::=...| i-fetch | m-fetch Simple Expressions SE ::= x | CN 0 | CN k (SE 1,...,SE k ) | k (x 1,...,x k ).E | (( k (x 1,...,x k ).E) SE 1...SE n ) n < k

13 March 4, 2008 DF4-13http://csg.csail.mit.edu/arvind/ KId Optimizations “Totally correct” optimizations ( S rewrite rules) Constant Propagation/Folding Fetch Elimination Barrier discharge Inline Substitution/Specialization Dead-code Elimination /Garbage collection... Additional transformations or rewrite rules Algebraic Identities Common Subexpression Elimination Code Hoisting out of Conditionals Loop Optimizations Peeling/Unrolling Lifting loop invariants Eliminating circulating variables and constants Induction variable analysis

14 March 4, 2008 DF4-14http://csg.csail.mit.edu/arvind/ P-TAC: Three Address Code A lower level language than KId 1. Exposes all address calculations. Requires choosing representations for all data structures 2. No nested function definitions - -abstractions exist only at the top level 3. Partial applications are represented as data structures (Closures)

15 March 4, 2008 DF4-15http://csg.csail.mit.edu/arvind/ Generating Dataflow Graphs GE :: P-TAC Expression --> DFG... tg x 1 x n sg G

16 March 4, 2008 DF4-16http://csg.csail.mit.edu/arvind/ P-TAC to Dataflow Graphs Expressions apply x 1 x 2 GE[c] = c GE[x 1 x 2 ] = GE[PF k (x 1,...,x k )] = PF k x 1... x k GE[x] = x

17 March 4, 2008 DF4-17http://csg.csail.mit.edu/arvind/ Case Schema GE[Case k (i, e 1,...,e k )] 1 k GE[e 1 ]GE[e k ] Switch i x 1... x n... x 1... x n { x 1,...,x n } = FV(e 1 )U...U FV(e k ) All e i ’s must have the same number of outputs Unused x i ’s in each branch have to be collected for signal generation

18 March 4, 2008 DF4-18http://csg.csail.mit.edu/arvind/ Graph for Function Application The Full Application case t (( k (x 1,...,x k ).e) x’ 1... x’ k-1 ) a  { x’ k = a in e[x’ 1 /x 1 ]... [x’ k /x k ] a new copy of e change tag a apply f x t: f get context extract tag change Tag0 change Tag1 a change Tag 1: 0: GE[e]  Apply is a conditional schema; make-closure part is not shown

19 March 4, 2008 DF4-19http://csg.csail.mit.edu/arvind/ Loop Schema GE[Wloop k (p,b,(x 1,...,x k ),tp] = next GS[S b ] GE[e p ] x 1... x k tp next {x 1,...,x n } are the nextified variables p = k (x 1...x k ).e p b = k (x 1...x k ).{S b in next x 1,...,next x k }...

20 March 4, 2008 DF4-20http://csg.csail.mit.edu/arvind/ P-TAC to Dataflow Graphs The Block Expression GE[{S in x}] = where {x 1,...,x n } = FV(S) GS[x = e] = where {x 1,...,x n } = FV(e)... tg x 1 x n sg GE(e) x GS[store(x 1,x 2 )] = x 1 x 2 sg istore... tg x 1 x n y 1 y m GS(S) x sg

21 March 4, 2008 DF4-21http://csg.csail.mit.edu/arvind/ Parallel Composition ''Wiring Diagrams'' {y 1,...,y n } = BV(S 1 ) U BV(S 2 ) {x 1,...,x n } = FV(S 1 ) U FV(S 2 ) - {y 1,...,y n } GS[S 1 ;S 2 ] =... tg x 11 x 1n y 11 y 1m sg GS(S 1 )... tg x 21 x 2n y 21 y 2m sg GS(S 2 ) x 1... x n y 1... y n Id Each x ij is to be connected to the y ij with the same name

22 March 4, 2008 DF4-22http://csg.csail.mit.edu/arvind/ Sequential Composition {x 1,...,x n } = FV(S 1 ) U FV(S 2 ) {y 1,...,y n } = BV(S 1 ) U BV(S 2 )... tg x 11 x 1n y 11 y 1m sg GS(S 1 ) GS[S 1 ---S 2 ] =... tg x 21 x 2n y 21 y 2m sg GS(S 2 ) x 1... x n y 1... y n Each x 2j is to be connected to the y 1j with the same name


Download ppt "March 4, 2008 DF4-1http://csg.csail.mit.edu/arvind/ From Id/pH to Dataflow Graphs Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute."

Similar presentations


Ads by Google