The Caltrop Actor Language a short introduction

Slides:



Advertisements
Similar presentations
A code generator for the CAL actor language Lars Wernli Supervisor: Joern Janneck, UC Berkeley Professor: Lothar Thiele, ETH Zuerich.
Advertisements

DATAFLOW PROCESS NETWORKS Edward A. Lee Thomas M. Parks.
Component Technologies for Embedded Systems Johan Eker.
5 th Biennial Ptolemy Miniconference Berkeley, CA, May 9, 2003 C AL - An actor language Jörn W. Janneck The Ptolemy Group University of California, Berkeley.
The Ptolemy Group University of California at Berkeley Jörn W. Janneck Actors, actor composition, and an actor language describing the semantics of (some)
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
The Caltrop Actor Language Johan Eker UC Berkeley MoBIES group, Carnegie Mellon, November 30, 2001.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Language Evaluation Criteria
1 Yolanda Gil Information Sciences InstituteJanuary 10, 2010 Requirements for caBIG Infrastructure to Support Semantic Workflows Yolanda.
Speaking Bluntly about SharpHDL: Some Old Stuff and Some Other Proposed Future Extensions Gordon J. Pace & Christine Vella Synchron’05 Malta, November.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Parser-Driven Games Tool programming © Allan C. Milne Abertay University v
1 Programming Languages Tevfik Koşar Lecture - II January 19 th, 2006.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
Design Languages in 2010 Chess: Center for Hybrid and Embedded Software Systems Edward A. Lee Professor UC Berkeley Panel Position Statement Forum on Design.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
Compiler Introduction 1 Kavita Patel. Outlines 2  1.1 What Do Compilers Do?  1.2 The Structure of a Compiler  1.3 Compilation Process  1.4 Phases.
Actor Oriented Programming with CAL -designing embedded system components Johan Eker Department of Automatic Control, Lund University Chris Chang, Jörn.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
ANU comp2110 Software Design lecture 10 COMP2110 Software Design in 2004 lecture 10 Software Architecture 2 of 2 design lecture 5 of 6 Goal of this small.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Chapter 1 Introduction Samuel College of Computer Science & Technology Harbin Engineering University.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Functional Programming
Advanced Computer Systems
Compiler Design (40-414) Main Text Book:
The architecture of the P416 compiler
Functional Programming Languages
Types CSCE 314 Spring 2016.
PRINCIPLES OF COMPILER DESIGN
Chapter 1 Introduction.
Introduction to Compiler Construction
Greg Steffens Noumena Solutions
Types for Programs and Proofs
Lexical and Syntax Analysis
CS 326 Programming Languages, Concepts and Implementation
John D. McGregor Session 9 Testing Vocabulary
Compiler Construction (CS-636)
SysML v2 Formalism: Requirements & Benefits
Input Space Partition Testing CS 4501 / 6501 Software Testing
Software Design and Architecture
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Week 4 Object-Oriented Programming (1): Inheritance
Compiler Lecture 1 CS510.
CS 536 / Fall 2017 Introduction to programming languages and compilers
John D. McGregor Session 9 Testing Vocabulary
Compiler Construction
CS416 Compiler Design lec00-outline September 19, 2018
Introduction to Functional Programming in Racket
Design by Contract Fall 2016 Version.
John D. McGregor Session 9 Testing Vocabulary
Shanna-Shaye Forbes Ben Lickly Man-Kit Leung
Higher-Order Procedures
MSIS 670 Object-Oriented Software Engineering
Software life cycle models
The Metacircular Evaluator
Prof. Jason Eisner MWF 3-4pm (sometimes 3-4:15)
Multiple Aspect Modeling of the Synchronous Language Signal
Coding Concepts (Basics)
An Introduction to Software Architecture
Jörn W. Janneck The Ptolemy Group University of California, Berkeley
CS416 Compiler Design lec00-outline February 23, 2019
Introduction to Functional Programming in Racket
Programming Languages
6.001 SICP Interpretation Parts of an interpreter
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Presentation transcript:

The Caltrop Actor Language a short introduction Johan Eker, Jörn W. Janneck Chris Chang, Lars Wernli The Ptolemy Group UC Berkeley December 14, 2001

