cost semantics for space usage in a parallel language
play

Cost Semantics for Space Usage in a Parallel Language Daniel - PowerPoint PPT Presentation

Cost Semantics for Space Usage in a Parallel Language Daniel Spoonhower Carnegie Mellon University (Joint work with Guy Blelloch & Robert Harper) DAMP 16 Jan 2007 Understanding How Programs Compute Interested in intensional behavior of


  1. Cost Semantics for Space Usage in a Parallel Language Daniel Spoonhower Carnegie Mellon University (Joint work with Guy Blelloch & Robert Harper) DAMP – 16 Jan 2007

  2. Understanding How Programs Compute Interested in intensional behavior of programs ◮ more than just final result ◮ e.g. time & space required 16 Jan 2007 DAMP ’07 Cost Semantics for Space 2

  3. Understanding How Programs Compute Interested in intensional behavior of programs ◮ more than just final result ◮ e.g. time & space required State-of-the-art = compile, run, & profile 16 Jan 2007 DAMP ’07 Cost Semantics for Space 2

  4. Understanding How Programs Compute Interested in intensional behavior of programs ◮ more than just final result ◮ e.g. time & space required State-of-the-art = compile, run, & profile ✖ architecture specific ( e.g. # cores) ✖ dependent on configuration ( e.g. scheduler) ✖ compilers for functional languages are complex ( e.g. closure, CPS conversion) 16 Jan 2007 DAMP ’07 Cost Semantics for Space 2

  5. Motivating Example: Quicksort Assume fine-grained parallelism ◮ pairs < e 1 || e 2 > may evaluate in parallel ◮ schedule determined by compiler & run-time fun qsort xs = case xs of nil => nil | x::xs => append <qsort (filter (le x) xs) || x::(qsort (filter (gt x) xs))> 16 Jan 2007 DAMP ’07 Cost Semantics for Space 4

  6. Quicksort: High-Water Mark for Heap 16 Jan 2007 DAMP ’07 Cost Semantics for Space 5

  7. Approach Cost Semantics ◮ define execution costs for high-level language ◮ account for parallelism & space Provable Implementation ◮ make parallelism explicit ◮ translate to lower-level language ◮ prove costs are preserved at each step ◮ consider scheduler, GC implementation 16 Jan 2007 DAMP ’07 Cost Semantics for Space 6

  8. Approach Talk Outline Cost Semantics ◮ define execution costs for high-level language ◮ account for parallelism & space Provable Implementation ◮ make parallelism explicit ◮ translate to lower-level language ◮ prove costs are preserved at each step ◮ consider scheduler, GC implementation 16 Jan 2007 DAMP ’07 Cost Semantics for Space 6

  9. Background: Cost Semantics A cost semantics is a dynamic semantics ◮ i.e. execution model for high-level language Yields a cost metric, some abstract measure of cost ◮ e.g. steps of evaluation, upper bound on space 16 Jan 2007 DAMP ’07 Cost Semantics for Space 7

  10. Background: Cost Semantics A cost semantics is a dynamic semantics ◮ i.e. execution model for high-level language Yields a cost metric, some abstract measure of cost ◮ e.g. steps of evaluation, upper bound on space We will a consider a cost model that accounts for parallelism and space. 16 Jan 2007 DAMP ’07 Cost Semantics for Space 7

  11. Source Language Consider a pure, functional language. ◮ includes functions, pairs, and booleans Pair components evaluated in parallel. ◮ denoted < e 1 || e 2 > Values are disjoint from source language. ◮ values are labeled to make sharing explicit e.g. ( v 1 , v 2 ) ℓ 16 Jan 2007 DAMP ’07 Cost Semantics for Space 8

  12. Parallel Cost Semantics Cost semantics is a big-step (evaluation) semantics ◮ yields two graphs: computation and heap ◮ sequential, unique result per program e ⇓ v ; g ; h Expression e evaluates to value v with computation graph g and heap graph h . 16 Jan 2007 DAMP ’07 Cost Semantics for Space 9

  13. Computation Graphs Track control dependencies using a DAG with distinguished start and end nodes. g = ( n start , n end , E ) 16 Jan 2007 DAMP ’07 Cost Semantics for Space 10

  14. Computation Graphs Track control dependencies using a DAG with distinguished start and end nodes. g = ( n start , n end , E ) 1 [ n ] g 1 ⊕ g 2 g 1 ⊗ g 2 16 Jan 2007 DAMP ’07 Cost Semantics for Space 10

  15. Heap Graphs Track heap dependencies using a directed graph h = E ◮ nodes shared with corresponding g ◮ edges run in opposite direction 16 Jan 2007 DAMP ’07 Cost Semantics for Space 11

  16. Heap Graphs Track heap dependencies using a directed graph h = E ◮ nodes shared with corresponding g ◮ edges run in opposite direction 16 Jan 2007 DAMP ’07 Cost Semantics for Space 11

  17. Using Cost Graphs Cost graphs are tools for programmers. ◮ relate execution costs to source code ◮ later: simulate runtime behavior Many concrete metrics possible ◮ considered maximum heap size in example ◮ impact of GC: measure overhead, latency 16 Jan 2007 DAMP ’07 Cost Semantics for Space 12

  18. Using Cost Graphs Cost graphs are tools for programmers. ◮ relate execution costs to source code ◮ later: simulate runtime behavior Many concrete metrics possible ◮ considered maximum heap size in example ◮ impact of GC: measure overhead, latency However, this reasoning is only valid if the implementation respects these costs. 16 Jan 2007 DAMP ’07 Cost Semantics for Space 12

  19. Provable Implementation Guaranteed to faithfully mirror high-level costs ◮ “implementation” = lower-level semantics Costs ⇒ contract for lower-level implementations ◮ e.g. environment trimming, tail calls ◮ can guide concrete implementation on hardware 16 Jan 2007 DAMP ’07 Cost Semantics for Space 13

  20. Provable Implementation Guaranteed to faithfully mirror high-level costs ◮ “implementation” = lower-level semantics Costs ⇒ contract for lower-level implementations ◮ e.g. environment trimming, tail calls ◮ can guide concrete implementation on hardware This work: transition semantics defines parallelism ◮ several (non-)deterministic versions ◮ can incorporate specific scheduling algorithms 16 Jan 2007 DAMP ’07 Cost Semantics for Space 13

  21. Transition Semantics Non-deterministic, parallel, small step semantics ◮ parallel construct for in-progress computations (expressions) e ::= . . . | let par d in e (declarations) d ::= x = e | d 1 and d 2 16 Jan 2007 DAMP ’07 Cost Semantics for Space 14

  22. Transition Semantics Non-deterministic, parallel, small step semantics ◮ parallel construct for in-progress computations (expressions) e ::= . . . | let par d in e (declarations) d ::= x = e | d 1 and d 2 ◮ declarations simulate a call “stack” ◮ allows unbounded parallelism, e.g. → d ′ → d ′ d 1 �− d 2 �− 1 2 → ( d ′ 1 and d ′ ( d 1 and d 2 ) �− 2 ) 16 Jan 2007 DAMP ’07 Cost Semantics for Space 14

  23. Schedules Define a schedule of g as any covering traversal from n start to n end . ◮ ordering must respect control dependencies 16 Jan 2007 DAMP ’07 Cost Semantics for Space 15

  24. Schedules Define a schedule of g as any covering traversal from n start to n end . ◮ ordering must respect control dependencies Definition (Schedule) A schedule of a graph g = ( n start , n end , E ) is a sequence of sets of nodes N 0 , . . . , N k such that n start �∈ N 0 , n end ∈ N k , and for all i ∈ [0 , k ), ◮ N i ⊆ N i +1 , and ◮ for all n ∈ N i +1 , pred( n ) ⊆ N i . 16 Jan 2007 DAMP ’07 Cost Semantics for Space 15

  25. Theorem Every schedule corresponds to a sequence of derivations in the transition semantics. Theorem If e ⇓ v ; g ; h then, N 0 , . . . , N k is a schedule of g ⇔ there exists a sequence of k transitions e �− → . . . �− → v such that i ∈ [0 , k ] , roots ( N i ; h ) = labels ( e i ) . 16 Jan 2007 DAMP ’07 Cost Semantics for Space 16

  26. Measuring Space Usage GC roots determined by heap graph h and schedule ◮ roots = edges that cross schedule frontier Reachable values deter- mined by reachability in h . 16 Jan 2007 DAMP ’07 Cost Semantics for Space 17

  27. Measuring Space Usage (con’t) Note that edges in h correspond to direct dependencies as well as “possible last uses.” e 1 ⇓ false ℓ 1 ; g 1 ; h 1 e 3 ⇓ v 3 ; g 3 ; h 3 ( n fresh) if e 1 then e 2 else e 3 ⇓ v 3 ; 1 ⊕ g 1 ⊕ [ n ] ⊕ 1 ⊕ g 3 h 1 ∪ h 3 ∪ { ( n , ℓ 1 ) } ∪ { ( n , ℓ ) } ℓ ∈ labels ( e 2 ) 16 Jan 2007 DAMP ’07 Cost Semantics for Space 18

  28. Measuring Space Usage (con’t) Note that edges in h correspond to direct dependencies as well as “possible last uses.” e 1 ⇓ false ℓ 1 ; g 1 ; h 1 e 3 ⇓ v 3 ; g 3 ; h 3 ( n fresh) if e 1 then e 2 else e 3 ⇓ v 3 ; 1 ⊕ g 1 ⊕ [ n ] ⊕ 1 ⊕ g 3 h 1 ∪ h 3 ∪ { ( n , ℓ 1 ) } ∪ { ( n , ℓ ) } ℓ ∈ labels ( e 2 ) 16 Jan 2007 DAMP ’07 Cost Semantics for Space 18

  29. Measuring Space Usage (con’t) Note that edges in h correspond to direct dependencies as well as “possible last uses.” e 1 ⇓ false ℓ 1 ; g 1 ; h 1 e 3 ⇓ v 3 ; g 3 ; h 3 ( n fresh) if e 1 then e 2 else e 3 ⇓ v 3 ; 1 ⊕ g 1 ⊕ [ n ] ⊕ 1 ⊕ g 3 h 1 ∪ h 3 ∪ { ( n , ℓ 1 ) } ∪ { ( n , ℓ ) } ℓ ∈ labels ( e 2 ) 16 Jan 2007 DAMP ’07 Cost Semantics for Space 18

  30. Measuring Space Usage (con’t) Note that edges in h correspond to direct dependencies as well as “possible last uses.” e 1 ⇓ false ℓ 1 ; g 1 ; h 1 e 3 ⇓ v 3 ; g 3 ; h 3 ( n fresh) if e 1 then e 2 else e 3 ⇓ v 3 ; 1 ⊕ g 1 ⊕ [ n ] ⊕ 1 ⊕ g 3 h 1 ∪ h 3 ∪ { ( n , ℓ 1 ) } ∪ { ( n , ℓ ) } ℓ ∈ labels ( e 2 ) 16 Jan 2007 DAMP ’07 Cost Semantics for Space 18

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend