U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Multilisp: Concurrent Functional Programming Ed Walters and Tim Richards University.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 1 Three Challenges for Transactional Computing J. Eliot B. Moss Associate Professor,
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Grace: Safe Multithreaded Programming for C/C++ Emery Berger University of Massachusetts,
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Rich Transactions on Reasonable Hardware J. Eliot B. Moss Univ. of Massachusetts,
Chapter 3 Functional Programming. Outline Introduction to functional programming Scheme: an untyped functional programming language.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Apply-to-all A functional form that takes a single function as a parameter and yields a list of values obtained.
U NIVERSITY OF M ASSACHUSETTS, A MHERST – Department of Computer Science The Implementation of the Cilk-5 Multithreaded Language (Frigo, Leiserson, and.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
Cs784(TK)1 Semantics of Procedures and Scopes. Kinds of Scope Static or Lexical scope –determined by structure of program –Scheme, C++, Java, and many.
1 Functional programming Languages And a brief introduction to Lisp and Scheme.
Cs7100(Prasad)L11Clos1 Closures and Streams. Contemporary Interest in Closures The concept of closures was developed in the 1960s and was first fully.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
Safety as a Software Metric Matthias Felleisen and Robert Corky Cartwright Rice University.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
Chapter 15 Other Functional Languages. Copyright © 2007 Addison-Wesley. All rights reserved. Functional Languages Scheme and LISP have a simple syntax.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science pH: A Parallel Dialect of Haskell Jim Cipar & Jacob Sorber University of Massachusetts.
Common Lisp! John Paxton Montana State University Summer 2003.
Functional programming: LISP Originally developed for symbolic computing First interactive, interpreted language Dynamic typing: values have types, variables.
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 Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Dr. Muhammed Al-Mulhem ICS An Introduction to Functional Programming.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
1 Lisp and Functional Languages Functional forms Referential transparency Function construction Function composition Mapping functions Designing functional.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Parallel & Concurrent Programming: Occam Vitaliy Lvin University of Massachusetts.
Copyright © 2009 Elsevier Chapter 10 :: Functional Languages Programming Language Pragmatics Michael L. Scott.
Functional Programing Referencing material from Programming Language Pragmatics – Third Edition – by Michael L. Scott Andy Balaam (Youtube.com/user/ajbalaam)
ICOM 5995: Performance Instrumentation and Visualization for High Performance Computer Systems Lecture 7 October 16, 2002 Nayda G. Santiago.
CS 403: Programming Languages Lecture 2 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
LISP – Not just a Speech Impediment Jim Lowe. Brief History of LISP Initial development begins at the Dartmouth Summer Research Project in 1956 by Dr.
1 Functional Programming In Text: Chapter Chapter 2: Evolution of the Major Programming Languages Outline Functional programming (FP) basics A bit.
CS 152: Programming Language Paradigms February 10 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Processes & Threads Emery Berger and Mark Corner University.
Functional Programming Languages Chapter 14
CS 403: Programming Languages Lecture 6 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
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 Performance of Work Stealing in Multiprogrammed Environments Matthew Hertz Department.
CMSC 330: Organization of Programming Languages
SCHEME Scheme is elegant, clear, small, and powerful programming language. It is a dialect of LISP and can be classified as a semi-functional programming.
Evaluating Python as an Introductory Programming Language A. Thomas and H.L. Liang UNISA.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Fortress John Burgess and Richard Chang CS691W University of Massachusetts Amherst.
ISBN Chapter 15 Functional Programming Languages.
Principles of Programming Languages Lecture 1 Slides by Yaron Gonen, based on slides by Daniel Deutch and lecture notes by Prof. Mira Balaban.
CS535 Programming Languages Chapter - 10 Functional Programming With Lists.
1 Alex Proctor and Brian Lee for CSCI 431 at UNCA, Fall 2002 ML (Meta Language) a brief introduction Alex Proctor and Brian Lee For CSCI 431 at the University.
1-1 An Introduction to Functional Programming Sept
Scheme Profs Tim Sheard and Andrew Black CS 311 Computational Structures.
Types and Programming Languages Lecture 11 Simon Gay Department of Computing Science University of Glasgow 2006/07.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Synchronization Emery Berger and Mark Corner University.
Semantic Analysis II Type Checking EECS 483 – Lecture 12 University of Michigan Wednesday, October 18, 2006.
Functional Programming IN NON-FUNCTIONAL LANGUAGES.
Interpreters and Higher-Order Functions CSE 413 Autumn 2008 Credit: CSE341 notes by Dan Grossman.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science John Cavazos J Eliot B Moss Architecture and Language Implementation Lab University.
CS 152: Programming Language Paradigms April 7 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
Language Paradigms CS655.
Xs Lisp ● xs is a lisp interpreter running on the brickOS firmware on the RCX brick.
CS314 – Section 5 Recitation 9
Functional Programming
Functional Programming Languages
Functional Programming
Closures and Streams cs784(Prasad) L11Clos
Lisp, Then and Now.
Closures and Streams cs7100(Prasad) L11Clos
Presentation transcript:

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Multilisp: Concurrent Functional Programming Ed Walters and Tim Richards University of Massachusetts Amherst

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 2 Overview What is Multilisp? Overview of Scheme Features of Multilisp Where is Multilisp Now?

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 3 Overview What is Multilisp? Overview of Scheme Features of Multilisp Where is Multilisp Now?

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 4 What is Multilisp? Dialect of Scheme language Functional Programming Limited Side-effects Garbage Collection Extensions for Concurrency Parallel Function Application Futures Reference: R. Halstead, TOPLAS, Vol. 7, No. 4, 1985.

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 5 Goal of Multilisp Explicit Constructs for Concurrency Adhere to Scheme Philosophy No Additional Syntax Minimal Additional Semantics Maximum Flexibility Granularity Backwards-compatibility

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 6 Overview What is Multilisp? Overview of Scheme Features of Multilisp Where is Multilisp Now?

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 7 The Scheme Language Descendent of Lisp (LISt Processing) Created by Steele and Sussman (1975) Important Features: Extended Lambda Calculus Lexical Scoping Functions are first-class

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 8 Important Terms Expression: Basic unit of Scheme code (e.g., List or integer) Evaluation: Scheme expressions evaluate to a value upon execution Application: Function call on a list, i.e. apply first element to rest of list (f a b c) => f(a, b, c)

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 9 Brief Scheme Syntax Function definition (define f (lambda (x) … )) Function application (f x) Conditionals (if x y z) Symbols and Atomic Elements ‘x, 3

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 10 Scheme Example: Fib (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (fib (- x 1)) (fib (- x 2))))))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 11 Scheme Example: Fib (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (fib (- x 1)) (fib (- x 2))))))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 12 Scheme Example: Fib (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (fib (- x 1)) (fib (- x 2))))))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 13 Scheme Example: Fib (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (fib (- x 1)) (fib (- x 2))))))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 14 Scheme Example: Fib (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (fib (- x 1)) (fib (- x 2))))))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 15 Scheme Example: Fib (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (fib (- x 1)) (fib (- x 2))))))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 16 Scheme Example: Fib (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (fib (- x 1)) (fib (- x 2))))))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 17 Overview What is Multilisp? Overview of Scheme Features of Multilisp Where is Multilisp Now?

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 18 Parallel Calls pcall : Parallel function application Syntax: (pcall F A B C) Semantics: Evaluate F, A, B, C in parallel Apply F to A, B, C (F A B C)

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 19 Parallel Calls: Example (define div-and-conq (lambda (x) (if (base-case x) x (pcall combine-results (div-and-conq (- x 1)) (div-and-conq (- x 5))))))

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 20 Parallel Calls: Example (define div-and-conq (lambda (x) (if (base-case x) x (pcall combine-results (div-and-conq (- x 1)) (div-and-conq (- x 5))))))

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 21 Parallel Calls: Example (define div-and-conq (lambda (x) (if (base-case x) x (pcall combine-results (div-and-conq (- x 1)) (div-and-conq (- x 5))))))

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 22 Parallel Calls: Example (define div-and-conq (lambda (x) (if (base-case x) x (pcall combine-results (div-and-conq (- x 1)) (div-and-conq (- x 5))))))

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 23 Parallel Calls: Example (define div-and-conq (lambda (x) (if (base-case x) x (pcall combine-results (div-and-conq (- x 1)) (div-and-conq (- x 5))))))

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 24 Futures future: contract to deliver parallel computation Syntax: (future ) Semantics: Evaluate concurrently with calling program Return reference to future immediately Block if value of is required

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 25 Futures: Example (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (future (fib (- x 1))) (future (fib (- x 2)))) )))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 26 Futures: Example (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (future (fib (- x 1))) (future (fib (- x 2)))) )))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 27 Futures: Example (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (future (fib (- x 1))) (future (fib (- x 2)))) )))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 28 Futures: Example (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (future (fib (- x 1))) (future (fib (- x 2)))) )))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 29 Futures: Example (define fib (lambda (x) (if (= x 1) 1 (if (= x 2) 2 (+ (future (fib (- x 1))) (future (fib (- x 2)))) )))) (fib 10) => 89

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 30 More Details pcall can be implemented using future Facilitates multiple concurrent programming paradigms: Cilk-style Message Passing Futures somewhat resemble Lazy Evaluation Evaluation delayed but guaranteed No infinite data structures

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 31 Implementation Notes Each future / pcall element is a thread pcall fork/join parallelism future asynchronous thread block on read

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 32 Overview What is Multilisp? Overview of Scheme Features of Multilisp Where is Multilisp Now?

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 33 Where is Multilisp Now? No current Scheme compilers implement futures We had to implement our own interpreter! However: THEY LIVE on in Java! Transparent Proxies for Java Futures, Pratikakis, Spacco, and Hicks, OOPSLA Safe Futures for Java, Welc, Jagannathan, and Hosking, OOPSLA 2005.

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 34 Conclusion Like much of the Scheme World: Elegant, Flexible Solution Deader than a Doornail Not Java