5 th Biennial Ptolemy Miniconference Berkeley, CA, May 9, 2003 Java Code Generation Steve Neuendorffer UC Berkeley.

Slides:



Advertisements
Similar presentations
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Advertisements

CSCI 160 Midterm Review Rasanjalee DM.
A code generator for the CAL actor language Lars Wernli Supervisor: Joern Janneck, UC Berkeley Professor: Lothar Thiele, ETH Zuerich.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
1 PtHOMAS project, Ptolemy mini-conference '09 CR/RTC3-NA Elizabeth Latronico; UC Berkeley Jackie Mankit Leung | 4/16/2009 | © 2009 Robert Bosch LLC and.
UC Berkeley Mobies Technology Project PI: Edward Lee CoPI: Tom Henzinger Process-Based Software Components for Networked Embedded Systems.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Component Technologies for Embedded Systems Johan Eker.
Integrated Design and Analysis Tools for Software-Based Control Systems Shankar Sastry (PI) Tom Henzinger Edward Lee University of California, Berkeley.
Type System, March 12, Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.
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.
Ngu, Texas StatePtolemy Miniconference, February 13, 2007 Flexible Scientific Workflows Using Dynamic Embedding Anne H.H. Ngu, Nicholas Haasch Terence.
February 12, 2009 Center for Hybrid and Embedded Software Systems Encapsulated Model Transformation Rule A transformation.
FunState – An Internal Design Representation for Codesign A model that enables representations of different types of system components. Mixture of functional.
Implementing Quantity Managers in Ptolemy II EE 290N Project Haibo Zeng Dec 10 th, 2004.
3/12/ Modeling and controlling the Caltech Ducted Fan Vehicle Steve Neuendorffer, Ptolemy Group, UC Berkeley.
February 23, 2006 Center for Hybrid and Embedded Software Systems Ptalon Ptalon is an ADL with a simple goal: Make it easier.
Dataflow Process Networks Lee & Parks Synchronous Dataflow Lee & Messerschmitt Abhijit Davare Nathan Kitchen.
Design of Fault Tolerant Data Flow in Ptolemy II Mark McKelvin EE290 N, Fall 2004 Final Project.
7th Biennial Ptolemy Miniconference Berkeley, CA February 13, 2007 Cyber-Physical Systems: A Vision of the Future Edward A. Lee Robert S. Pepper Distinguished.
Heterochronous Dataflow in Ptolemy II Brian K. Vogel EE249 Project Presentation, Dec. 4, 1999.
SEC PI Meeting Annapolis, May 8-9, 2001 Component-Based Design of Embedded Control Systems Edward A. Lee & Jie Liu UC Berkeley with thanks to the entire.
February 12, 2009 Center for Hybrid and Embedded Software Systems Model Transformation Using ERG Controller Thomas H. Feng.
MoBIES Working group meeting, September 2001, Dearborn Ptolemy II The automotive challenge problems version 4.1 Johan Eker Edward Lee with thanks.
The Caltrop Actor Language Johan Eker UC Berkeley MoBIES group, Carnegie Mellon, November 30, 2001.
5 th Biennial Ptolemy Miniconference Berkeley, CA, May 9, 2003 JHDL Hardware Generation Mike Wirthlin and Matthew Koecher
5 th Biennial Ptolemy Miniconference Berkeley, CA, May 9, 2003 MESCAL Application Modeling and Mapping: Warpath Andrew Mihal and the MESCAL team UC Berkeley.
System-Level Types for Component-Based Design Paper by: Edward A. Lee and Yuhong Xiong Presentation by: Dan Patterson.
Department of Electrical Engineering and Computer Sciences University of California at Berkeley The Ptolemy II Framework for Visual Languages Xiaojun Liu.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
Review of C++ Programming Part II Sheng-Fang Huang.
02/06/05 “Investigating a Finite–State Machine Notation for Discrete–Event Systems” Nikolay Stoimenov.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Programming Languages and Paradigms Object-Oriented Programming.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Eric Keller, Evan Green Princeton University PRESTO /22/08 Virtualizing the Data Plane Through Source Code Merging.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
VHDL Symbolic simulator in OCaml Florent Ouchet TIMA Labs – GINP – UJF – CNRS – VDS group OCaml Meeting 2009.
- 1 - Embedded Systems - SDL Some general properties of languages 1. Synchronous vs. asynchronous languages Description of several processes in many languages.
Replay Compilation: Improving Debuggability of a Just-in Time Complier Presenter: Jun Tao.
1 5 Nov 2002 Risto Pohjonen, Juha-Pekka Tolvanen MetaCase Consulting AUTOMATED PRODUCTION OF FAMILY MEMBERS: LESSONS LEARNED.
Compilers for Embedded Systems Ram, Vasanth, and VJ Instructor : Dr. Edwin Sha Synthesis and Optimization of High-Performance Systems.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
Computing Simulation in Orders Based Transparent Parallelizing Pavlenko Vitaliy Danilovich, Odessa National Polytechnic University Burdeinyi Viktor Viktorovych,
CS 261 – Data Structures Introduction to C Programming.
ReNeW Reference Net Workshop Presenter Yao Sun. The ReNeW Features  High-level Petri Nets (Support Predicate)  Place/Transition Nets  Petri Nets with.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Chapter 4 Software. Chapter 4: Software Generations of Languages Each computer is wired to perform certain operations in response to an instruction. An.
Gedae, Inc. Gedae: Auto Coding to a Virtual Machine Authors: William I. Lundgren, Kerry B. Barnes, James W. Steed HPEC 2004.
Concurrency Properties. Correctness In sequential programs, rerunning a program with the same input will always give the same result, so it makes sense.
Incremental Checkpointing with Application to Distributed Discrete Event Simulation Thomas Huining Feng and Edward A. Lee {tfeng,
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Internet Computing Module II. Syllabus Creating & Using classes in Java – Methods and Classes – Inheritance – Super Class – Method Overriding – Packages.
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.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
IP – Based Design Methodology
Code Generation for Ptolemy II
Shanna-Shaye Forbes Ben Lickly Man-Kit Leung
Retargetable Model-Based Code Generation in Ptolemy II
Object Oriented Programming
VHDL Introduction.
Introduction to Data Structure
Mark McKelvin EE249 Embedded System Design December 03, 2002
Design Yaodong Bi.
Introduction to Programming
Presentation transcript:

5 th Biennial Ptolemy Miniconference Berkeley, CA, May 9, 2003 Java Code Generation Steve Neuendorffer UC Berkeley

Neuendorffer/UC Berkeley/Ptolemy Miniconference 2 Outline Motivation Code generation architecture Component Specialization –Parameter –Type –Connection –Domain Token Unboxing and Obfuscation

Neuendorffer/UC Berkeley/Ptolemy Miniconference 3 Design Pressures Increasing Complexity Market Customization Safety Requirements Design Reuse is Key!

Neuendorffer/UC Berkeley/Ptolemy Miniconference 4 Motivation System modeling using high-level components enables rapid prototyping System implementation becomes the bottleneck

Neuendorffer/UC Berkeley/Ptolemy Miniconference 5 Motivation Generation of hardware and software architectures for embedded systems RS-232 Localization Computer b Caltech vehicles

Neuendorffer/UC Berkeley/Ptolemy Miniconference 6 Ptolemy Classic Stars Galaxy CGC Stars (+ scheduling, etc.) Fire { x=x+1 send(x) } Fire { x=x+1 send(x) } Fire { x=x+1 send(x) } Fire { x=x+1 send(x) } Fire { x=x+1 send(x) } C code CG-VHDL Stars inside <= a AND b; x <= inside; y <= inside OR (not a); entity foo is port(a, b: in std_logic; x, y: out std_logic); end foo; VHDL Fire { x=x+1 send(x) } Fire { x=x+1 send(x) } Fire { x=x+1 send(x) } inside <= a AND b; x <= inside; y <= inside OR (not a); inside <= a AND b; x <= inside; y <= inside OR (not a);

Neuendorffer/UC Berkeley/Ptolemy Miniconference 7 Ptolemy II Java Actors Model (+ scheduling, etc.) Fire { x=x+1 send(x) } Fire { x=x+1 send(x) } Fire { x=x+1 send(x) } Fire { x=x+1 send(x) } Fire { x=x+1 send(x) } Java code Lda x add 1 Sta x Lda x add 1 Sta x Lda x add 1 Sta x JHDL Actor Specializer Lda x add 1 Sta x Lda x add 1 Sta x Lda x add 1 Sta x C code

Neuendorffer/UC Berkeley/Ptolemy Miniconference 8 Component Specification public interface Executable { public boolean prefire() throws IllegalActionException; public void initialize() throws IllegalActionException; public void fire() throws IllegalActionException; … } Java Code Finite State Machines Functional Expressions Special Purpose Languages Hierarchical Model actor Switch [T] () Integer Select, multi T Input ==> T Output : action Select: [i], Input: [a] at i ==> [a] end end

Neuendorffer/UC Berkeley/Ptolemy Miniconference 9 Parameter Specialization ? ? Here the scale factor has not been determined yet, because it depends on the parameter x. Specialize (Specified in Java code)

Neuendorffer/UC Berkeley/Ptolemy Miniconference 10 Implicit vs. Explicit information Implicit SpecializationExplicit Specialization ? Specialize Specialize factor = 2

Neuendorffer/UC Berkeley/Ptolemy Miniconference 11 Parameter Specialization Implicit Parameter Specialization relies on model analysis to determine parameter values that set and cannot change. Dynamic parameters: Parameters accessible through a user interface. Parameters that can be set in the FSM transitions. Parameters with values depending on unbound variables All other parameters can be specialized using implicit context.

Neuendorffer/UC Berkeley/Ptolemy Miniconference 12 Type Specialization ? output > input output > factor Implicit analysis simply uses the standard type inference mechanism. Currently assume that even when parameter values change, types do not.

Neuendorffer/UC Berkeley/Ptolemy Miniconference 13 Aggregation Parameter and Type specialization can be performed on individual actors. Domain and Connection specialization occur as part of aggregation. initialize { … } fire { … } Java code

Neuendorffer/UC Berkeley/Ptolemy Miniconference 14 Connection Specialization public void fire() { if (input.hasToken(0)) { Token in = input.get(0); Token factorToken = factor.getToken(); Token result = in.multiply(factorToken); output.send(0, result); } Scale.java receiver1receiver2 Connection specialization ties actors directly to the channels they are connected to. Connections are assumed not to change.

Neuendorffer/UC Berkeley/Ptolemy Miniconference 15 Connection Specialization public void fire() { if (receiver1.hasToken()) { Token in = receiver1.get(); Token factorToken = factor.getToken(); Token result = in.multiply(factorToken); receiver2.put(result); } receiver1receiver2 Connection specialization ties actors directly to the channels they are connected to. Connections are assumed not to change.

Neuendorffer/UC Berkeley/Ptolemy Miniconference 16 Domain Specialization receiver1receiver2 Connection specialization ties actors directly to the channels they are connected to. Domains are assumed not to change. public void fire() { if (receiver1.hasToken()) { Token in = receiver1.get(); Token factorToken = factor.getToken(); Token result = in.multiply(factorToken); receiver2.put(result); }

Neuendorffer/UC Berkeley/Ptolemy Miniconference 17 Domain Specialization public void fire() { if (true) { Token in = receiver1._array[index1++]; index1 = index1 %1; Token factorToken = factor.getToken(); Token result = in.multiply(factorToken); receiver2._array[index2++] = result; index2 = index2 % 1; } receiver1receiver2 Connection specialization ties actors directly to the channels they are connected to. Domains are assumed not to change.

Neuendorffer/UC Berkeley/Ptolemy Miniconference 18 Token Unboxing After specialization, memory use is a significant performance bottleneck. Token Unboxing removes allocation of token objects by replacing each token with its constituent fields. public void fire() { int in = receiver1._array[index1]; boolean inIsNull = receiver1._arrayIsNull[index1]; index1 = index1++ % 1; int factorToken = factor; boolean factorTokenIsNull = false; int result = in*factorToken; boolean resultIsNull = inIsNull && factorTokenIsNull; receiver2._array[index2++] = result; receiver2._arrayIsNull[index2++] = resultIsNull; index2 = index2++ % 1; }

Neuendorffer/UC Berkeley/Ptolemy Miniconference 19 Obfuscation Java.class files contain a large number of strings String literals Class names Method signatures Field signatures Exception messages Obfuscation renames these strings to shorter ones, where possible. Reduces bytecode side.

Neuendorffer/UC Berkeley/Ptolemy Miniconference 20 Why does this all work? Ptolemy actor specifications are highly polymorphic and reusable. However, we commonly use them only in monomorphic contexts. –Constant, exactly analyzable types. –Connections, domains don’t change. –Parameter values change only in known patterns.

Neuendorffer/UC Berkeley/Ptolemy Miniconference 21 Why does this all work? We’ve eliminated a large amount of synchronization overhead. –Workspace.getReadAccess() –Workspace.doneReading() We’ve eliminated object allocation, which reduces load on the garbage collector. Generated code is entirely self contained. Functionality is important, interfaces are not.

Neuendorffer/UC Berkeley/Ptolemy Miniconference 22 Capabilities Applications –Control algorithm for Caltech vehicles. –Rijndael encryption algorithm. –HTVQ Video compression. Supported –Expression actor –FSM actor –Modal models –SDF and Giotto domains Not supported –Record types –Transparent hierarchy

Neuendorffer/UC Berkeley/Ptolemy Miniconference 23 How to use Command-line interface >> copernicus model.xml Code is generated in: $ PTII/ptolemy/copernicus/java/cg/model/ Vergil User interface view -> Code Generator Allows easier changing of parameters.

Neuendorffer/UC Berkeley/Ptolemy Miniconference 24 Conclusion Java code generation is at the point where it might be useful for speeding up the simulation of some models. Current work: Embedded Java platform Integration with hardware synthesis Guided refinement