Single Assignment C. Research by Sven Bodo Schulz and Clemens Grelk Single Assignment C: efficient support for high level array operations in a functional.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Etter/Ingber Arrays and Matrices. Etter/Ingber One-Dimensional Arrays 4 An array is an indexed data structure 4 All variables stored in an array are of.
Arrays.
C Language.
Semantic Analysis Chapter 6. Two Flavors  Static (done during compile time) –C –Ada  Dynamic (done during run time) –LISP –Smalltalk  Optimization.
Arrays, A1 COMP 401, Fall 2014 Lecture 4 8/28/2014.
GPU programming: CUDA Acknowledgement: the lecture materials are based on the materials in NVIDIA teaching center CUDA course materials, including materials.
Compiler Construction
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
Stanford University CS243 Winter 2006 Wei Li 1 Loop Transformations and Locality.
Encapsulation by Subprograms and Type Definitions
 2006 Pearson Education, Inc. All rights reserved Arrays.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Lecture 5 Arrays A way to organize data © MIT AITI 2003.
Chapter 8 Arrays and Strings
1 CMSC 132: Object-Oriented Programming II Java Constructs Department of Computer Science University of Maryland, College Park.
TODAY’S LECTURE Review Chapter 2 Go over exercises.
PARALLEL PROGRAMMING ABSTRACTIONS 6/16/2010 Parallel Programming Abstractions 1.
Java Basics Kris Secor Mobile Application Development.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
CIS Computer Programming Logic
 2006 Pearson Education, Inc. All rights reserved Arrays.
Haskell. 2 GHC and HUGS Haskell 98 is the current version of Haskell GHC (Glasgow Haskell Compiler, version 7.4.1) is the version of Haskell I am using.
Parallelizing Iterative Computation for Multiprocessor Architectures Peter Cappello.
GENERIC COLLECTIONS. Type-Wrapper Classes  Each primitive type has a corresponding type- wrapper class (in package java.lang).  These classes are called.
Arrays and ArrayLists in Java L. Kedigh. Array Characteristics List of values. A list of values where every member is of the same type. Each member in.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
JAVA 0. HAFTA Algorithms FOURTH EDITION Robert Sedgewick and Kevin Wayne Princeton University.
CS 584 Lecture 14 n Assignment –Program due now –Check the web »Create program model & do calculations »Additional calculation problems n Paper presentations.
The Powers of Array Programming AiPL – Edinburgh Sven-Bodo Scholz.
C Basics Computer Organization I 1 May 2010 © McQuain, Feng & Ribbens A History Lesson Development of language by Dennis Ritchie at Bell Labs.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
Introduction to Java Java Translation Program Structure
16. STRUCTURES, UNIONS, AND ENUMERATIONS. Declaring Structures A structure is a collection of one or more components (members), which may be of different.
1 Arrays and Vectors Chapter 7 Arrays and Vectors Chapter 7.
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Arrays.
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Arrays An array is an indexed data structure which is used to store data elements of the same data type. An array is an indexed data structure which is.
Module 1: Array ITEI222 - Advance Programming Language.
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
Data-Parallel Programming using SaC lecture 2 F21DP Distributed and Parallel Technology Sven-Bodo Scholz.
C Part 1 Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens A History Lesson Development of language by Dennis Ritchie at Bell.
Data-Parallel Programming using SaC lecture 1 F21DP Distributed and Parallel Technology Sven-Bodo Scholz.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
Data-Parallel Programming using SaC lecture 3 F21DP Distributed and Parallel Technology Sven-Bodo Scholz.
Loops. Review Control Structure – making decisions if-statement Program Design Understand what you want to do Design your solution Write and test your.
ENEE150 – 0102 ANDREW GOFFIN Abstract Data Types.
SaC – Functional Programming for HP 3 Chalmers Tekniska Högskola Sven-Bodo Scholz.
Java Programming Language Lecture27- An Introduction.
Information and Computer Sciences University of Hawaii, Manoa
The Machine Model Memory
Types CSCE 314 Spring 2016.
Java Primer 1: Types, Classes and Operators
Java for Android is specific
Haskell.
Conversions of the type of the value of an expression
Distributed System Gang Wu Spring,2018.
Introduction To Programming Information Technology , 1’st Semester
Object Oriented Programming in java
Compiler Construction
Java’s Central Casting
Compiler Construction
Presentation transcript:

