ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun...
-
date post
19-Dec-2015 -
Category
Documents
-
view
237 -
download
2
Transcript of ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun...
![Page 1: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/1.jpg)
ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for
Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA
Embedded Software fromConcurrent Component Models
Edward A. Lee
UC Berkeley
with
Shuvra Bhattacharyya, Johan Eker,
Christopher Hylands, Jie Liu, Xiaojun Liu,
Steve Neuendorffer, Jeff Tsay, and Yuhong Xiong
![Page 2: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/2.jpg)
E. A. Lee, Berkeley, 2
View of SW Architecture:Actors with Ports and Attributes
P ortP ort
A ctor A ctor
L inkR elation
A ctor
P ort
connection
connection conn
ectio
n
L ink
Link
A ttribu tes A ttribu tes
A ttribu tes
Model of Computation:
• Messaging schema• Flow of control• Concurrency
Examples:
• Time triggered• Process networks• Discrete-event systems• Dataflow systems• Publish & subscribe
Key idea: The model of computation is part of the framework within which components are embedded not part of the components themselves.
![Page 3: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/3.jpg)
E. A. Lee, Berkeley, 3
Actor View of Producer/Consumer Components
Models of Computation:
• continuous-time• dataflow• rendezvous• discrete events• synchronous• time-driven• publish/subscribe•…
Actor
IOPort
IORelation
P2P1
E1
E2
send(0,t) receiver.put(t) get(0)
token tR 1
Basic Transport:
Receiver(inside port)
![Page 4: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/4.jpg)
E. A. Lee, Berkeley, 4
Examples of Actors+PortsSoftware Architectures
Simulink (The MathWorks) Labview (National Instruments) OCP, open control platform (Boeing) SPW, signal processing worksystem (Cadence) System studio (Synopsys) ROOM, real-time object-oriented modeling (Rational) Port-based objects (U of Maryland) I/O automata (MIT) VHDL, Verilog, SystemC (Various) Polis & Metropolis (UC Berkeley) Ptolemy & Ptolemy II (UC Berkeley) …
![Page 5: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/5.jpg)
E. A. Lee, Berkeley, 5
What a Program Looks Like
Ptolemy II model of an embedded control system and the system being controlled. This is a hierarchical, heterogeneous model that combines four models of computation.
Model by Johan Eker
![Page 6: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/6.jpg)
E. A. Lee, Berkeley, 6
Contrast with Object Orientation
Call/return imperative semantics band-aids: futures, proxies, monitors
Poorly models the environment which does not have call/return semantics
Concurrency is via ad-hoc calling conventions Nothing at all to say about time
ComponentEntityCompositeEntity
AtomicActor
CompositeActor
0..10..n
«In te rface»Actor
+getD irec tor() : D irec to r+getE xecutiveD irec tor() : D irec to r+getM anager() : M anager+ inputP ortL is t() : L is t+new R eceiver() : R ece iver+outpu tP ortL is t() : L is t
«In terface»Executable
+fire ()+ in itia lize()+postfire () : boo lean+prefire () : boo lean+pre in itia lize()+s topF ire ()+ term ina te()+w rapup()
Director
Object modeling emphasizes inheritance and procedural interfaces.
Actor modeling emphasizes concurrency and communication abstractions.
![Page 7: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/7.jpg)
E. A. Lee, Berkeley, 7
Hierarchy and Heterogeneity 1Modal Models Model by Johan Eker
![Page 8: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/8.jpg)
E. A. Lee, Berkeley, 8
Domains
Each level of the hierarchy may have its own “laws of physics” communication semantics flow of control constraints
Domain a region of the universe where a certain set of “laws of
physics” applies Realizes a “model of computation”
![Page 9: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/9.jpg)
E. A. Lee, Berkeley, 9
A Problem: Compiling these Models:“Code generation”
![Page 10: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/10.jpg)
E. A. Lee, Berkeley, 10
Outline of our Approach
Domain semantics defines communication, flow of control
Ptolemy II model
scheduler
Schedule: - fire Gaussian0 - fire Ramp1 - fire Sine2 - fire AddSubtract5 - fire SequenceScope10
parser
method call
if
block
method call
block
…
for (int i = 0; i < plus.getWidth(); i++) {
if (plus.hasToken(i)) {
if (sum == null) {
sum = plus.get(i);
} else {
sum = sum.add(plus.get(i));
}
}
}
…
All actors are given in Java, then translated to embedded Java, C, VHDL, etc.
target codeabstract syntax tree
Jeff Tsay, Christopher Hylands, Steve Neuendorffer
![Page 11: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/11.jpg)
E. A. Lee, Berkeley, 11
Division of Responsibility
Domain semantics defines flow of control across actors communication protocols between actors
Actors define: functionality of components
Hierarchy: Code generation at a level of the hierarchy produces a
new actor definition
Multiple domains may be used in the same model
![Page 12: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/12.jpg)
E. A. Lee, Berkeley, 12
Software Basis
Build on: First version on Titanium (UC Berkeley) Second version on Soot (McGill)
Targeting: Simulation acceleration Embedded software synthesis Configurable hardware synthesis
![Page 13: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/13.jpg)
E. A. Lee, Berkeley, 13
Our Generator Approach
Actor libraries are built and maintained in Java more maintainable, easier to write polymorphic libraries are rich and small
Java + Domain translates to target language concurrent and imperative semantics
Efficiency gotten through code transformations specialization of polymorphic types code substitution using domain semantics removal of unnecessary code
![Page 14: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/14.jpg)
E. A. Lee, Berkeley, 14
Code transformations (data types)
// Original actor source
Token t1 = in.get(0);
Token t2 = in.get(1);
out.send(0, t1.multiply(t2));
specialization of Token declarations
// With specialized types
IntMatrixToken t1 = in.get(0);
IntMatrixToken t2 = in.get(1);
out.send(0, t1.multiply(t2));
The Ptolemy II type system supports polymorphic actors with propagating type constraints and static type resolution. The resolved types can be used in optimized generated code.
See Jeff Tsay, A Code Generation Framework for Ptolemy II
![Page 15: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/15.jpg)
E. A. Lee, Berkeley, 15
Type System
Output of type general - pure event with no value
Input of general type - anything will do
Polymorphic output - type depends on the parameters
double
general
int
general
double
Polymorphic actor uses late binding in Java to determine implementation of addition.
Opaque port - types propagated from inside
double
Lossless runtime type conversion
Type system by Yuhong Xiong
![Page 16: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/16.jpg)
E. A. Lee, Berkeley, 16
Type System
Extensible type lattice Unification infrastructure
Finds a least fixed point
Composite types records, arrays, matrices
Higher-order types planned Experiments with dependent types
encoding domain constraints
![Page 17: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/17.jpg)
E. A. Lee, Berkeley, 17
Code transformations (domains)
transformation using domain semantics
// With specialized types
IntMatrixToken t1 = in.get(0);
IntMatrixToken t2 = in.get(1);
out.send(0, t1.multiply(t2));
Domain-polymorphic code is replaced with specialized code.
// Extended Java with specialized communication
int[][] t1 = _inbuf[0][_inOffset = (_inOffset+1)%5];
int[][] t2 = _inbuf[1][_inOffset = (_inOffset+1)%5];
_outbuf[_outOffset = (_outOffset+1)%8] = t1 * t2;
See Jeff Tsay, A Code Generation Framework for Ptolemy II
![Page 18: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/18.jpg)
E. A. Lee, Berkeley, 18
Synchronous Dataflow (SDF) Domain
Balance equations (one for each channel):
FAN = FBM
Scheduled statically Decidable resource requirements
Available optimizations: eliminate checks for input data statically allocate communication buffers statically sequence actor invocations (and inline?)
send(0,t) get(0)
token tN MA
B
![Page 19: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/19.jpg)
E. A. Lee, Berkeley, 19
Synchronous/Reactive Domain
A discrete model of time progresses as a sequence of “ticks.” At a tick, the signals are defined by a fixed point equation:
A
CB
x
yz
x
y
z
f
f z
f x y
A t
B t
C t
L
NMMMO
QPPPL
NMMM
O
QPPP
,
,
,
( )
( )
( , )
1
Available optimizations:• Statically sequence fixed-point iteration• Communication via registers
![Page 20: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/20.jpg)
E. A. Lee, Berkeley, 20
Other Domains with Useful Properties for Code Generation
Strong static analyzability Giotto (time triggered) Finite state machines Discrete time
Good for hardware descriptions Discrete events Process networks Continuous time (analog hardware)
![Page 21: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/21.jpg)
E. A. Lee, Berkeley, 21
Hierarchical Heterogeneity
P6 P3P2 P5P1E1
E2
E4
E0
M: Manager
D1: local director
D2: local director
P4 P7
E3
E5
OpaqueComposite
Actor
TransparentComposite
Actor
Ptolemy II composes domains hierarchically, where components in a model can be refined into subcomponents where the component interactions follow distinct semantics.
![Page 22: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/22.jpg)
E. A. Lee, Berkeley, 22
Hierarchical Code Generation
atomic actor definition
atomic actor definitionatomic actor definition
atomic actor definition
![Page 23: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/23.jpg)
E. A. Lee, Berkeley, 23
Basic Object Model forExecutable Components
ComponentEntityCompositeEntity
AtomicActor
CompositeActor
0..10..n
«In te rface»Actor
+getD irec tor() : D irec to r+getE xecutiveD irec tor() : D irec to r+getM anager() : M anager+ inputP ortL is t() : L is t+new R eceiver() : R ece iver+outpu tP ortL is t() : L is t
«In terface»Executable
+fire ()+ in itia lize()+pos tfire () : boo lean+prefire () : boo lean+pre in itia lize()+s topF ire ()+ term ina te()+w rapup()
Director
![Page 24: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/24.jpg)
E. A. Lee, Berkeley, 24
Abstract Semantics – How Components Interact
flow of control Initialization Execution Finalization
communication Structure of signals Send/receive protocols
![Page 25: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/25.jpg)
E. A. Lee, Berkeley, 25
Abstract Semantics – How Components Interact
flow of control Initialization Execution Finalization
communication Structure of signals Send/receive protocols
preinitialize() declare static information, like
type constraints, scheduling properties, temporal properties, structural elaboration
initialize() initialize variables
![Page 26: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/26.jpg)
E. A. Lee, Berkeley, 26
Abstract Semantics – How Components Interact
flow of control Initialization Execution Finalization
communication Structure of signals Send/receive protocols
iterate()
![Page 27: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/27.jpg)
E. A. Lee, Berkeley, 27
Abstract Semantics – How Components Interact
flow of control Initialization Execution Finalization
communication Structure of signals Send/receive protocols
iterate()
prefire() fire() postfire()
stopFire()
![Page 28: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/28.jpg)
E. A. Lee, Berkeley, 28
The Key Action Methods
Prefire() obtain required resources may read inputs may start computations returns a boolean indicating readiness
Fire() produces results
Postfire() commits state updates (transactional)
StopFire() request premature termination
All of these are atomic (non-preemptible)
![Page 29: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/29.jpg)
E. A. Lee, Berkeley, 29
Benefits
Composable semantics arbitrarily deep hierarchies heterogeneous hierarchies
controller plant
actuatordynamics
sensor
task1
task2
TTA
TTA
Hierarchical, heterogeneous, system-level model
![Page 30: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/30.jpg)
E. A. Lee, Berkeley, 30
This Abstract Semanticshas Worked For
Continuous-time models Finite state machines Dataflow Discrete-event systems Synchronous/reactive systems Time-driven models (Giotto) …
We can even make it work for priority-driven multitasking (RTOS style)!
Hybrid systems
![Page 31: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/31.jpg)
E. A. Lee, Berkeley, 31
A Twist: Threaded ModelsThe Precise Mode Change Problem
How do you get the processes to a quiescent state to take a mode change?
thread or process
thread or process
thread or process
Problem posed by Boeing
![Page 32: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/32.jpg)
E. A. Lee, Berkeley, 32
HPM DomainHierarchical Preemptive Multitasking
Objective: support priority-driven preemptive scheduling use atomic execution, to get composability solve the precise mode change problem make behavior (more) deterministic
Solution: Atomic execution when possible Façade to long-running processes when not
Split phase execution (read phase, write phase)
Domain by Jie Liu
![Page 33: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/33.jpg)
E. A. Lee, Berkeley, 33
Atomic Façade to Long-Running Computations
Each component defines the interaction between the atomic façade and the long-running process.
There are several useful patterns: allow task to complete enforce declared timing “anytime” computation transactional
Declared time
OperationDispatcher
Atomic Facade
prefire()
readystart
priority-drivenmultitaskingrun other
atomic andnon-atomicoperations
fire()produceoutputs
Task
join
postfire()commitstatecontinue
produce outputs
read inputs
commit state
![Page 34: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/34.jpg)
E. A. Lee, Berkeley, 34
Inter-domain example: Shared-resource controllers
plant1
plant2
computer
controller1
controller2
Model by Jie Liu
![Page 35: ACM SIGPLAN 2001 Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES'2001) Jun 22-23, 2001, Snowbird, Utah, USA Embedded Software from.](https://reader036.fdocuments.net/reader036/viewer/2022062320/56649d2b5503460f94a00e70/html5/thumbnails/35.jpg)
E. A. Lee, Berkeley, 35
Conclusion
Systematic, principled, real-time, heterogeneous, hierarchical composition of:
Processes and/or threads Finite automata (mode controllers) Other models of computation
Continuous-time models Dataflow models …
Code generation
The key is the abstract semantics of Ptolemy II, which defines hierarchical heterogeneous composition of models of computation.
http://ptolemy.eecs.berkeley.edu