U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science pH: A Parallel Dialect of Haskell Jim Cipar & Jacob Sorber University of Massachusetts.

Slides:



Advertisements
Similar presentations
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Advertisements

Types of Recursive Methods
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Potential Languages of the Future Chapel,
CS412/413 Introduction to Compilers Radu Rugina Lecture 37: DU Chains and SSA Form 29 Apr 02.
Program Representations. Representing programs Goals.
U NIVERSITY OF M ASSACHUSETTS, A MHERST – Department of Computer Science The Implementation of the Cilk-5 Multithreaded Language (Frigo, Leiserson, and.
Fundamentals of Python: From First Programs Through Data Structures
PARALLEL PROGRAMMING WITH OPENMP Ing. Andrea Marongiu
More on Recursive Methods KFUPM- ICS Data Structures.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
Operating Systems CMPSCI 377 Lecture 11: Memory Management
Computer Architecture II 1 Computer architecture II Programming: POSIX Threads OpenMP.
CSCI 8150 Advanced Computer Architecture Hwang, Chapter 2 Program and Network Properties 2.3 Program Flow Mechanisms.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
CS 536 Spring Intermediate Code. Local Optimizations. Lecture 22.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
U NIVERSITY OF M ASSACHUSETTS, A MHERST D EPARTMENT OF C OMPUTER S CIENCE Advanced Compilers CMPSCI 710 Spring 2003 Computing SSA Emery Berger University.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
U NIVERSITY OF M ASSACHUSETTS, A MHERST D EPARTMENT OF C OMPUTER S CIENCE Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
Intermediate Code. Local Optimizations
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Multilisp: Concurrent Functional Programming Ed Walters and Tim Richards University.
Dr. Muhammed Al-Mulhem ICS An Introduction to Functional Programming.
Computer Science 101 Introduction to Programming.
– 1 – Basic Machine Independent Performance Optimizations Topics Load balancing (review, already discussed) In the context of OpenMP notation Performance.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Parallel & Concurrent Programming: Occam Vitaliy Lvin University of Massachusetts.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
U NIVERSITY OF M ASSACHUSETTS, A MHERST D EPARTMENT OF C OMPUTER S CIENCE Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
ECE 1747 Parallel Programming Shared Memory: OpenMP Environment and Synchronization.
March 4, 2008 DF4-1http://csg.csail.mit.edu/arvind/ From Id/pH to Dataflow Graphs Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute.
Functional Languages. Why? Referential Transparency Functions as first class objects Higher level of abstraction Potential for parallel execution.
Functional Programming Universitatea Politehnica Bucuresti Adina Magda Florea
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Concurrency Patterns Emery Berger and Mark Corner University.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Advanced Compilers CMPSCI 710 Spring 2004 Lecture 1 Emery Berger University of Massachusetts,
U NIVERSITY OF M ASSACHUSETTS, A MHERST – Department of Computer Science Performance of Work Stealing in Multiprogrammed Environments Matthew Hertz Department.
Design Issues. How to parallelize  Task decomposition  Data decomposition  Dataflow decomposition Jaruloj Chongstitvatana 2 Parallel Programming: Parallelization.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Fortress John Burgess and Richard Chang CS691W University of Massachusetts Amherst.
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Overview of Compilers and JikesRVM John.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Software Systems Advanced Synchronization Emery Berger and Mark Corner University.
Fortress Aaron Becker Abhinav Bhatele Hassan Jafri 2 May 2006.
1-1 An Introduction to Functional Programming Sept
CS510 Concurrent Systems Jonathan Walpole. RCU Usage in Linux.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Synchronization Emery Berger and Mark Corner University.
High-level Interfaces for Scalable Data Mining Ruoming Jin Gagan Agrawal Department of Computer and Information Sciences Ohio State University.
3/12/2013Computer Engg, IIT(BHU)1 OpenMP-1. OpenMP is a portable, multiprocessing API for shared memory computers OpenMP is not a “language” Instead,
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science John Cavazos J Eliot B Moss Architecture and Language Implementation Lab University.
3/2/2016© Hal Perkins & UW CSES-1 CSE P 501 – Compilers Optimizing Transformations Hal Perkins Autumn 2009.
CS412/413 Introduction to Compilers and Translators April 2, 1999 Lecture 24: Introduction to Optimization.
CPE779: Shared Memory and OpenMP Based on slides by Laxmikant V. Kale and David Padua of the University of Illinois.
©SoftMoore ConsultingSlide 1 Code Optimization. ©SoftMoore ConsultingSlide 2 Code Optimization Code generation techniques and transformations that result.
CS314 – Section 5 Recitation 9
More Functional Programming
More on Recursive Methods
Computer Engg, IIT(BHU)
Optimization Code Optimization ©SoftMoore Consulting.
Closures and Streams cs784(Prasad) L11Clos
Lecture 5: GPU Compute Architecture
Amir Kamil and Katherine Yelick
Lecture 5: GPU Compute Architecture for the last time
Optimizing Transformations Hal Perkins Autumn 2011
FP Foundations, Scheme In Text: Chapter 14.
Optimizing Transformations Hal Perkins Winter 2008
Background and Motivation
Languages and Compilers (SProg og Oversættere)
Amir Kamil and Katherine Yelick
Closures and Streams cs7100(Prasad) L11Clos
The structure of programming
Thinking procedurally
Presentation transcript:

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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)

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 2 outline Historical Background pH Language Threading in pH Scheduling Where is pH today?

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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.

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 4 History Id worked great on the Monsoon dataflow architecture. 1x2x4x8x Mat. Multiply Paraffins n= Particles(40K) Simple 100 iters Speed up Data flow architecture effectively supports the execution model.

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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 (?)

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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)

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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.

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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) Program Version Executed Instructions Critical PathAverage Parallelism Heap used (words) HA1 HA2 HA3 HA4 HA5 M-structures 199,757 72, , , ,370 60,496 1,452 7, , ,250 2,100 18, ,301 9

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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};

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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};

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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};

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 15 Barriers (3) Force sequential evaluation def replace a i v = { x = a![i]; --- a![i] = v; in x};

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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};

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 17 Implicit Parallelism def fib n = if n < 2 then n else { x = fib(n-1); y = fib(n-2); in x + y}; fib() (-) fib() (+) n12

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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.

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 19 Threading in pH

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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.

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 22 Where is pH now? Hmmm…..

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 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