1 / 24

pH: A Parallel Dialect of Haskell

pH: A Parallel Dialect of Haskell. Jim Cipar & Jacob Sorber University of Massachusetts Amherst. * Some material adapted from slides from Arvind(MIT) and Jan-Willem Maesson(Sun). outline. Historical Background pH Language Threading in pH Scheduling Where is pH today?. History.

Download Presentation

pH: A Parallel Dialect of Haskell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. pH: A Parallel Dialect of Haskell Jim Cipar & Jacob Sorber University of Massachusetts Amherst * Some material adapted from slides from Arvind(MIT) and Jan-Willem Maesson(Sun)

  2. outline • Historical Background • pH Language • Threading in pH • Scheduling • Where is pH today?

  3. History • Dataflow Languages • Describe programs as data flows • Inherently parallel • Examples: Id and Sisal • Id • Introduced I-structures and M-structures to avoid copying arrays during construction.

  4. History • Id worked great on the Monsoon dataflow architecture. Speed up Data flow architecture effectively supports the execution model.

  5. History • Haskell • Purely functional programming language • Lazy execution model (expressions only evaluated when needed) • “Sexy” new type system [Jan-Willem Maesson] • People actually use Haskell (?)

  6. pH: parallel Haskell • pH = Haskell (syntax, type system) + Id (evaluation order, side-effect ops) • Goal: Unite two communities • Bring the dataflow and functional communities under a single language • Facilitate code sharing

  7. Language Structure • pH has 3 layers • pH(F) • Purely functional • Haskell + loops • pH(I) • pH(F) + I-structures (Id) • pH(M) • pH(I) + M-structures (Id)

  8. pH(F) • Adds for and while loops to Haskell • Syntactic sugar (== tail recursion) for sum=0 in for i <- [1..n] do next sum = sum + i finally sum

  9. pH(I) • I-structures • I-structure = write-once array • Reads are delayed until written • All reads return a single consistent value • No data races

  10. State? • Programs without side-effects/state are not usually very useful. • Add state using assignment (ML, Scheme) • Results in a sequential evaluation order • Goal: evaluate sequentially only when necessary.

  11. pH(M) == Full pH • M-structures (state) • Allows multiple synchronized “takes” and “puts” • Take: block until data is written, then remove it • Potential for race conditions (use barriers) • Useful for classic mark-based graph algorithms • Higher performance than pure functional (sometimes)

  12. M-Structure Syntax • Allocate := M_array(1,n) • Allocate := M_array((1,n),(1,m)) • Put := A![i] = 5 • Take := (A![i] + B![i]) def replace a i v = { x = a![i]; a![i] = v; in x};

  13. Barriers (1) • Divide a control region into two subregions that must be evaluated sequentially • Syntax = “---” def fib n = if n < 2 then n else { x = fib(n-1); --- y = fib(n-2); in x + y};

  14. Barriers (2) • Control parallelism • Reduce exponential resource usage • Sacrifice parallelism def fib n = if n < 2 then n else { x = fib(n-1); --- y = fib(n-2); in x + y};

  15. Barriers (3) • Force sequential evaluation def replace a i v = { x = a![i]; --- a![i] = v; in x};

  16. Implicit Parallelism • Program execution == expression reduction • Every reduction is evaluated in parallel • Exception: lambda expressions and conditionals def fib n = if n < 2 then n else { x = fib(n-1); y = fib(n-2); in x + y};

  17. Implicit Parallelism def fib n = if n < 2 then n else { x = fib(n-1); y = fib(n-2); in x + y}; n 1 2 (-) (-) fib() fib() (+)

  18. Parallel Execution • Eager evaluation • All expressions are reduced in parallel • Limited by data dependences and barriers f (4*x)(g 25 (5+6)) • Implications • Not all Haskell programs will terminate using pH semantics! • All pH programs will terminate using Haskell lazy semantics.

  19. Threading in pH

  20. Threading in pH • Spawn a new thread only when: • There are multiple dependent blocks • One of them actually suspends • Use strictness analysis to determine what needs to be evaluated.

  21. Scheduling • Work stealing (Cilk-style) • Follows usual call/return pattern • Good temporal locality in practice • Low overhead in the common case • I-structures/M-structures? • Add yourself to the defer list • Run the defer list on a write • Messes up temporal locality

  22. Where is pH now? Hmmm…..

  23. Implementation Status • Limited at best • Currently compiles to the Monsoon dataflow machine • Coming soon to the UltraSPARC • No documentation • A few papers, mostly about semantics • No support • Support for real parallel architectures might encourage involvement from the Haskell community

  24. Where is pH now? • Implementation • There might be hope • Haskell is actually used • Mitre: Speech Recognition System • LOLITA: Natural Language Processing System • Monadius: a Haskell shoot ‘em up • Legacy might live on through Fortress

More Related