An Eect Type System for Modular Distribution of Dataow Programs

Similar documents
A Type System for the Automatic Distribution of Higher-order Synchronous Dataflow Programs

Clock-directed Modular Code-generation for Synchronous Data-flow Languages

Reactive Types. Jean-Pierre Talpin. Campus de Beaulieu, Rennes, France.

Lecture 2. The SCADE Language Data Flow Kernel. Daniel Kästner AbsInt GmbH 2012

Zélus, a Synchronous Language with ODEs 1

Synchronous Kahn Networks (ten years later)

Tutorial and Reference Manual

A Lift Controller in Lustre. (a case study in developing a reactive system) Leszek Holenderski

A Synchronous-based Code Generator For Explicit Hybrid Systems Languages

Verifying a Lustre Compiler Part 2

Synchronous Specification

GADTs meet Subtyping

Programming Languages

Productive Design of Extensible Cache Coherence Protocols!

CSE 130, Fall 2005: Final Examination

Lecture #23: Conversion and Type Inference

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

Safe Reactive Programming: the FunLoft Proposal

TYPE INFERENCE. François Pottier. The Programming Languages Mentoring ICFP August 30, 2015

Synchronous reactive programming

A Process Model suitable for defining and programming MpSoCs

A Conservative Extension of Synchronous Data-flow with State Machines

Programming the Simulink Standard Library with Zélus: experience report 1

Type-based Initialization Analysis of a Synchronous Data-flow Language

CSE 505, Fall 2008, Final Examination 11 December Please do not turn the page until everyone is ready.

A New Formalization of Subtyping to Match Subclasses to Subtypes

The Esterel language

An Introduction to Lustre

Introduction 2 The first synchronous language (early 80 s) Gérard Berry and his team (École des Mines de Paris / INRIA Sophia-Antipolis) Imperative, s

A Certified Non-Interference Java Bytecode Verifier

Lecture #13: Type Inference and Unification. Typing In the Language ML. Type Inference. Doing Type Inference

λ calculus is inconsistent

Synchronous Dataflow Processong

proc {Produce State Out} local State2 Out2 in State2 = State + 1 Out = State Out2 {Produce State2 Out2}

The Lustre Language Synchronous Programming Pascal Raymond, Nicolas Halbwachs Verimag-CNRS

Goal. CS152: Programming Languages. Lecture 15 Parametric Polymorphism. What the Library Likes. What The Client Likes. Start simpler.

Argos: an automaton-based synchronous language

Programming Languages and Compilers (CS 421)

Functions. Arizona State University 1

EE382N.23: Embedded System Design and Modeling

Static program checking and verification

Dependencies by case or by function?

LusRegTes: A Regression Testing Tool for Lustre Programs

CMSC 330: Organization of Programming Languages

Chapter 1 Programming: A General Overview

Teleport Messaging for. Distributed Stream Programs

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

control edge synchronization edge MGOTO COEND

Hierarchical FSMs with Multiple CMs

Programming Languages Assignment #7

Scope, Functions, and Storage Management

Some Advanced ML Features

More Static Semantics. Static. One-Slide Summary. Lecture Outline. Typing Rules. Dispatch Rules SELF_TYPE

COS 320. Compiling Techniques

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein

Outline Chapter 2: Automatic distribution of Lustre and Esterel synchronous programs. Context. Outline

Subtyping and Objects

Combining Static and Dynamic Contract Checking for Curry

Recap: Functions as first-class values

CIS 341 Final Examination 4 May 2017

An update on XML types

CSE 505, Fall 2008, Final Examination 11 December Please do not turn the page until everyone is ready.

Topics. Midterm Finish Chapter 7

Towards efficient, typed LR parsers

02157 Functional Programming. Michael R. Ha. Lecture 3: Programming as a model-based activity. Michael R. Hansen

Type checking. Jianguo Lu. November 27, slides adapted from Sean Treichler and Alex Aiken s. Jianguo Lu November 27, / 39

Ornaments in ML. Thomas Williams, Didier Rémy. April 18, Inria - Gallium

The essence of dataflow programming. Teooriapäevad Kokel 2,

Memory optimisation in a first-order dataflow synchronous language

CSE-321 Programming Languages 2011 Final

CSE 130, Fall 2006: Final Examination

Cunning Plan. One-Slide Summary. Functional Programming. Functional Programming. Introduction to COOL #1. Classroom Object-Oriented Language

CMa simple C Abstract Machine

Programming Languages Lecture 14: Sum, Product, Recursive Types

A Multiparadigm Language for Reactive Systems

Mode-Automata based Methodology for Scade

Static Checking and Type Systems

State Machines in OpenModelica

Some instance messages and methods