Single Assignment C

Research by Sven Bodo Schulz and Clemens Grelk Single Assignment C: efficient support for high level array operations in a functional setting [Scholz] SAC – A Functional Array Language for Efficient Multi-threaded Execution [Grelk and Scholz] Accelerating APL Programs in SAC [Grelk and Scholz]

SAC Language Overview N-dimensional arrays as first-class entities – powerful primitives for array-oriented programming

SAC Language Overview N-dimensional arrays as first-class entities – powerful primitives for array-oriented programming Purely functional semantics + static types – Useful for implicit parallelism and aggressive optimizations

SAC Language Overview N-dimensional arrays as first-class entities – powerful primitives for array-oriented programming Purely functional semantics + static types – Useful for implicit parallelism and aggressive optimizations Curly braces syntax – don’t scare the “white belt programmer”

A First Look At SAC int foo(int v, int w) { r = v + w; r = r + 1; return (r); } It doesn’t look functional!

A First Look At SAC int foo(int v, int w) { r = v + w; // type of local variables inferred r = r + 1; return (r); } It doesn’t look functional!

A First Look At SAC int foo(int v, int w) { r = v + w; // type of local variables inferred r = r + 1; // re-assignment treated as implicit let return (r); } It doesn’t look functional!

A First Look At SAC int foo(int v, int w) { r = v + w; // type of local variables inferred r = r + 1; // re-assignment treated as implicit let return (r); } It doesn’t look functional! let foo (v:int) (w:int) : int = let r = v + w in let r = r + 1 in r

Let’s generalize to arrays… int[*] foo(int[*] v, int[*] w) { r = v + w; r = r + 1; return (r); }

Arrays in SAC Arrays can be scalars, vectors, matrices, etc… Arrays consist of two components: 1 2 = [1,2,3,4], [2,2] 34 data shape Specified using reshape(dims, data) ValueShapeRank 1[]0 [1,2][2]1 reshape([2,2],[1,2,3,4])[2,2]2

The Type System Primitive types of C – int, char, float, double, double, bool, etc… Hierarchy of array types bool[1,2] ≤ bool[.,.] ≤ bool[+] ≤ bool[*]

The Heart of Array Processing: with-loops We want a small core functionality for expressing shape-invariant array operations – Keeps the language elegant, and helps the optimizing compiler

The Heart of Array Processing: with-loops We want a small core functionality for expressing array operations – Keeps the language elegant, and helps the optimizing compiler SAC defines all array operations in terms of “with-loops” (sort of like an array comprehension)

genarray with-loop Specifies a mapping from indices to values: with index sets : values genarray (shape) with ([0,0] <= k < [1,1]): 7 default: 42 genarray([2,3]) 

modarray with-loop Duplicates old array’s values, with some specified modifications with index sets : values modarray (array) x = [1,2,3]; with ([0] <= k < [2]): 7 modarray (x)  7 7 3

fold with-loop Reduces dimensionality of array. Requires binary (associative, commutative) operation and a neutral element with index sets : values fold (op, neutral) x = [1,2,3]; with ([0] <= k <= [2]): x[k] fold(+, 0)  6

with-loop examples (I) double[+] abs(double[+] a) { res = with (iv) : abs(a[iv]) genarray(shape(a)); return (res) }

with-loop examples (II) bool any(bool[+] a) { res = with (iv < shape(a)) : a[iv] fold(||, false); return (res) }

Parallel Execution with-loops embody data parallelism (like array comprehensions in Data Parallel Haskell) Pool of worker threads (one thread per CPU) Array index space is partitioned between workers, and each worker executes identical code with-loops are combined by SAC compiler and unnecessary synchronization is optimized away