A RETROSPECTIVE OF CRYSTAL

Similar documents
Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference

Intermediate Code Generation

! Use of formal notations. ! in software system descriptions. ! for a broad range of effects. ! and varying levels of use. !

Com S 541. Programming Languages I

Programming Languages Third Edition

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

A Simple Syntax-Directed Translator

A macro- generator for ALGOL

PSD1C SYSTEM SOFTWAE UNIT: I - V PSD1C SYSTEM SOFTWARE

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking

Contents. Chapter 1 SPECIFYING SYNTAX 1

Local Specialization in Open-Axiom

1. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail.

Undergraduate Compilers in a Day

Single-Path Programming on a Chip-Multiprocessor System

Single-pass Static Semantic Check for Efficient Translation in YAPL

Context Free Languages

Chapter 3. Semantics. Topics. Introduction. Introduction. Introduction. Introduction

The SPL Programming Language Reference Manual

Lecture #23: Conversion and Type Inference

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

Conversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = "Hello";

CS 5540 Spring 2013 Assignment 3, v1.0 Due: Apr. 24th 11:59PM

6.001 Notes: Section 6.1

POWR IP PZ1/17

computer science department technical report no. 386 A Case Study of the Use of Formal Techniques to Achieve June 1993

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Introduction. Problem Solving on Computer. Data Structures (collection of data and relationships) Algorithms

Functional Programming. Big Picture. Design of Programming Languages

Short Notes of CS201

COS 320. Compiling Techniques

Semantics. There is no single widely acceptable notation or formalism for describing semantics Operational Semantics

CS201 - Introduction to Programming Glossary By

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53

Term Algebras with Length Function and Bounded Quantifier Elimination

Linear Loop Transformations for Locality Enhancement

Computational problems. Lecture 2: Combinatorial search and optimisation problems. Computational problems. Examples. Example

TOWARDS A 3D SPATIAL QUERY LANGUAGE FOR BUILDING INFORMATION MODELS

Introduction to SML Getting Started

UNIT 3

General Models for Optimum Arbitrary-Dimension FPGA Switch Box Designs

Lecture 11 Lecture 11 Nov 5, 2014

LOGIC AND DISCRETE MATHEMATICS

The PCAT Programming Language Reference Manual

Programming Languages

4. Simplicial Complexes and Simplicial Homology

Control Network Programming: Static Search Control with System Options

7. Introduction to Denotational Semantics. Oscar Nierstrasz

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

ABC basics (compilation from different articles)

Approximation of 3D-Parametric Functions by Bicubic B-spline Functions

Chapter 1: Introduction

Compiling for Advanced Architectures

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

Graphs, graph algorithms (for image segmentation),... in progress

Denotational Semantics of a Simple Imperative Language Using Intensional Logic

Programming Languages Lecture 14: Sum, Product, Recursive Types

Computing Fundamentals 2 Introduction to CafeOBJ

Satisfiability Modulo Theory based Methodology for Floorplanning in VLSI Circuits

5. Semantic Analysis!

A Catalog of While Loop Specification Patterns

Denotational Semantics. Domain Theory

Integrating SysML and OWL

Structural and Syntactic Pattern Recognition

SDD Advanced-User Manual Version 1.1

The Metalanguage λprolog and Its Implementation

Programming Languages, Summary CSC419; Odelia Schwartz

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