Lecture Outline. Type systems and their expressiveness. Type Checking in COOL (II) Type checking with SELF_TYPE in COOL

SEMANTIC ANALYSIS TYPES AND DECLARATIONS

MA513: Formal Languages and Automata Theory Topic: Context-free Grammars (CFG) Lecture Number 18 Date: September 12, 2011

The Metalanguage λprolog and Its Implementation

A Proposal for Verified Code Generation from Modelica

Cyber Physical System Verification with SAL

Lucian: Dataflow and Object-orientation

Chapter 2 Synchronous Programming: Overview

Algebraic Properties of CSP Model Operators? Y.C. Law and J.H.M. Lee. The Chinese University of Hong Kong.

OCaml. ML Flow. Complex types: Lists. Complex types: Lists. The PL for the discerning hacker. All elements must have same type.

Static Analysis by A. I. of Embedded Critical Software

UML Profile for MARTE: Time Model and CCSL

PRET-C: A New Language for Programming Precision Timed Architectures (extended abstract)

Exercise 1 ( = 24 points)

Programming Embedded Systems

First-Class Type Classes

Cache Aware Optimization of Stream Programs

Type Checking and Type Inference

News. CSE 130: Programming Languages. Environments & Closures. Functions are first-class values. Recap: Functions as first-class values

Midterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 20, 2013

Lecture Notes on Program Equivalence

Transcription:

An Eect Type System for Modular Distribution of Dataow Programs Gwenaël Delaval 1 Alain Girault 1 Marc Pouzet 2 P P 1 INRIA Rhône-Alpes, Pop-Art project ART 2 LRI, Demons team June 13, 2008 LCTES, Tucson, Arizona

Motivations To provide a language-oriented solution for the design of functionally distributed systems:

Motivations To provide a language-oriented solution for the design of functionally distributed systems: Alternative: separate design of each computing resource. Which raises the following problems: One function can involve several computing resources = separate design of closely related components, risks of data inconsistency. One computing resource can be involved in several functions = duplicated control jeopardizing the modularity.

Motivations To provide a language-oriented solution for the design of functionally distributed systems: Alternative: separate design of each computing resource. Which raises the following problems: One function can involve several computing resources = separate design of closely related components, risks of data inconsistency. One computing resource can be involved in several functions = duplicated control jeopardizing the modularity. To perform modular distribution: To avoid inlining every function To allow, by mean of high-order features, dynamic reconguration of a resource by another (by sending functions through channels)

Example Multichannel reception system of a software-dened radio FPGA DSP x g(y) lter_1800 dem_gmsk g(y) MUX y lter_2000 dem_qpsk Reception channel composed of two components: a pass-band lter implemented on a FPGA a demodulator implemented on a DSP

Synchronous Reactive Systems Reactive systems A reactive system is a system which reacts to its environment at the speed of the environment

Synchronous Reactive Systems Reactive systems A reactive system is a system which reacts to its environment at the speed of the environment The Synchronous Hypothesis Discrete time scale I 1 I 1 I 2 1 2 3 t O 1 O 1 O 2

Synchronous Reactive Systems Reactive systems A reactive system is a system which reacts to its environment at the speed of the environment The Synchronous Hypothesis Discrete time scale I 1 I 1 I 2 1 2 3 t O 1 O 1 O 2 Instantaneous broadcast of events

Synchronous Reactive Systems Reactive systems A reactive system is a system which reacts to its environment at the speed of the environment The Synchronous Hypothesis Discrete time scale I 1 I 1 I 2 1 2 3 t O 1 O 1 O 2 Instantaneous broadcast of events Language restrictions to ensure real-time executions

Dataow synchronous languages Example node sum (x,reset) = s where s = x + (0 -> if reset then 0 else pre s) val sum : int * int -> int val sum :: 'a * 'a -> 'a Examples: Lustre, Lucid Synchrone x, reset and s are data streams state of the system represented by the memories (pre(e))

Dataow synchronous languages Example node sum (x,reset) = s where s = x + (0 -> if reset then 0 val sum : else pre s) int * int -> int val sum :: 'a * 'a -> 'a Examples: Lustre, Lucid Synchrone x, reset and s are data streams state of the system represented by the memories (pre(e)) x reset 0 if + s pre

SDR example node channel(filter,demod,x) = y where m = filter(x) and y = demod(m) node multichannel_sdr(x) = y where c = g(y) and match (true fby c) with true -> y = channel(filter_bp_1800, demod_gmsk, x) false -> y = channel(filter_bp_2000, demod_qpsk, x)

SDR example loc FPGA; loc DSP; loc GPP; link FPGA to DSP; link DSP to GPP; node channel(filter,demod,x) = y where m = filter(x) at FPGA and y = demod(m) at DSP node multichannel_sdr(x) = y where c = g(y) and match (true fby c) with true -> y = channel(filter_bp_1800, demod_gmsk, x) false -> y = channel(filter_bp_2000, demod_qpsk, x)

