Advanced Shared-Memory Programming
|
|
- Fay Perkins
- 5 years ago
- Views:
Transcription
1 Advanced Shared-Memory Programming Parallel Programming Concepts Winter Term 2013 / 2014 Dr. Peter Tröger, M.Sc. Frank Feinbube
2 Shared-Memory Parallelism 2 Libraries and language extensions for standard languages OpenMP for C / C++ Java /.NET concurrency functionality Cilk derivate of C++ Different levels of abstractions Process model, thread model, task model Specialized programming languages for NUMA systems: Partitioned Global Address Space (PGAS)... for computational applications: Fortran / HPF... for implicit parallelism: Functional languages Profiling
3 PGAS Languages 3 Typically, the developer is shielded from memory hierarchy aspects through the operating system (PRAM thinking) Partitioned global address space (PGAS) approach Driven by high-performance computing community Modern approach for large-scale NUMA Precondition for Exascale computing Explicit notion of memory partition per processor Data is designated as local (near) or global (possibly far) Programmer is aware of NUMA nodes and can handle data and task placement explicitly Only way to allow performance optimization in systems with deep memory hierarchies
4 PGAS Libraries 4 PGAS languages Unified Parallel C (Ansi C) Co-Array Fortran / Fortress (F90) Titanium (Java), Chapel (Cray), X10 (IBM), All research, no wide-spread solution on industry level Core data management functionality can be re-used as library Global-Address Space Networking (GASNet) Used by many PGAS languages - UPC, Co-Array Fortran, Titanium, Chapel Aggregate Remote Memory Copy Interface (ARMCI) Blocking / non-blocking API, MPI compatibility Kernel Lattice Parallelism (KeLP) C++ class framework based on MPI
5 Unified Parallel C (UPC) 5 Extension of C for HPC on large-scale supercomputers Initiative started 1996 at the University of Berkeley Meanwhile consortium for language specification Latest language specification v1.3 from 2013 Extension of ISO C 99 with An explicitly parallel execution model An explicit shared memory consistency model Synchronization primitives Memory management primitives Support for major HPC platforms (Tru64, HP-UX, Cray, Altix, ) Support from commercial debuggers
6 Unified Parallel C (UPC) 6 Execution environment Each UPC program consists of a set of threads SPMD execution of UPC threads with flexible placement Threads may allocate shared and private data Access to this data can be local or shared Shared access can be strict or relaxed with respect to memory consistency Strict-only access to variables leads to sequential consistency Relaxed operations are finished before a strict operation
7 Unified Parallel C 7 Data is by default private, exists as copy per thread New data type qualifier shared for shared thread data Shared data has affinity for a particular UPC thread Primitive / pointer / aggregates: Affinity with UPC thread 0 Array type: cyclic affinity per element, block-cyclic affinity, partitioning Pointers to shared data consist of thread ID, local address, and position #include <upc_relaxed.h> #define N 100*THREADS shared int v1[n], v2[n], v1plusv2[n]; void main() { int i; for(i=0; i<n; i++) if (MYTHREAD==i%THREADS) v1plusv2[i]=v1[i]+v2[i]; }
8 Unified Parallel C 8 shared int A[100] Distributes array cyclically across all thread memories shared [B] int A[100] Distributes chunks of size B across all threads shared [*] int A[100] Position all array elements in thread 0 Explicit synchronization primitives upc_lock, upc_unlock, upc_lock_attempt, upc_lock_t upc_barrier, upc_notify, upc_wait Collective operations (upc_all_broadcast)
9 Unified Parallel C 9 Each memory reference / statement can be annotated Strict modifier: Sequential consistency (references from the same thread are in order) Relaxed modifier: Issuing thread sees sequential consistency, no other guarantees Manual optimization still needed, but data management is encapsulated in abstract keywords
10 Unified Parallel C 10 Loop parallelization with upc_forall Assignment of field elements to threads must be done explicitly with fourth parameter Identify thread by shared pointer Distribute in round-robin fashion according to fixed number Block-wise assignment shared int a[100], b[100], c[100]; int i; upc_forall(i=0; i<100; i++; &a[i]) a[i]=b[i]*c[i]; upc_forall(i=0; i<100; i++; i) a[i]=b[i]*c[i]; upc_forall(i=0; i<100; i++; (i*threads)/100) a[i]=b[i]*c[i];
11 X10 11 Parallel object-oriented PGAS language by IBM Java derivate, compiles to C++ or pure Java code Different binaries can interact through common runtime X86 and Power support Transport: Shared memory, TCP/IP, MPI, CUDA, Linux, MacOS X, Windows, AIX Full developer support with Eclipse environment Fork-join execution model, instead of SPMD as in MPI One application instance runs at a fixed number of places Each place has a private copy of static variables main() method runs automatically at place 0 Each place typically represents a NUMA node
12 X10 12 Local Heap Global Reference Local Heap Activities Activities Place 0 Place N Parallel tasks, each operating in one place of the PGAS Direct variable access only in local place of the global space Tasks mapped to places, potentially on different machines Implementation One operating system process per place, manages thread pool Work-stealing scheduler, queue with pending async s
13 X10 13 Local Heap Global Reference Local Heap Activities Activities Place 0 Place N async S Creates a new task that executes S, returns immediately S may reference all variables in the enclosing block finish S Execute S and wait for all transitively spawned tasks (barrier) If one task throws an exception, all others are finished first
14 Example 14 public class Fib {! public static def fib(n:int) {! if (n<=2) return 1;! val f1:int;! val f2:int;! finish {! async { f1 = fib(n-1); }! f2 = fib(n-2);! }! return f1 + f2;! }!! public static def main(args:array[string](1)) {! val n = (args.size > 0)? int.parse(args(0)) : 10;! Console.OUT.println("Computing Fib("+n+")");! val f = fib(n);! Console.OUT.println("Fib("+n+") = "+f);! }! }!
15 X10 15 Local Heap Global Reference Local Heap Activities Activities Place 0 Place N atomic S Execute S atomically, with respect to all other atomic blocks S must not create concurrency, access only local data when(c) S Suspend current task until c, then execute S atomically
16 Example 16 class Buffer[T]{T isref,t haszero} { protected var datum:t = null; class Account { public var value:int; def transfer(src:account, v:int) { atomic { src.value -= v; this.value += v; } } } public def send(v:t){v!=null} { when(datum == null) { datum = v; } } public def receive() { when(datum!= null) { val v = datum; datum = null; return v; } } }
17 Tasks Can Move 17 Local Heap Global Reference Local Heap Activities Activities Place 0 Place N at(p) S Execute statement S at place p, block current task at(p) e Evaluate expression e at place p and return the result at(p) async S Create new task at p to run S, return immediately
18 Example 18 class HelloWholeWorld { public static def main(args:rail[string]) { finish for(p in Place.places()) at(p) async Console.OUT.println(p + says + args(0)); Console.OUT.println( Bye ); } } $ x10c++ HelloWholeWorld.x10 $ X10_NPLACES=4./a.out hello Place(0) says hello Place(2) says hello Place(3) says hello Place(1) says hello Bye
19 X10 Object Model 19 Object live in a single place Tasks shift their place, not objects Bring the work to the data, not the other way around Global references can be created and used explicitely val ref:globalref[rail[int]] = GlobalRef(rail); at transparently copies the reachable object graph Compiler identifies reachable parts of the object graph Runtime copies the neccessary data Global references are serialized, not the content Special support for arrays as non-reference type
20 X10 Example: Parallel Sum 20 public class ParaSum {! public static def main(argv:rail[string]!) {! val id = (i:int) => i; // integer identity function! x10.io.console.out.println("sum(i=1..10)i = " + sum(id, 1, 10));! val sq = (i:int) => i*i; // integer square function, inline def. used instead! x10.io.console.out.println("sum(i=1..10)i*i = " + sum((i:int)=>i*i, 1, 10)); }!! public static def sum(f: (Int)=>Int, a:int, b:int):int {! val s = Rail.make[Int](1);! s(0) = 0;! finish {! for(p in Place.places) {! async{ // Spawn async at each place to compute its local range!! val ppartialsum = at(p) sumforplace(f, a, b);! atomic { s(0) += ppartialsum; } // add partial sums! }}}! return s(0) } // return total sum! private static def sumforplace(f: (Int)=>Int, a:int, b:int) {! var accum : Int = 0;! // each processor p of K computes f(a+p.id), f(a+p.id+k), f(a+p.id+2k), etc.! for(var i : Int = here.id + a; i <= b; i += Place.places.length {! accum += f(i); }! return accum;! }}!
21 Fortran 21 Programming language for scientific computing Developed in the 1950 s by IBM FORTRAN 66: First ANSI-standardized version FORTRAN 77: Structured Programming FORTRAN 90: Modular Programming, Array Operations FORTRAN 03: Object-Oriented Programming FORTRAN 08: Concurrent Programming Primary language in high-performance computing [Wikipedia]
22 Fortran 22 [Wikipedia] Array operation
23 High-Performance Fortran (HPF) 23 High-Performance Fortran as Fortran 95 extension Minimal set of extensions for classical Fortran language Data-parallel programming model Expression of parallelism, data distribution and alignment!hpf$ TEMPLATE!HPF$ PROCESSORS data objects!hpf$ ALIGN template!hpf$ DISTRIBUTE abstract processors with grid topology implementation dependent grid mapping physical processors with arbitrary topology Two-level mapping of data objects to abstract processors Array elements are aligned with template structure Template elements are distributed to abstract processors
24 High-Performance Fortran (HPF) 24 PROCESSOR directive Declare rectangular processor arrangement Defined by number of dimensions and extend per direction Final mapping (abstract -> physical) is not part of HPF TEMPLATE directive Template defined by number of dimensions and extends Abstract space of indexed positions Does not occupy memory at run-time Each data structure has a natural template Example: For array, index space that is identical
25 High-Performance Fortran (HPF) 25 HPF compiler directives as structured comments Hints for the compiler No change to the program semantics DISTRIBUTE directive Allows template to be distributed (BLOCK / CYCLIC) Any dimension of the template can be collapsed or replicated on a processor grid!hpf$ PROCESSORS P(4)!HPF$ TEMPLATE T(16)!HPF$ DISTRIBUTE T(BLOCK) ONTO P !HPF$ DISTRIBUTE T(BLOCK(5)) ONTO P !HPF$ DISTRIBUTE T(CYCLIC) ONTO P !HPF$ DISTRIBUTE T(CYCLIC(2)) ONTO P
26 High-Performance Fortran (HPF) 26 ALIGN directive TRANSPOSITION AND STRIDE SHIFT AND STRIDES Specify that some data objects should be mapped as others Intention to optimize operations that act on both Many options: shifts, strides, transposition of indices,... ALIGN and DISTRIBUTE are static data mappings REAL, DIMENSION(12,6) :: A!HPF$ TEMPLATE T(12,12)!HPF$ ALIGN A(I,J) WITH T(2*J-1,I) RELATIVE ALIGNMENT INTEGER, DIMENSION(4,4) :: B!HPF$ TEMPLATE T(12,12)!HPF$ ALIGN B(I,J) WITH T(2:12:3,1:12:3) COLLAPSE Part of subroutine declaration Dynamic versions at runtime REALIGN REDISTRIBUTE REAL, DIMENSION(8,8) :: C,D!HPF$ TEMPLATE T(12,12)!HPF$ ALIGN C(:,:) WITH T(:,:)!HPF$ ALIGN D(I,J) WITH T(I+5,J+5) REAL, DIMENSION(8,12) :: E!HPF$ TEMPLATE T(12)!HPF$ ALIGN(*.:) WITH T(:)
27 27 High-Performance Fortran (HPF)
28 HPF Data Parallelism 28 With parallel array assignments With FORALL statements FORALL(I=1:100,J=1:100) B(I,J)=1.0 FORALL(I=1:100,J=1:100) A(I,J)=B(I,J) FORALL(I=1: 98,J=3:100) A(I,J)=B(I+2,J-2) FORALL(I=1:100,J=1:100,B(I,J).GT.0) A(I,J)=2.*B(I,J) With INDEPENDENT directive Instruct compiler that instructions in the following FORALL statement have no data dependency With PURE functions Functions with syntactical restrictions to produce no sideeffects, mandatory in FORALL body With some of the intrinsic data functions
29 Declarative Programming 29.NET Language Integrated Query (LINQ) General purpose query facility, e.g. for databases or XML Declarative standard query operators var query = from p in products! where p.name.startswith("a")! orderby p.id! select p;!! foreach ( var p in query ) {! Console.WriteLine ( p.name );! }! PLINQ is parallelizing the execution of queries on objects and XML Declarative style of LINQ allows seamless transition to parallel version of the code IEnumerable<T> data =...; var q = data.where(x => p(x)).orderby(x => k(x)).select(x => f(x)); foreach (var e in q) a(e); IEnumerable<T> data =...; var q = data.asparallel().where(x => p(x)).orderby(x => k(x)).select(x => f(x)); foreach (var e in q) a(e);
30 Functional Programming 30 Programming paradigm that treats execution as function evaluation -> map some input to some output Contrary to imperative programming No longer focus on statement execution for state modification Programmer no longer specifies control flow explicitly High-level solution Side-effect free computation through avoidance of local state -> referential transparency (no demand for some control flow) Typically strong focus on immutable data as language default -> instead of altering values, return altered copy One foundation: Alonzo Church s lambda calculus from the 1930 s First functional language was Lisp (late 50s) Trend to add functional programming features into imperative languages (anonymous functions, fiter, map, )
31 Imperative to Functional 31 alert("i'd like some Spaghetti!");! alert("i'd like some Chocolate Moose!");! Optimize function SwedishChef( food )! {! alert("i'd like some " + food + "!");! }! SwedishChef("Spaghetti");! SwedishChef("Chocolate Moose");!! alert("get the lobster");! PutInPot("lobster");! PutInPot("water");! alert("get the chicken");! BoomBoom("chicken");! BoomBoom("coconut");! Optimize function Cook( i1, i2, f ) {! alert("get the " + i1);! f(i1); f(i2); }!! Cook( "lobster", "water", PutInPot);! Cook( "chicken", "coconut", BoomBoom):! Anonymous Function function Cook( i1, i2, f ) {! alert("get the " + i1);! f(i1); f(i2); }!! Cook( "lobster", "water",! function(x) { alert("pot " + x); } );! Cook( "chicken", "coconut",! function(x) { alert("boom " + x); } );!
32 Imperative to Functional 32 map() does not demand particular operation ordering var a = [1,2,3];! for (i=0; i<a.length; i++) {! a[i] = a[i] * 2;! }!! for (i=0; i<a.length; i++) {! alert(a[i]);! }! function map(fn, a)! {! for (i = 0; i < a.length; i++)! {! a[i] = fn(a[i]);! }! }! map( function(x){return x*2;}, a );! map( alert, a );!
33 Imperative to Functional 33 function sum(a) {! var s = 0;! for (i = 0; i < a.length; i++)! s += a[i];! return s;! }! function join(a) {! var s = "";! for (i = 0; i < a.length; i++)! s += a[i];! return s; }! alert(sum([1,2,3]));! alert(join(["a","b","c"]));! map() and reduce() functions do not demand particular operation ordering function reduce(fn, a, init){! var s = init;! for (i = 0; i < a.length; i++)! s = fn( s, a[i] );! return s;! }!! function sum(a){! return reduce( function(a, b){ return a + b; }, a, 0 );! }!! function join(a){! return reduce( function(a, b){ return a + b; }, a, "" );! }!
34 Imperative to Functional - Python 34 # Nested loop procedural style for finding big products xs = (1,2,3,4) ys = (10,15,3,22) bigmuls = [] for x in xs: for y in ys: if x*y > 25: bigmuls.append((x,y)) print bigmuls [David Merz] print [(x,y) for x in (1,2,3,4) for y in (10,15,3,22) if x*y > 25]
35 Functional Programming 35 Higher order functions: Functions as argument or return value Pure functions: No memory or I/O side effects If the result of a pure expression is not used, it can be removed A pure function called with side-effect free parameters has a constant result Without data dependencies, pure functions can run in parallel A language with only pure function semantic can change evaluation order Functions with side effects (e.g. printing) typically do not return results Recursion as replacement for looping (e.g. factorial) Lazy evaluation possible, e.g. to support infinite data structures Perfect foundation for implicit parallelism...
36 Functional Programming 36 Pure functions save state on the stack as function parameters But: Applications must have side effects The application task is to modify state Goal is to limit side-effects and to concentrate them Many popular new functional languages JVM-based: Clojure, Scala (parts of it) Common Lisp, Erlang, F#, Haskell, ML, Ocaml, Scheme
37 Clojure 37 Dynamically typed, functional programming language Derivation from Lisp Runs on JVM >= v5, allows Java interoperability Variations with backend for.net and JavaScript Major goal: Easier development of data-parallel applications Clojure operation: Function, macro, or special form Special forms are implemented by the compiler Typical keywords (new, throw, monitor-enter, if, let,...) Three ways of sharing mutable data in a safe way Refs: Coordinated access by software-transactional memory Atoms: Synchronized access to one data item Agents: Asychronous access to one data item
38 Clojure 38 (Function) Data
39 39 Clojure
40 Fortress (== Secure Fortran ) 40 Oracle / Sun Programming Language Research Group, Guy L. Steele (Scheme, Common Lisp, Java) Language designed for (mathematical) high-performance computing Dynamic compilation, type inference Growable language: Prefer library over compiler Mathematical notation Everything is an expression, some having void value (e.g. while, for, assignment) Source code can be rendered in ASCII, Unicode, or as image Functional programming concepts, but also Scala / Haskell derivations PT 2013
41 Fortress - Comparison to C 41 No memory management, all handled by runtime system Implicit instead of explicit threading Set of types similar to C library Fortress program state: Number of threads + memory Fortress program execution: Evaluation of expressions in all threads Component model supported, interfaces can be imported and exported Components live in the,fortress database, interaction through shell
42 Fortress Syntax 42 Adopt math whenever possible Integer, naturals, rationals, complex number, floating point Support for units and dimensions Everything is an expression, () is the void value Statements are void-type expressions (while, for, assignment, binding) Some statements have non-() values (if, do, try, case, spawn,...) if x 0 then x else -x end atomic x := max(x, y[k]) Generators: j:k - range, j#n - n consecutive integers from j,...
43 Fortress Basics 43 Object: Fields and methods Traits: Set of abstract / concrete methods (extended interface concept) Every object extends a set of traits trait Boolean extends BooleanAlgebra Boolean,,,,,false,true comprises { true, false } opr (self, other: Boolean): Boolean opr (self, other: Boolean): Boolean opr (self): Boolean end object true extends Boolean opr (self, other: Boolean) = other opr (self, other: Boolean) = self opr (self) = false end...
44 Fortress - Functions 44 Functions Static (nat or int) parameters One variable parameter Optional return value Optional body expression Result comes from evaluation of the body do-end expression: Sequence of expressions with implicit parallel execution, last defining the blocks result Supports also do syntax for explicit parallelism do factorial (10) also do factorial (5) also do factorial (2) end
45 Fortress - Parallelism 45 Parallel programming as necessary compromise, not as primary goal Implicit parallelism wherever possible, supported by functional approach Evaluated in parallel: function / method arguments, operator operands, tuple expressions (each element evaluated separately), loop iterations, sums Loop iterations are parallelized Generators generate values in parallel, called functions run in parallel Race condition handling through atomic keyword, explicit spawn keyword for i <- 1:5 do print(i ) print(i ) end for i <- sequential(1:5) do print(i ) print(i ) end
46 Asynchronous Programming? 46 Huge hype around asynchronous programming A model to implement I/O concurrency Explicit avoidance of any threading overhead Focus on fast context switch between many activities Often implemented by event-driven programming style Activities perform callback when they are done Whole API modeled around this idea JavaScript, Node.JS, Python Twisted, Mostly based on libevent wrapper library for /dev/poll, kqueue, epoll, Mainly targets the problem of blocking code on I/O activity No standalone solution for speedup, but helps with scaling
47 Profiling 47 Many available profiling tools for shared-memory parallelism Sampling profiler Sporadic recording of application state Time-driven: Uniform time period between samples Event-driven: Uniform event number between samples Original code remains unchanged Small impact on execution behavior, can find race conditions Low overhead (hardware-based ~ 2%, software-based ~ 5%) Instrumenting profiler Modification of original application with measurement code Allows gathering of all possible events Higher accuracy than sampling, but also higher overhead Data gathering is one part, vizualisation a different one
48 Intel VTune 48 Commercial profiling tool, for command-line or GUI Plugins for Eclipse and Visual Studio Support for Fortran, C, C++, Java,.NET, Assembly Linux and Windows Standard features Hotspot analysis where is the most time spent? Concurrency analysis are all cores well utilized? Lock analysis which locks are hot? User-mode sampling Sampling library is dynamically attached via LD_PRELOAD Set up timer per thread, then issue signal and take sample Hardware-event based sampling
49 Performance Monitoring Unit 49 one PMU per core one PMU in uncore region elapsed cycles L1, L2 cache events processed instructions uncore bound QPI events L3 cache events memory controller events
50 Example 50 Hotspot Analysis (Whetstone) Top-Down View (Call Tree) Bottom-Up View
51 51 Example
52 52 Example
53 53 Example
Shared-Memory Programming Models
Shared-Memory Programming Models Parallel Programming Concepts Winter Term 2013 / 2014 Dr. Peter Tröger, M.Sc. Frank Feinbube Cilk C language combined with several new keywords Different approach to OpenMP
More informationRationale for Map-Reduce
Rationale for Map-Reduce Map-reduce idea: An Example (part 1) This example uses JavaScript. // A trivial example: alert("i d like some Spaghetti!"); alert("i d like some Chocolate Moose!"); The above can
More informationLecture 32: Partitioned Global Address Space (PGAS) programming models
COMP 322: Fundamentals of Parallel Programming Lecture 32: Partitioned Global Address Space (PGAS) programming models Zoran Budimlić and Mack Joyner {zoran, mjoyner}@rice.edu http://comp322.rice.edu COMP
More informationUnified Parallel C (UPC)
Unified Parallel C (UPC) Vivek Sarkar Department of Computer Science Rice University vsarkar@cs.rice.edu COMP 422 Lecture 21 March 27, 2008 Acknowledgments Supercomputing 2007 tutorial on Programming using
More informationNew Programming Paradigms: Partitioned Global Address Space Languages
Raul E. Silvera -- IBM Canada Lab rauls@ca.ibm.com ECMWF Briefing - April 2010 New Programming Paradigms: Partitioned Global Address Space Languages 2009 IBM Corporation Outline Overview of the PGAS programming
More informationChapel Introduction and
Lecture 24 Chapel Introduction and Overview of X10 and Fortress John Cavazos Dept of Computer & Information Sciences University of Delaware www.cis.udel.edu/~cavazos/cisc879 But before that Created a simple
More informationA Comparison of Unified Parallel C, Titanium and Co-Array Fortran. The purpose of this paper is to compare Unified Parallel C, Titanium and Co-
Shaun Lindsay CS425 A Comparison of Unified Parallel C, Titanium and Co-Array Fortran The purpose of this paper is to compare Unified Parallel C, Titanium and Co- Array Fortran s methods of parallelism
More informationCMSC 714 Lecture 4 OpenMP and UPC. Chau-Wen Tseng (from A. Sussman)
CMSC 714 Lecture 4 OpenMP and UPC Chau-Wen Tseng (from A. Sussman) Programming Model Overview Message passing (MPI, PVM) Separate address spaces Explicit messages to access shared data Send / receive (MPI
More informationCS 470 Spring Parallel Languages. Mike Lam, Professor
CS 470 Spring 2017 Mike Lam, Professor Parallel Languages Graphics and content taken from the following: http://dl.acm.org/citation.cfm?id=2716320 http://chapel.cray.com/papers/briefoverviewchapel.pdf
More informationDistributed Shared Memory for High-Performance Computing
Distributed Shared Memory for High-Performance Computing Stéphane Zuckerman Haitao Wei Guang R. Gao Computer Architecture & Parallel Systems Laboratory Electrical & Computer Engineering Dept. University
More informationParallel Programming Languages. HPC Fall 2010 Prof. Robert van Engelen
Parallel Programming Languages HPC Fall 2010 Prof. Robert van Engelen Overview Partitioned Global Address Space (PGAS) A selection of PGAS parallel programming languages CAF UPC Further reading HPC Fall
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing
More informationAbstract. Negative tests: These tests are to determine the error detection capabilities of a UPC compiler implementation.
UPC Compilers Testing Strategy v1.03 pre Tarek El-Ghazawi, Sébastien Chauvi, Onur Filiz, Veysel Baydogan, Proshanta Saha George Washington University 14 March 2003 Abstract The purpose of this effort is
More informationCOP4020 Programming Languages. Functional Programming Prof. Robert van Engelen
COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts
More informationDesign Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8
Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns
More informationFunctional Programming. Big Picture. Design of Programming Languages
Functional Programming Big Picture What we ve learned so far: Imperative Programming Languages Variables, binding, scoping, reference environment, etc What s next: Functional Programming Languages Semantics
More informationSeminar on Languages for Scientific Computing Aachen, 6 Feb Navid Abbaszadeh.
Scientific Computing Aachen, 6 Feb 2014 navid.abbaszadeh@rwth-aachen.de Overview Trends Introduction Paradigms, Data Structures, Syntax Compilation & Execution Concurrency Model Reference Types Performance
More informationThe APGAS Programming Model for Heterogeneous Architectures. David E. Hudak, Ph.D. Program Director for HPC Engineering
The APGAS Programming Model for Heterogeneous Architectures David E. Hudak, Ph.D. Program Director for HPC Engineering dhudak@osc.edu Overview Heterogeneous architectures and their software challenges
More informationScala, Your Next Programming Language
Scala, Your Next Programming Language (or if it is good enough for Twitter, it is good enough for me) WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that
More informationIntroduction to High Performance Computing and X10
Introduction to High Performance Computing and X10 Special Topic For Comp 621 Vineet Kumar High Performance Computing Supercomputing Grid computers, Multi-cores, clusters massively parallel computing Used
More informationTitanium. Titanium and Java Parallelism. Java: A Cleaner C++ Java Objects. Java Object Example. Immutable Classes in Titanium
Titanium Titanium and Java Parallelism Arvind Krishnamurthy Fall 2004 Take the best features of threads and MPI (just like Split-C) global address space like threads (ease programming) SPMD parallelism
More informationCS 11 Haskell track: lecture 1
CS 11 Haskell track: lecture 1 This week: Introduction/motivation/pep talk Basics of Haskell Prerequisite Knowledge of basic functional programming e.g. Scheme, Ocaml, Erlang CS 1, CS 4 "permission of
More informationSteve Deitz Chapel project, Cray Inc.
Parallel Programming in Chapel LACSI 2006 October 18 th, 2006 Steve Deitz Chapel project, Cray Inc. Why is Parallel Programming Hard? Partitioning of data across processors Partitioning of tasks across
More informationModels and languages of concurrent computation
Models and languages of concurrent computation Lecture 11 of TDA383/DIT390 (Concurrent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2016/2017 Today s menu
More informationA Local-View Array Library for Partitioned Global Address Space C++ Programs
Lawrence Berkeley National Laboratory A Local-View Array Library for Partitioned Global Address Space C++ Programs Amir Kamil, Yili Zheng, and Katherine Yelick Lawrence Berkeley Lab Berkeley, CA, USA June
More informationFunctional Programming and Haskell
Functional Programming and Haskell Tim Dawborn University of Sydney, Australia School of Information Technologies Tim Dawborn Functional Programming and Haskell 1/22 What are Programming Paradigms? A programming
More informationCPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia
CPL 2016, week 10 Clojure functional core Oleg Batrashev Institute of Computer Science, Tartu, Estonia April 11, 2016 Overview Today Clojure language core Next weeks Immutable data structures Clojure simple
More informationParallel Programming with OpenMP. CS240A, T. Yang
Parallel Programming with OpenMP CS240A, T. Yang 1 A Programmer s View of OpenMP What is OpenMP? Open specification for Multi-Processing Standard API for defining multi-threaded shared-memory programs
More informationProgramming Languages Third Edition. Chapter 9 Control I Expressions and Statements
Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE
More informationWritten Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming
Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Nicolas Bettenburg 1 Universitaet des Saarlandes, D-66041 Saarbruecken, nicbet@studcs.uni-sb.de Abstract. As traditional
More informationUnified Parallel C, UPC
Unified Parallel C, UPC Jarmo Rantakokko Parallel Programming Models MPI Pthreads OpenMP UPC Different w.r.t. Performance/Portability/Productivity 1 Partitioned Global Address Space, PGAS Thread 0 Thread
More informationCSC312 Principles of Programming Languages : Functional Programming Language. Copyright 2006 The McGraw-Hill Companies, Inc.
CSC312 Principles of Programming Languages : Functional Programming Language Overview of Functional Languages They emerged in the 1960 s with Lisp Functional programming mirrors mathematical functions:
More informationCOMP Parallel Computing. SMM (2) OpenMP Programming Model
COMP 633 - Parallel Computing Lecture 7 September 12, 2017 SMM (2) OpenMP Programming Model Reading for next time look through sections 7-9 of the Open MP tutorial Topics OpenMP shared-memory parallel
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationIntroduce C# as Object Oriented programming language. Explain, tokens,
Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation
More informationFunctional Languages. CSE 307 Principles of Programming Languages Stony Brook University
Functional Languages CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Historical Origins 2 The imperative and functional models grew out of work
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationChapter 11 :: Functional Languages
Chapter 11 :: Functional Languages Programming Language Pragmatics Michael L. Scott Copyright 2016 Elsevier 1 Chapter11_Functional_Languages_4e - Tue November 21, 2017 Historical Origins The imperative
More informationScala : an LLVM-targeted Scala compiler
Scala : an LLVM-targeted Scala compiler Da Liu, UNI: dl2997 Contents 1 Background 1 2 Introduction 1 3 Project Design 1 4 Language Prototype Features 2 4.1 Language Features........................................
More informationSD314 Outils pour le Big Data
Institut Supérieur de l Aéronautique et de l Espace SD314 Outils pour le Big Data Functional programming in Python Christophe Garion DISC ISAE Christophe Garion SD314 Outils pour le Big Data 1/ 35 License
More informationConcepts of Programming Languages
Concepts of Programming Languages Lecture 15 - Functional Programming Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages
More informationAllows program to be incrementally parallelized
Basic OpenMP What is OpenMP An open standard for shared memory programming in C/C+ + and Fortran supported by Intel, Gnu, Microsoft, Apple, IBM, HP and others Compiler directives and library support OpenMP
More informationINF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors.
INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION Instructors: Crista Lopes Copyright Instructors. Topics Recursion Higher-order functions Continuation-Passing Style Monads (take 1) Identity Monad Maybe
More informationParallel Programming. March 15,
Parallel Programming March 15, 2010 1 Some Definitions Computational Models and Models of Computation real world system domain model - mathematical - organizational -... computational model March 15, 2010
More informationParallel Programming with Coarray Fortran
Parallel Programming with Coarray Fortran SC10 Tutorial, November 15 th 2010 David Henty, Alan Simpson (EPCC) Harvey Richardson, Bill Long, Nathan Wichmann (Cray) Tutorial Overview The Fortran Programming
More informationCMSC330. Objects, Functional Programming, and lambda calculus
CMSC330 Objects, Functional Programming, and lambda calculus 1 OOP vs. FP Object-oriented programming (OOP) Computation as interactions between objects Objects encapsulate mutable data (state) Accessed
More informationMPI and OpenMP (Lecture 25, cs262a) Ion Stoica, UC Berkeley November 19, 2016
MPI and OpenMP (Lecture 25, cs262a) Ion Stoica, UC Berkeley November 19, 2016 Message passing vs. Shared memory Client Client Client Client send(msg) recv(msg) send(msg) recv(msg) MSG MSG MSG IPC Shared
More informationCSCE 314 Programming Languages
CSCE 314 Programming Languages Haskell 101 Dr. Hyunyoung Lee 1 Contents 1. Historical Background of Haskell 2. Lazy, Pure, and Functional Language 3. Using ghc and ghci 4. Functions 5. Haskell Scripts
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter
More informationWeeks 6&7: Procedures and Parameter Passing
CS320 Principles of Programming Languages Weeks 6&7: Procedures and Parameter Passing Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Weeks 6&7: Procedures and Parameter Passing 1 / 45
More informationClosures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming
Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Summary 1. Predictive Parsing 2. Large Step Operational Semantics (Natural) 3. Small Step Operational Semantics
More informationCSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Basics
1 CSCE 314: Programming Languages Dr. Flemming Andersen Haskell Basics 2 Contents 1. Jump into Haskell: Using ghc and ghci (more detail) 2. Historical Background of Haskell 3. Lazy, Pure, and Functional
More informationProgrammiersprachen (Programming Languages)
2016-05-13 Preface Programmiersprachen (Programming Languages) coordinates: lecturer: web: usable for: requirements: No. 185.208, VU, 3 ECTS Franz Puntigam http://www.complang.tuwien.ac.at/franz/ps.html
More informationOrganization of Programming Languages CS3200/5200N. Lecture 11
Organization of Programming Languages CS3200/5200N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Functional vs. Imperative The design of the imperative languages
More informationG Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 6 Robert Grimm, New York University 1 Review Last week Function Languages Lambda Calculus SCHEME review 2 Outline Promises, promises, promises Types,
More informationTable of Contents. Cilk
Table of Contents 212 Introduction to Parallelism Introduction to Programming Models Shared Memory Programming Message Passing Programming Shared Memory Models Cilk TBB HPF Chapel Fortress Stapl PGAS Languages
More informationFirst Programming Language in CS Education The Arguments for Scala
First Programming Language in CS Education The Arguments for Scala WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that is under contract with CRC Press.
More informationOverview: Emerging Parallel Programming Models
Overview: Emerging Parallel Programming Models the partitioned global address space paradigm the HPCS initiative; basic idea of PGAS the Chapel language: design principles, task and data parallelism, sum
More informationTrends and Challenges in Multicore Programming
Trends and Challenges in Multicore Programming Eva Burrows Bergen Language Design Laboratory (BLDL) Department of Informatics, University of Bergen Bergen, March 17, 2010 Outline The Roadmap of Multicores
More informationLecture content. Course goals. Course Introduction. TDDA69 Data and Program Structure Introduction
Lecture content TDDA69 Data and Program Structure Introduction Cyrille Berger Course Introduction to the different Programming Paradigm The different programming paradigm Why different paradigms? Introduction
More informationLecture 8: Summary of Haskell course + Type Level Programming
Lecture 8: Summary of Haskell course + Type Level Programming Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense October 31, 2017 Principles from Haskell
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationOverview: The OpenMP Programming Model
Overview: The OpenMP Programming Model motivation and overview the parallel directive: clauses, equivalent pthread code, examples the for directive and scheduling of loop iterations Pi example in OpenMP
More informationLECTURE 16. Functional Programming
LECTURE 16 Functional Programming WHAT IS FUNCTIONAL PROGRAMMING? Functional programming defines the outputs of a program as a mathematical function of the inputs. Functional programming is a declarative
More informationConcurrency: what, why, how
Concurrency: what, why, how May 28, 2009 1 / 33 Lecture about everything and nothing Explain basic idea (pseudo) vs. Give reasons for using Present briefly different classifications approaches models and
More information1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.
1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered
More informationProgramming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI
Programming Kotlin Familiarize yourself with all of Kotlin s features with this in-depth guide Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Copyright 2017 Packt Publishing First
More informationIntroduction to OpenMP.
Introduction to OpenMP www.openmp.org Motivation Parallelize the following code using threads: for (i=0; i
More informationFunctional Programming Lecture 1: Introduction
Functional Programming Lecture 1: Introduction Viliam Lisý Artificial Intelligence Center Department of Computer Science FEE, Czech Technical University in Prague viliam.lisy@fel.cvut.cz Acknowledgements
More information.consulting.solutions.partnership. Clojure by Example. A practical introduction to Clojure on the JVM
.consulting.solutions.partnership Clojure by Example A practical introduction to Clojure on the JVM Clojure By Example 1 Functional Progamming Concepts 3 2 Clojure Basics 4 3 Clojure Examples 5 4 References
More informationJukka Julku Multicore programming: Low-level libraries. Outline. Processes and threads TBB MPI UPC. Examples
Multicore Jukka Julku 19.2.2009 1 2 3 4 5 6 Disclaimer There are several low-level, languages and directive based approaches But no silver bullets This presentation only covers some examples of them is
More informationTypes and Type Inference
CS 242 2012 Types and Type Inference Notes modified from John Mitchell and Kathleen Fisher Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on Web!! Outline General discussion of
More informationComputer Systems A Programmer s Perspective 1 (Beta Draft)
Computer Systems A Programmer s Perspective 1 (Beta Draft) Randal E. Bryant David R. O Hallaron August 1, 2001 1 Copyright c 2001, R. E. Bryant, D. R. O Hallaron. All rights reserved. 2 Contents Preface
More informationSemantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End
Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors
More informationChapter 7 Control I Expressions and Statements
Chapter 7 Control I Expressions and Statements Expressions Conditional Statements and Guards Loops and Variation on WHILE The GOTO Controversy Exception Handling Values and Effects Important Concepts in
More informationFunctional Programming. Pure Functional Programming
Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).
More informationTypes and Type Inference
Types and Type Inference Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on the course homepage Outline General discussion
More informationChapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.
Chapter 1 GETTING STARTED SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: Java platform. Applets and applications. Java programming language: facilities and foundation. Memory management
More informationClosures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming
Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming t ::= x x. t t t Call-by-value big-step Operational Semantics terms variable v ::= values abstraction x.
More informationProgramming Language Pragmatics
Chapter 10 :: Functional Languages Programming Language Pragmatics Michael L. Scott Historical Origins The imperative and functional models grew out of work undertaken Alan Turing, Alonzo Church, Stephen
More informationImplementing a Scalable Parallel Reduction in Unified Parallel C
Implementing a Scalable Parallel Reduction in Unified Parallel C Introduction A reduction is the process of combining elements of a vector (or array) to yield a single aggregate element. It is commonly
More informationParallel Programming Features in the Fortran Standard. Steve Lionel 12/4/2012
Parallel Programming Features in the Fortran Standard Steve Lionel 12/4/2012 Agenda Overview of popular parallelism methodologies FORALL a look back DO CONCURRENT Coarrays Fortran 2015 Q+A 12/5/2012 2
More informationCS 242. Fundamentals. Reading: See last slide
CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language
More informationSurvey on High Productivity Computing Systems (HPCS) Languages
Survey on High Productivity Computing Systems (HPCS) Languages [Internal Report] Saliya Ekanayake School of Informatics and Computing, Indiana University sekanaya@cs.indiana.edu Abstract Parallel languages
More informationGeneral Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design
General Concepts Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design 1 Abstractions in Programming Languages Abstractions hide details that
More informationExecutive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads.
Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads. Poor co-ordination that exists in threads on JVM is bottleneck
More informationProgramming Systems in Artificial Intelligence Functional Programming
Click to add Text Programming Systems in Artificial Intelligence Functional Programming Siegfried Nijssen 8/03/16 Discover thediscover world at the Leiden world University at Leiden University Overview
More informationInformal Semantics of Data. semantic specification names (identifiers) attributes binding declarations scope rules visibility
Informal Semantics of Data semantic specification names (identifiers) attributes binding declarations scope rules visibility 1 Ways to Specify Semantics Standards Documents (Language Definition) Language
More informationCIS24 Project #3. Student Name: Chun Chung Cheung Course Section: SA Date: 4/28/2003 Professor: Kopec. Subject: Functional Programming Language (ML)
CIS24 Project #3 Student Name: Chun Chung Cheung Course Section: SA Date: 4/28/2003 Professor: Kopec Subject: Functional Programming Language (ML) 1 Introduction ML Programming Language Functional programming
More informationUvA-SARA High Performance Computing Course June Clemens Grelck, University of Amsterdam. Parallel Programming with Compiler Directives: OpenMP
Parallel Programming with Compiler Directives OpenMP Clemens Grelck University of Amsterdam UvA-SARA High Performance Computing Course June 2013 OpenMP at a Glance Loop Parallelization Scheduling Parallel
More informationTypes, Type Inference and Unification
Types, Type Inference and Unification Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Cornell CS 6110 Summary (Functional Programming) Lambda Calculus Basic ML Advanced ML: Modules, References,
More informationCom S 541. Programming Languages I
Programming Languages I Lecturer: TA: Markus Lumpe Department of Computer Science 113 Atanasoff Hall http://www.cs.iastate.edu/~lumpe/coms541.html TR 12:40-2, W 5 Pramod Bhanu Rama Rao Office hours: TR
More informationIntroduction to Standard OpenMP 3.1
Introduction to Standard OpenMP 3.1 Massimiliano Culpo - m.culpo@cineca.it Gian Franco Marras - g.marras@cineca.it CINECA - SuperComputing Applications and Innovation Department 1 / 59 Outline 1 Introduction
More informationPGAS Languages (Par//oned Global Address Space) Marc Snir
PGAS Languages (Par//oned Global Address Space) Marc Snir Goal Global address space is more convenient to users: OpenMP programs are simpler than MPI programs Languages such as OpenMP do not provide mechanisms
More informationOpenACC Course. Office Hour #2 Q&A
OpenACC Course Office Hour #2 Q&A Q1: How many threads does each GPU core have? A: GPU cores execute arithmetic instructions. Each core can execute one single precision floating point instruction per cycle
More informationImplementing X10. Towards Performance and Productivity at Scale. David Grove IBM Research NICTA Summer School February 5, 2013
Implementing X10 Towards Performance and Productivity at Scale http://x10-lang.org David Grove NICTA Summer School February 5, 2013 This material is based upon work supported in part by the Defense Advanced
More informationFunctional Programming Languages (FPL)
Functional Programming Languages (FPL) 1. Definitions... 2 2. Applications... 2 3. Examples... 3 4. FPL Characteristics:... 3 5. Lambda calculus (LC)... 4 6. Functions in FPLs... 7 7. Modern functional
More informationNotes from a Short Introductory Lecture on Scala (Based on Programming in Scala, 2nd Ed.)
Notes from a Short Introductory Lecture on Scala (Based on Programming in Scala, 2nd Ed.) David Haraburda January 30, 2013 1 Introduction Scala is a multi-paradigm language that runs on the JVM (is totally
More informationOpenMP I. Diego Fabregat-Traver and Prof. Paolo Bientinesi WS16/17. HPAC, RWTH Aachen
OpenMP I Diego Fabregat-Traver and Prof. Paolo Bientinesi HPAC, RWTH Aachen fabregat@aices.rwth-aachen.de WS16/17 OpenMP References Using OpenMP: Portable Shared Memory Parallel Programming. The MIT Press,
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Week 13 - Part 1 Thomas Wies New York University Review Last lecture Object Oriented Programming Outline Today: Scala Sources: Programming in Scala, Second
More information