ITT8060: Advanced Programming (in F#)

CSC 533: Organization of Programming Languages. Spring 2005

This book is licensed under a Creative Commons Attribution 3.0 License

9. Elementary Algebraic and Transcendental Scalar Functions

Compiler Optimization and Code Generation

Chapter 7:: Data Types. Mid-Term Test. Mid-Term Test (cont.) Administrative Notes

Lambda Calculus see notes on Lambda Calculus

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad


Flat (Draft) Pasqualino Titto Assini 27 th of May 2016

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Lecture Notes on Aggregate Data Structures

(Refer Slide Time: 4:00)

An Evolution of Mathematical Tools

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

ENGINEERING PROBLEM SOLVING WITH C++

Functional Languages. Hwansoo Han

40 Behaviour Compatibility

Motivation was to facilitate development of systems software, especially OS development.

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

XQuery Optimization Based on Rewriting

Chapter 8: Enhanced ER Model

Intermediate Code Generation

IEEE LANGUAGE REFERENCE MANUAL Std P1076a /D3

Types and Static Type Checking (Introducing Micro-Haskell)

Query Languages. Berlin Chen Reference: 1. Modern Information Retrieval, chapter 4

LECTURE 16. Functional Programming

DISCRETE DOMAIN REPRESENTATION FOR SHAPE CONCEPTUALIZATION

Computers Programming Course 6. Iulian Năstac

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

FRAC: Language Reference Manual

Transcription:

Introduction Language Program Transformation Compiler References A RETROSPECTIVE OF CRYSTAL ANOTHER PARALLEL COMPILER" AMBITION FROM THE LATE 80 S Eva Burrows BLDL-Talks Department of Informatics, University of Bergen, Norway February 16, 2010

Introduction Language Program Transformation Compiler References WHAT IS CRYSTAL? a purely functional language with typed λ -abstraction, higher-order operators and data structures code resembles mathematical notations equational theory for program transformations (deriving new programs equivalent to the old) using a metalanguage efficient (parallel) compiler with optimizations (equations) all in all: addresses programmability and performance of parallel computations

Introduction Language Program Transformation Compiler References Features Language Elements CRYSTAL PROGRAMS a set of mutually recursive definitions of the form <identifier> : <type-expression> = <expression> with special constructs to express data parallelism and locality the compiler: classifies the source code communication primitives and their cost on the target machine maps data to distributed memory generates parallel code with explicit communication commands

Introduction Language Program Transformation Compiler References Features Language Elements EXPRESSIONS basic data types: integers, booleans, floating points composite data types: index domains, data fields function application to constants and identifiers functions: fn(x) : T {ε[x]} environments: ε where {d 1,d 2,...,d n } b 1 e 1 conditionals:... b n e n reduction operators for binary functions: reduce, scan a construct to simulate while loops: µ(i) : D{p[i]}, where p[i] is a boolean predicate

Introduction Language Program Transformation Compiler References Features Language Elements COMPOSITE DATA TYPES: INDEX DOMAINS an index domain D is associated with set of elements (indices) set of functions from D to D (communication operators) together with communication costs set of predicates used to define distributed data structures they can be interpreted as locations in space and time over which the parallel computation is defined they can be declared to be of a certain kind (second-order types): universal, temporal, spatial, processor, memory (aid for the compiler )

Introduction Language Program Transformation Compiler References Features Language Elements INDEX DOMAINS (CONT.) basic index domains: interval: interval(m, n) hypercube: hcube(n) binary tree: tree(r,s) with root r and nodes from the set S (left or right associative or balanced) domain constructors: product (D E), disjoint union (D + E), function space (D E) data-dependent index domain: defined as the value of a recursively defined function hyper surfaces: define the boundary of domain where functions take no special value

Introduction Language Program Transformation Compiler References Features Language Elements EXAMPLE: FRAGMENT FROM THE GAUSS ELIMINTATION SOURCE CODE

Introduction Language Program Transformation Compiler References Features Language Elements INDEX DOMAIN MORPHISMS transform one index domain into an other, with the kinds of the domains indicating the change of interpretations a morphism is a mapping D E such that paths are preserved (paths as defined by the composition of the domains communication operators) reshape morphisms: morphism with an inverse (isomorphisms) refinement morphisms: morphism with no inverse affine morphism is a reshape morphism from one product of intervals to an other (unify loop transformations, to skew the original structure): ex. loop interchange: g = fn(i,j) : D 1 D 2 {(j,i) : D 2 D 1 } space-time realizations by morphisms: g = fn(i) : D{(ε s (i),ε t (i)) : S[S ] T [T ]} can express inner loops to be executed in parallel etc.

Introduction Language Program Transformation Compiler References Features Language Elements AFFINE DOMAIN MORPHISMS EXAMPLE Let D = 0..n 1, E = 0..n 1, and T = 0..2n 1 be domains. Then, g : D 2 E T s.t. g = fn(i,j) : D 2.(i,i + j) is an affine morphism. The space-time realization of domain D requires a time product D T while the reshaped domain E T is a space time realization already.

Introduction Language Program Transformation Compiler References Features Language Elements DATA FIELDS AND DATA FIELD MORPHISMS a data field is a function over an index domain into some domain of values: a : D V, in Crystal notation: a : dfield(d,v) unify the notion of arrays and functions an example of a nested for-loop { to compute the elements of a matrix: } i = 0 j = 0 a : dfield(d 2 e1,v) = fn(i,j) : D else a(i 1,j) + a(i,j 1) index domain morphisms induce data field morphisms: Given g : D E index domain morphism, then g : (D V) (E V) : a a g 1 will define to new data field. But only works if g is a reshape morphism

Introduction Language Program Transformation Compiler References Features Language Elements COMMUNICATION FORMS they needed the explicit introduction of senders, receivers (the sender does not know who the receivers are) to keep track of communications and help optimizations in the example: a = fn(i) : D[P]{b(τ 1 (i)) + c(τ 2 (i))} the request-reply could be replaced by a single send if τ 1 or τ 2 (or both) had an inverse a communication form is a set of communication actions which are defined over two index domains D to E as a set of pairs: (s,t) the invers of the communication form is the set of pairs (t,s)

Introduction Language Program Transformation Compiler References Features Language Elements COMPILER DIRECTIVES The compiler needs to be told about: domain morphisms: to run the program with reshaped data fields communication forms: to specify inverses that cannot be derived by the compiler common index domains: alignment of data fields to be allocated over the index precedence: precedence(a,{2, 1, 3}) dynamic scheduling of mapping computations to processors. If not specified, it is static

Introduction Language Program Transformation Compiler References Equations Transformation Strategy THE EQUATIONAL THEORY OF CRYSTAL a minimal set of valid equations/algebraic entities in the language (M = N) with some inference rules for deriving new equations from old equations are expressing distributivity wrt. function composition and function application over conditional statements. Ex.: F {B H} = {B F H} {B H} F = {B F H F}. inference rules are the usual one for equality, substitution, application, abstraction and composition. Ex.: M = N fn(x){m} = fn(x){n} M = N M[H/K ] = N[H/K ]... a definition is a simple equation where the left-hand side is a single variable, and the right-hand side an expression possibly containing the same variable

Introduction Language Program Transformation Compiler References Equations Transformation Strategy A NEW PROGRAM FROM THE OLD given a : D V a data-field, and g : D E index domain morphism, then we want a new program in terms of a = a g 1 how to do this without repeating the application of a and g 1 in the new program (since repeating them does not reduce the cost)? by a mechanizable strategy based on substituting all occurrences of a with a = a g in the defintion of a using a combination of unfolding g and g 1 and the identities of the underlying theory, eliminate all occurrences of g and g 1. results in a new program (a more efficient one) a metalanguage is provided to define such (or similar) transformations at the programmer s convenience

Introduction Language Program Transformation Compiler References Compilation Stages Some Elements of the Compiler THE STRUCTURE OF THE CRYSTAL COMPILER

Introduction Language Program Transformation Compiler References Compilation Stages Some Elements of the Compiler DEPENDENCY ANALYSES call dependency between data fields (functions). It helps decomposing the program into phases and determining the control flow of the target program communication dependency among the indices of the index domains (wrt to data fields defined over the same index domain). Provides information for data accessing patterns and storage information. Based on this the compiler determines appropriate reshape morphisms and mappings to processors and time sequences by other morphisms.

Introduction Language Program Transformation Compiler References Compilation Stages Some Elements of the Compiler INDEX DOMAIN ALIGNMENT cross-referenced data fields: find a set of suitable reshape morphisms that map the index domains of these data fields into a common index domain data movements between processors are then reduced (optimization) can be automated or defined by the programmer

Introduction Language Program Transformation Compiler References Compilation Stages Some Elements of the Compiler EXAMPLE: FRAGMENT OF THE TRANSFORMED GAUSS EL. CODE

Introduction Language Program Transformation Compiler References Compilation Stages Some Elements of the Compiler SYNTHESIS OF PARALLEL CONTROL STRUCTURE determining the temporal part and the spatial part of an index domain from a communication dependency graph if the graph is acyclic, it is simple if it is cyclic: a sophisticated algorithm finds all the temporal components of the index domain, and the rest is spatial

Introduction Language Program Transformation Compiler References Compilation Stages Some Elements of the Compiler INTERMEDIATE PROGRAM by now the Crystal program has been transformed into an intermediate parallel program for multiple processors with a global shared memory

Introduction Language Program Transformation Compiler References Compilation Stages Some Elements of the Compiler DATA LAYOUT AND COMMUNICATION SYNTESIS deals with the distribution of data over individual memory on each processor, and defines explicit communications for the target program

Introduction Language Program Transformation Compiler References REFERENCES Marina Chen, Young-il Choo, Jingke Li: Crystal: theory and pragmatics of generating efficient parallel code. In: Parallel functional languages and compilers, ed. B. Szymanski, ACM, 1991 Marina Chen, Young-il Choo, Jingke Li: Compiling parallel programs by optimizing performance. The Journal of Supercomputing, 1988, Kluwer Academic Publishers, Boston J. Allan Yang, Young-il Choo: Metalinguistic Features for Formal Parallel-Program Transformation. Proceedings of the 1992 International Conference on Computer Languages, 1992.