Caltrop is a (textual) language for writing dataflow actors. What is Caltrop? Caltrop is a (textual) language for writing dataflow actors. It compiles (one day) against the Ptolemy API (Pt/Java). ... but is intended to be retargetable, and usable in a wide variety of contexts. It is designed as a domain-specific language. Notice, we make the assumption that you’re either a Ptolemy user, or a Ptolemy hacker  Of course, what is really meant by “Ptolemy user” is “the rest of the world”.

Can you guess what this does? actor A (Double k) Double Input1, Double Input2 ==> Double Output: action [a], [b] ==> [k*(a + b)] end end

Or this? actor B () Double Input ==> Double Output: Integer n := 0; Double sum := 0; action [a] ==> [sum / n] : n := n + 1; sum := sum + a; end

Writing simple actors should be simple. Motivation Writing simple actors should be simple. But: The Ptolemy API is very rich, and writing actors in it requires considerable skill. However: Many Ptolemy actors have considerable commonalities - they are written in a stylized format.

We should generate many actors from a more abstract description. Motivation We should generate many actors from a more abstract description. Benefits: reduces amount of code to be written makes writing actors more accessible reduces error probability makes code more versatile actors may be retargeted to other platforms, or new versions of the Ptolemy API

Why is Caltrop useful for me? For Ptolemy users: Makes it easier to write atomic actors. Makes Ptolemy accessible to a wider audience. For Ptolemy ‘hackers’: Reduces possibilities for bugs. Makes actors more reusable. Enables analysis and efficient code generation. Same joke

Some language features

Multiple actions, action conditions actor C () Double Input ==> Double Output: action [a] ==> [a] where a >= 0 end action [a] ==> [-a] where a < 0 end end actor D () Double Input ==> Double Output: action [a] ==> [abs(a)] end end

Nondeterminism More than one action may be firable. actor E () Double Input ==> Double Output: action [a] ==> [a] end action [a] ==> [-a] end end More than one action may be firable. Caltrop does not specify how this is resolved. It allows deterministic as well as non-deterministic implementations. Often, determinism can be ascertained statically.

Port patterns examples [a, b, c] [a, b, c | s] [| s] actor PairwiseSwap [T] () T Input ==> T Output: action [a, b] ==> [b, a] end end examples [a, b, c] [a, b, c | s] [| s]

Repeated patterns actor ReversePrefix [T] (Integer n) T Input ==> T Output: action [a] repeat n ==> [reverse(a)] repeat n end end

Channel selectors actor Switch [T] () multi T Data, Integer Select ==> T Output: action [a] i, [i] ==> [a] end end

Port tags actor Switch [T] () multi T Data, Integer Select ==> T Output: action Data:: [a] i, Select:: [i] ==> [a] end end actor Switch [T] () multi T Data, Integer Select ==> T Output: action Select:: [i], Data:: [a] i ==> [a] end end

Action tags, action selectors actor FairMerge [T] () T Input1, T Input2 ==> T Output: A: action Input1:: [a] ==> [a] end B: action Input2:: [a] ==> [a] end selector (AB)* end other selectors are conceivable, e.g. (AB)* | (BA)* ( (AB) | (BA) )*

Action conditions, state actor FairMerge [T] () T Input1, T Input2 ==> T Output: Integer s := 1; action Input1:: [a] ==> [a] where s = 1: s := 2; end action Input2:: [a] ==> [a] where s = 2: s := 1;

Overview of the implementation aspects of the Pt/Java implementation general architecture aspects of the Pt/Java implementation

Caltrop implementation —the big picture. source text parsing Caltrop transformation, annotation Caltrop AST Caltrop(0) code generation target platform Caltrop(1) We perform a series of transformations on the Caltrop language; each transformation results in a new language Caltrop(n). When these transformations finish, we call the resulting final language Calcore. Calcore guarantees various properties, which make it an easy language to generate code from. Caltrop(n) split-phase CalCore Ì CalCore Matlab? DSP/FPGA? Pt/Java TinyOS/C? ???