Distribution of synchronous dataows programs Principles Allowing the explicit localization of computations: y = f(x) at A... Inference of the localization of each value and computation from expressed ones: coloration of the program [Caspi, Girault & Pilaud, IEEE TSE 1999]

Distribution of synchronous dataows programs Principles Allowing the explicit localization of computations: y = f(x) at A... Inference of the localization of each value and computation from expressed ones: coloration of the program [Caspi, Girault & Pilaud, IEEE TSE 1999] Realisation Localization of a value spatial type of this value coloration type inference

Extended language Architecture description : composed of location declarations as symbolic names, and links between locations : loc FPGA; loc DSP; loc GPP; link FPGA to DSP; link DSP to GPP; Localization : e at A : every computation in e will be performed at location A Communications : abstraction of their positions, and their technical expression

Annotated semantics : principle Based on a reactive semantics : R e v e. Formalization of distributed values ˆv (and distributed reaction environment ˆR) : i at s : immediate value located at s (vl, vl ) at A : pair entirely located at A (vl at A, vl at B) : distributed pair Formalization of distributed reactions involving l a set of sites l : ˆR e ˆv e

Distributed execution I An immediate value can be emitted anywhere : (Imm) ˆR {s} i i at s i An operation can be performed only on two values at the same location, and the result is on this location : (Op) ˆR l 1 e 1 i1 at A e 1 ˆR l 2 ˆR e 2 i2 at A e 2 i = op(i 1, i 2 ) l 1 l 2 op(e 1, e 2 ) i at A op(e 1, e 2)

Distributed execution II The reaction of a e at A expression must involve at most the location A : (At) {A} ˆR e ˆv e ˆR {A} e at A ˆv e at A A value located on one site A can be communicated on any location available from A : (Comm) l ˆR e vl at A ˆR e l {A } e (A, A ) L vl at A e

Spatial types: overview Type and eect system [Talpin & Jouvelot, JFP 1992] : t at s is the spacial type of a value available at location s (either a constant location A or a location variable δ) functional values: spatial types of the form s i l, T s o s.t. : s i is the spatial type of the function's inputs s o is the spatial type of the function's outputs l is the set of locations involved in the computation of the function (used for type inference: it includes every location of s i, s o, and T ) T is a set of communication channels involved in the computation (used for distribution)

Example of spatial types node f(x) = y3 where y1 = f1(x) at P and y2 = f2(y1) at Q and y3 = f3(y2) at R x P Q R y1 y2 f1 f2 f3 f y Assuming that f1, f2, and f3 are computable everywhere : f1 gets the spatial type c at P {P}, c at P f2 gets the spatial type c at Q {Q}, c at Q f3 gets the spatial type c at R {R}, c at R because of the presence of the two communications, f is nally of spatial type c at P {P, Q, R}, [P 1 Q, Q 2 R] c at R

Spatial type expressions Judgments of the form H e : t/l/t : In the environment H, the expression e is of spatial type t, and computing e involves : the set of locations l the set of named communication channels T

Typing rules: localization The expression e at A is typed by constraining the computation of the expression e to involve at most the location A, by use of instanciation mechanisms : (At) H at A e : t/{a}/t A S H e at A : t/{a}/t

Typing rules: communications Communications are inserted by means of subtyping : A value typed t at s can be considered as of type t at s, provided that there exists a communication link from s to s : (Comm) H e : tc at s/l/t H e : tc at s /l {s }/T, [s (s, s ) L c s ]

Distribution: Principle Denition of a type-directed operation of projection : H D : H /l/t = A D H e : t/l/t = A e /D The expression e, projected on A, results in a new expression e D contains additional declarations (e.g., channel denitions)

Distribution: Principle Denition of a type-directed operation of projection : H D : H /l/t = A D H e : t/l/t = A e /D The expression e, projected on A, results in a new expression e D contains additional declarations (e.g., channel denitions) Communication channels used between two projected expressions are added as inputs or outputs streams of nodes

Modular distribution: principle Channel names, dened or used as streams in the body of a function, will be added to the signature of this function

Modular distribution: principle Channel names, dened or used as streams in the body of a function, will be added to the signature of this function This allows multiple instanciations of functions

Distribution example: node distribution loc A; loc B; link A to B; node f(x) = z where y = x + 1 at A and z = y + 2 at B

Distribution example: node distribution loc A; loc B; link A to B; node f(x) = z where y = x + 1 at A and z = y + 2 at B Spatial type of f : b at A {A, B}/[A c B] b at B