Caltrop implementation many small modules transformers, annotaters, checkers transforming Caltrop into some language subset CalCore small, semantically complete subset minimal language for code generation, analysis, transformation built on functional and procedural closures

Transformers & annotators replace control structures replace port patterns sort variable declarations replace operators propagate type information check static properties tag port patterns ...

Caltrop implementation Benefits: Much of the ‘hard’ stuff can be done on the same data structure, exploiting the regularities of the Caltrop/CalCore semantics and the existing software infrastructure. Code generators becomes relatively small, thus making retargeting easier. Intermediate results are valid Caltrop programs, making debugging a lot easier. We can look at them easily. We can use the parser and the well-formedness/type checkers themselves as debugging tools!

Switch in CalCore* actor Switch [T] () multi T Data, Integer Select ==> T Output : action Select::[|G0], Data::[|G2] all ==> Output::[a] where G1, G3 with Boolean G1 := available(G0, 1), Integer i := if G1 then G0[0] else null end, Integer G4 := i, Boolean G3 := available(G2[G4], 1), Integer a := if G3 then G2[G4][0] else null end end Split window with earlier example(s) and calcore Maybe use both examples *Actually, we are cheating here; CalCore is in fact even more primitive. And even less readable...

CalCore ==> Pt/Java different programming models single atomic action vs prefire/firen/postfire referentially transparent access to channels vs. token consuming read methods stateful computation vs state-invariant fire

CalCore ==> Pt/Java mapping Caltrop notions to Pt/Java concepts parameters ==> attributes + attribute changes types and type checking ...

What goes into prefire()? actor Switch [T] () multi T Data, Integer Select ==> T Output : action Select::[|G0], Data::[|G2] all ==> Output::[a] where G1, G3 with Boolean G1 := available(G0, 1), Integer i := if G1 then G0[0] else null end, Integer G4 := i, Boolean G3 := available(G2[G4], 1), Integer a := if G3 then G2[G4][0] else null end end All computation that is required in order to decide firability? Just the part of it before the first token access?

prefire/fire aggressive vs defensive condition evaluation incrementally computing conditions reusing computation done in prefire Should tokens read in prefire be kept if prefire returns false?

fire/postfire prefire fire postfire action Input1:: [a] ==> [a] where s = 1 : s := 2; end action Input1::[|G0] ==> Output::[a] where equals(s,1), G1 with Boolean G1 := available(G0, 1), T a := if G1 then G0[0] else null end : s := 2; end prefire fire postfire Computation that does not affect the output can be done in postfire.

State management If state needs to be changed in order to compute output, it needs to be shadowed. safe state management referentially transparent expressions no aliasing of stateful structures

State management actor B () Double Input ==> Double Output: Integer n := 0; Double sum := 0; action [a] ==> [sum / n] : n := n + 1; sum := sum + a; end The division between fire and postfire can be expressed in Caltrop (btw, this is a non-CalCore transformation) using action tags and selectors.

State management actor B () Double Input ==> Double Output: Integer n := 0; Integer n$shadow; Double sum := 0; Double sum$shadow; fire: action [a] ==> [sum$shadow / n$shadow] : n$shadow := n; sum$shadow := sum; n$shadow := n$shadow + 1; sum$shadow := sum$shadow + a; end postfire: action ==> : n := n$shadow; sum := sum$shadow; selector (fire+ postfire)* end

Things we need to do...

Short term “grunt” work  well-formedness checks type system, type checking split-phase analyses interpreter (+ wrapper for Pt/Java) optimizations, big and small other transformers, annotators There shouldn’t really be a , but it’s meant as a joke, and to add contrast to the ’s in the next few slides. The presenter should emphasize that it’s not grunt work at all.

Fun mid-term projects  static analysis of actor properties (data rates, dependency on state, parameters, input, ...) relation to MoC (e.g. BDF) computing interface automata from actor descriptions code generators to other platforms and languages code generation for composite actors?

Even funner long-term projects  generic code generation framework maybe based on Calif? extending the language higher-order constructs domains/directors+receivers a formal semantics, a framework for actor analysis

Caltrop resources www.gigascale.org/caltrop Meeting: Tuesdays, 1:30pm, DOP Center Library (We need Caltroopers!)

Thanks.