Distribution example: node distribution loc A; loc B; link A to B; node f(x) = z where y = x + 1 at A and z = y + 2 at B Spatial type of f : b at A {A, B}/[A c B] b at B On A, c is added as an output : node f(x) = ((),c) where y = x + 1 and c = y

Distribution example: node distribution loc A; loc B; link A to B; node f(x) = z where y = x + 1 at A and z = y + 2 at B Spatial type of f : b at A {A, B}/[A c B] b at B On A, c is added as an output : node f(x) = ((),c) where y = x + 1 and c = y On B, c is added as an input : node f (x,c) = z where z = c + 2

Distribution example: node instanciation node g (x1,x2) = (y1,y2) where y1 = f(x1) and y2 = f(x2) g : (b at A b at A) {A, B}/[A c 1 B, A c 2 B] (b at B b at B)

Distribution example: node instanciation node g (x1,x2) = (y1,y2) where y1 = f(x1) and y2 = f(x2) g : (b at A b at A) {A, B}/[A c 1 B, A c 2 B] (b at B b at B) use of two distinct channels : one for each instanciation

Node instanciation: projection on A and B On location A : Channel c 1 is an output of f's rst instance (resp. c 2 ) Channels c 1 and c 2 are both added as outputs of g node g (x1,x2) = ((x1,x2),c1,c2) where (x1,c1) = f(x1) and (x2,c2) = f(x2)

Node instanciation: projection on A and B On location A : Channel c 1 is an output of f's rst instance (resp. c 2 ) Channels c 1 and c 2 are both added as outputs of g node g (x1,x2) = ((x1,x2),c1,c2) where (x1,c1) = f(x1) and (x2,c2) = f(x2) On location B : Channel c 1 is an input of f's rst instance (resp. c 2 ) Channels c 1 and c 2 are both inputs of g node g ((x1,x2),c1,c2) = (y1,y2) where y1 = f(x1,c1) and y2 = f(x2,c2)

SDR example node channel(filter,demod,x) = y where m = filter(x) at FPGA and y = demod(m) at DSP channel : α, β, γ, η.(α at FPGA {FPGA}/ β at FPGA) (β at DSP {DSP}/ γ at DSP) α at FPGA {FPGA, DSP}/[FPGA c DSP] γ at DSP

Control: SDR example node multichannel_sdr(x) = y where c = g(y) and match (true fby c) with true -> y = channel(filter_bp_1800, demod_gmsk, x) false -> y = channel(filter_bp_2000, demod_qpsk, x) multichannel_sdr : c at FPGA {FPGA, DSP}/T c at DSP with T = [FPGA c 1 DSP, FPGA c 2 DSP, DSP c 3 FPGA]

Results Theorems Executable by centralized semantics typable executable by the distributed semantics

Results Theorems Executable by centralized semantics typable executable by the distributed semantics Let D distributed on an architecture G = A 1,..., A n, L : H D : H /l/t A 1 = D 1 H D : H /l/t. An = D n Then D is semantically equivalent with D 1 and... and D n.

Results Theorems Executable by centralized semantics typable executable by the distributed semantics Let D distributed on an architecture G = A 1,..., A n, L : H D : H /l/t A 1 = D 1 H D : H /l/t. An = D n Then D is semantically equivalent with D 1 and... and D n. Implementation Type system with channel inference and automatic distribution implemented into the Lucid Synchrone compiler.

Contributions Interest of a language approach for the design of distributed embedded systems Extension of a synchronous dataow language with primitives for program distribution Proposal of a formal semantics for this extended language, through the formalization of distributed values and distributed execution Design of a spatial type system, and a type-directed automatic distribution operation : integration within modular compilation Taking into account of control primitives : global clocks and match/with Implementation into the Lucid Synchrone compiler

Prospects Finer architecture description: typed channels, hierarchy, clock or temporal informations Finer and more complete distribution via the expression of more general types, including site or eect variables Examination of higher-order dataow programs distribution. Goal: expression of dynamic reconguration of a resource by sending functions through channels...

Prospects: dynamic reconguration This is 100% valid Lucid Synchrone code!!! let node channel reconfigure x = y where rec automaton Init -> do y = x until reconfigure(filter,demod) then Configure(filter,demod) Configure(filter,demod) -> let f = run filter x in do y = run demod f until reconfigure(filter',demod') then Configure(filter',demod') end

Prospects: dynamic reconguration (cont'd) let node multichannel_sdr x = y where rec y = channel switch_channel x and automaton Reconfigure_GSM -> do emit switch_channel = (filter_1800,demod_gmsk) then GSM GSM -> do until (umts y) then Reconfigure_UMTS Reconfigure_UMTS -> do emit switch_channel = (filter_2000,demod_qpsk) then UMTS UMTS -> do until (gsm y) then Reconfigure_GSM end

Questions?...