Concurrent Models of Computation - PowerPoint PPT Presentation

1 / 73
About This Presentation
Title:

Concurrent Models of Computation

Description:

Distributed Version of. 20-th Century Computation ... GR 2-D and 3-D graphics. PN process networks. DPN distributed process networks ... – PowerPoint PPT presentation

Number of Views:105
Avg rating:3.0/5.0
Slides: 74
Provided by: edward6
Category:

less

Transcript and Presenter's Notes

Title: Concurrent Models of Computation


1
Concurrent Models of Computation
  • Edward A. Lee
  • Professor, UC Berkeley
  • Ptolemy Project
  • CHESS Center for Hybrid and Embedded Software
    Systems

HP Workshop on Advanced Software
TechnologiesJuly 20-22 HP Labs, Palo Alto, CA
2
Standard Software Abstraction(20-th Century
Computation)
initial state
sequence
f State ? State
Alan Turing
final state
  • Time is irrelevant
  • All actions are ordered

3
Standard Software Abstraction Processes or
Threads
  • The operating system (typically) provides
  • suspend/resume
  • mutual exclusion
  • semaphores

Infinite sequences of state transformations are
called processes or threads
suspend
resume
4
Standard Software AbstractionConcurrency via
Interacting Threads
Potential for race conditions, deadlock, and
livelock severely compromises software
reliability. These methods date back to the
1960s (Dijkstra).
stalled by precedence
race condition
stalled for rendezvous
5
A Stake in the Ground
  • Nontrivial concurrent programs based on
    processes, threads, semaphores, and mutexes are
    incomprehensible to humans.
  • No amount of process improvement is going to
    change this.
  • the human brain doesnt work this way.
  • Formal methods may help
  • scalability?
  • understandability?
  • Better concurrency abstractions will help more

6
A Story Ptolemy Project Code Review
7
Ptolemy Project Code ReviewA Typical Story
  • Code review discovers that a method needs to be
    synchronized to ensure that multiple threads do
    not reverse each others actions.
  • No problems had been detected in 4 years of using
    the code.
  • Three days after making the change, users started
    reporting deadlocks caused by the new mutex.
  • Analysis and correction of the deadlock is hard.
  • But code review successfully identified the flaw.

8
Code Review Doesnt Always WorkAnother Typical
Story
/ CrossRefList is a list that maintains
pointers to other CrossRefLists. _at_author
Geroncio Galicia, Contributor Edward A.
Lee _at_version Id CrossRefList.java,v 1.78
2004/04/29 145000 eal Exp _at_since Ptolemy II
0.2 _at_Pt.ProposedRating Green (eal) _at_Pt.AcceptedRat
ing Green (bart) / public final class
CrossRefList implements Serializable
protected class CrossRef implements
Serializable // NOTE
It is essential that this method not be
// synchronized, since it is called by
_farContainer(), // which is. Having it
synchronized can lead to // deadlock.
Fortunately, it is an atomic action, //
so it need not be synchronized. private
Object _nearContainer() return
_container private
synchronized Object _farContainer()
if (_far ! null) return _far._nearContainer()
else return null

Code that had been in use for four years, central
to Ptolemy II, with an extensive test suite,
design reviewed to yellow, then code reviewed to
green in 2000, causes a deadlock during a demo on
April 26, 2004.
9
And Doubts Remain
/ CrossRefList is a list that maintains
pointers to other CrossRefLists. _at_author
Geroncio Galicia, Contributor Edward A.
Lee _at_version Id CrossRefList.java,v 1.78
2004/04/29 145000 eal Exp _at_since Ptolemy II
0.2 _at_Pt.ProposedRating Green (eal) _at_Pt.AcceptedRat
ing Green (bart) / public final class
CrossRefList implements Serializable
protected class CrossRef implements
Serializable private
synchronized void _dissociate()
_unlink() // Remove this. // NOTE
Deadlock risk here! If _far is waiting
// on a lock to this CrossRef, then we will
get // deadlock. However, this will
only happen if // we have two threads
simultaneously modifying a // model.
At the moment (4/29/04), we have no
// mechanism for doing that without first
// acquiring write permission the
workspace(). // Two threads cannot
simultaneously hold that // write
access. if (_far ! null)
_far._unlink() // Remove far
Safety of this code depends on policies
maintained by entirely unconnected classes. The
language and synchronization mechanisms provide
no way to talk about these systemwide properties.
10
What it Feels Like to Use the synchronized
Keyword in Java
Image borrowed from an Iomega advertisement for
Y2K software and disk drives, Scientific
American, September 1999.
11
Diagnosis Interacting Processes are Not
Compositional
An aggregation of processes is not a process (a
total order of external interactions). What is
it? Many software failures are due to this
ill-defined composition.
12
Distributed Version of 20-th Century Computation
Force-fitting the sequential abstraction onto
parallel hardware.
remote procedure call
13
Combining Processes and RPC Split-Phase
Execution, Futures,Asynchronous Method Calls,
Callbacks,
These methods are at least as incomprehensible as
concurrent threads or processes.
asynchronous procedure call
14
Model Used in Wireless Sensor NetsNo Threads
nesC and TinyOS
  • Typical usage pattern
  • hardware interrupt signals an event.
  • event handler posts a task.
  • tasks are executed when machine is idle.
  • tasks execute atomically w.r.t. one another.
  • tasks can invoke commands and signal events.
  • hardware interrupts can interrupt tasks.
  • exactly one monitor, implemented by disabling
    interrupts.

interface provided
Component 1
interface used
event handled
command invoked
event signaled
command implemented
interface provided
Component 2
Command implementers can invoke other commands or
post tasks, but do not trigger events.
interface used
15
Ptolemy II Framework for Experimenting with
Alternative Concurrent Models of Computation
Basic Ptolemy II infrastructure
16
The Basic Abstract Syntax
  • Actors
  • Attributes on actors (parameters)
  • Ports in actors
  • Links between ports
  • Width on links (channels)
  • Hierarchy
  • Concrete syntaxes
  • XML
  • Visual pictures
  • Actor languages (Cal, StreamIT, )

17
Hierarchy - Composite Components
dangling
Relation
Port
Actor
opaque Port
Port
transparent or opaqueCompositeActor
toplevel CompositeActor
18
Abstract Semanticsof Actor-Oriented Models of
Computation
  • Actor-Oriented Models of Computation that we have
    implemented
  • dataflow (several variants)
  • process networks
  • distributed process networks
  • Click (push/pull)
  • continuous-time
  • CSP (rendezvous)
  • discrete events
  • distributed discrete events
  • synchronous/reactive
  • time-driven (several variants)

execution control
data transport
init() fire()
19
What is an Actor-Oriented MoC?
20
Models of ComputationImplemented in Ptolemy II
  • CI Push/pull component interaction
  • Click Push/pull with method invocation
  • CSP concurrent threads with rendezvous
  • CT continuous-time modeling
  • DE discrete-event systems
  • DDE distributed discrete events
  • FSM finite state machines
  • DT discrete time (cycle driven)
  • Giotto synchronous periodic
  • GR 2-D and 3-D graphics
  • PN process networks
  • DPN distributed process networks
  • SDF synchronous dataflow
  • SR synchronous/reactive
  • TM timed multitasking

Most of these are actor oriented.
21
Discrete Event Models
Reactive actors
Event source
Signal
Time line
22
Semantics of DE Signals
Note A signal is not a single event but all the
events that flow on a path.
signal in
signal out
A signal is a partial function
Data type (set of values)
Real numbers (approximated by doubles)
Integers (allowing for simultaneous events in a
signal)
23
Subtleties Simultaneous Events
By default, an actor produces events with the
same time as the input event. But in this
example, we expect (and need) for the
BooleanSwitch to see the output of the
Bernoulli in the same firing where it sees the
event from the PoissonClock. Events with
identical time stamps are also ordered, and
reactions to such events follow data precedence
order.
24
Subtleties Feedback
Data precedence analysis has to take into account
the non-strictness of this actor (that an output
can be produced despite the lack of an input).
25
Discrete-Event Semantics
Cantor metric
where t is the earliest time where x and y
differ.
x
y
t
26
Causality
Causal
Strictly causal
Delta causal
A delta-causal component is a contraction map.
27
Semantics of Composition
If the components are deterministic, the
composition is deterministic.
  • Banach fixed point theorem
  • Contraction map has a unique fixed point
  • Execution procedure for finding that fixed point
  • Successive approximations to the fixed point

28
Zeno Systems
Theorem If every directed cycle contains a
delta-causal component, then the system is
non-Zeno.
29
Extension of Discrete-Event Modeling for
Wireless Sensor Nets
VisualSense extends the Ptolemy II discrete-event
domain with communication between actors
representing sensor nodes being mediated by a
channel, which is another actor. The example at
the left shows a grid of nodes that relay
messages from an initiator (center) via a channel
that models a low (but non-zero) probability of
long range links being viable.
30
Distributed Discrete Event Modelsas Currently
Implemented in Ptolemy II
Local notion of time in each actor, advancing
only when input is received
Blocking read at input ports prevents time from
locally advancing without permission from a
source
This is the Chandy and Misra style of
distributed discrete events 1979, which
compared to Croquet and Time Warp Jefferson,
1985, is conservative.
31
Continuous-Time Models
Director implements a solver that constructs an
approximation to the continuous-time behavior.
A signal has a value at all real-valued times.
Integrator used to define systems governed by
ordinary differential equations.
32
Heterogeneous ModelsMixed Signals DE CT
DE signal
DE model of a digital controller
CT signal
CT model of mechanical system
33
Heterogeneous ModelsHybrid Systems CT FSM
The FSM director can be combined with other
directors to create modal models.
34
Untimed Concurrency ModelFirst Example Click
  • Typical usage pattern
  • queues have push input, pull output.
  • schedulers have pull input, push output.
  • thin wrappers for hardware have push output or
    pull input only.
  • push or pull handled by method calls

agnostic output port
push output port
push input port
pull output port
Implementation of Click with a visual syntax in
Mescal (Keutzer, et al.)
35
Untimed Concurrency ModelSecond Example
Process Networks
actor thread
signal stream
reads block
writes dont
Kahn, MacQueen, 1977
36
PN Semantics
  • A signal is a sequence of values
  • Define a prefix order
  • x y
  • means that x is a prefix of y.
  • Actors are monotonic functions
  • x y ? F(x) F(y)
  • Stronger condition Actors are continuous
    functions (intuitively they dont wait forever
    to produce outputs).

37
PN Semantics of Composition (Kahn, 74)
If the components are deterministic, the
composition is deterministic.
  • Knaster-Tarski fixed point theorem
  • Continuous function has a unique least fixed
    point
  • Execution procedure for finding that fixed point
  • Successive approximations to the fixed point

38
Distributed Process Networks
Transport mechanism between hosts is provided by
the director. Transparently provides guaranteed
delivery and ordered messages.
  • Created by Dominique Ragot, Thales Communications

39
Kepler Extensions to Ptolemy II for Scientific
Workflows
Example showing a web service wrapper (Thanks to
Bertram Ludaecher, San Diego Supercomputer Center)
40
Synchronous Models of Computation
Director finds a value (or absent) at each tick
of a global clock
Feedback is resolved by finding a fixed point.
Semantic foundation based on Kanster-Tarski fixed
point theorem on Scott topologies.
Signal has a value or is absent at each tick of
the clock.
41
Languages Based on theSynchronous Model of
Computation
  • Lustre (and SCADE)
  • Esterel
  • Signal
  • Statecharts (and UML state machines)
  • Argos

42
Dataflow Models of Computation
Many tools, software frameworks, and hardware
architectures have been built to support one or
more of these.
  • Computation graphs Karp Miller - 1966
  • Process networks Kahn - 1974
  • Static dataflow Dennis - 1974
  • Dynamic dataflow Arvind, 1981
  • K-bounded loops Culler, 1986
  • Synchronous dataflow Lee Messerschmitt, 1986
  • Structured dataflow Kodosky, 1986
  • PGM Processing Graph Method Kaplan, 1987
  • Synchronous languages Lustre, Signal, 1980s
  • Well-behaved dataflow Gao, 1992
  • Boolean dataflow Buck and Lee, 1993
  • Multidimensional SDF Lee, 1993
  • Cyclo-static dataflow Lauwereins, 1994
  • Integer dataflow Buck, 1994
  • Bounded dynamic dataflow Lee and Parks, 1995
  • Heterochronous dataflow Girault, Lee, Lee,
    1997

43
Synchronous Dataflow (SDF)(Lee and
Messerschmitt, 1986)
SDF director
SDF offers feedback, multirate, static
scheduling, deadlock analysis, parallel
scheduling, static memory allocation.
44
Synchronous Dataflow (SDF)Fixed
Production/Consumption Rates
  • Balance equations (one for each channel)
  • Schedulable statically
  • Get a well-defined iteration
  • Decidable
  • buffer memory requirements
  • deadlock

number of tokens consumed
number of firings per iteration
number of tokens produced
45
One Consequence of SDF SemanticsMobile Code
that Cannot Perform Denial of Service Attacks
SDF model has decidable semantics (termination,
memory usage).
MobileModel actor accepts an XML description of a
model. It then executes that model on a stream of
input data using locally defined component
implementations.
PushConsumer actor receives pushed data provided
via CORBA, where the data is an XML model of a
signal analysis algorithm.
46
Parallel Scheduling of SDF Models
Many scheduling optimization problems can be
formulated. Some can be solved, too!
SDF is suitable for automated mapping onto
parallel processors and synthesis of parallel
circuits.
A
C
B
D
Sequential
Parallel
47
Scheduling Tradeoffs(Bhattacharyya, Parks, Pino)
Scheduling strategy Code Data
Minimum buffer schedule, no looping 13735 32
Minimum buffer schedule, with looping 9400 32
Worst minimum code size schedule 170 1021
Best minimum code size schedule 170 264
Source Shuvra Bhattacharyya
48
Minimum Buffer Schedule
  • A B A B C A B C A B A B C A B C D E A F F F F F B
    A B C A B C A B A B C D E
  • A F F F F F B C A B A B C A B C A B A B C D E A F
    F F F F B C A B A B C A B C
  • D E A F F F F F B A B C A B C A B A B C A B C D E
    A F F F F F B A B C A B C A
  • B A B C D E A F F F F F B C A B A B C A B C A B A
    B C D E A F F F F F E B C A
  • F F F F F B A B C A B C D E A F F F F F B A B C A
    B C A B A B C A B C D E A F
  • F F F F B A B C A B C A B A B C D E A F F F F F B
    C A B A B C A B C A B A B C
  • D E A F F F F F B C A B A B C A B C D E A F F F F
    F B A B C A B C A B A B C A
  • B C D E A F F F F F B A B C A B C A B A B C D E A
    F F F F F E B C A F F F F F B
  • A B C A B C A B A B C D E A F F F F F B C A B A B
    C A B C D E A F F F F F B A
  • B C A B C A B A B C A B C D E A F F F F F B A B C
    A B C A B A B C D E A F F F
  • F F B C A B A B C A B C A B A B C D E A F F F F F
    B C A B A B C A B C D E A F
  • F F F F B A B C A B C A B A B C A B C D E A F F F
    F F E B A F F F F F B C A B C
  • A B A B C D E A F F F F F B C A B A B C A B C A B
    A B C D E A F F F F F B C A
  • B A B C A B C D E A F F F F F B A B C A B C A B A
    B C A B C D E A F F F F F B
  • A B C A B C A B A B C D E A F F F F F B C A B A B
    C A B C A B A B C D E A F
  • F F F F B C A B A B C A B C D E F F F F F E F F F
    F F

Source Shuvra Bhattacharyya
49
Selected Generalizations
  • Multidimensional Synchronous Dataflow (1993)
  • Arcs carry multidimensional streams
  • One balance equation per dimension per arc
  • Cyclo-Static Dataflow (Lauwereins, et al., 1994)
  • Periodically varying production/consumption rates
  • Boolean Integer Dataflow (1993/4)
  • Balance equations are solved symbolically
  • Permits data-dependent routing of tokens
  • Heuristic-based scheduling (undecidable)
  • Dynamic Dataflow (1981-)
  • Firings scheduled at run time
  • Challenge maintain bounded memory, deadlock
    freedom, liveness
  • Demand driven, data driven, and fair policies all
    fail
  • Kahn Process Networks (1974-)
  • Replace discrete firings with process suspension
  • Challenge maintain bounded memory, deadlock
    freedom, liveness
  • Heterochronous Dataflow (1997)
  • Combines state machines with SDF graphs
  • Very expressive, yet decidable

50
Multidimensional SDF(Lee, 1993)
  • Production and consumption of N-dimensional
    arrays of data
  • Balance equations andscheduling
    policiesgeneralize.
  • Much more data parallelism is exposed.

(40, 48)
(8, 8)
Similar (but dynamic) multidimensional streams
have been implemented in Lucid.
51
MDSDF Structure ExposesFine-Grain Data
Parallelism
However, such programs are extremely hard to
write (and to read).
52
Cyclostatic Dataflow (CSDF)(Lauwereins et al.,
TU Leuven, 1994)
  • Actors cycle through a regular production/consumpt
    ion pattern.
  • Balance equations become

cyclic production pattern
fire B consume M
fire A produce
channel
53
Boolean and Integer Dataflow (BDF, IDF)(Lee and
Buck, 1993)
  • Balance equations are solved symbolically in
    terms of unknowns that become known at run time.
  • An annotated schedule is constructed with
    predicates guarding each action.
  • Existence of such an annotated schedule is
    undecidable (as is deadlock bounded memory)

b
b
B
A
E
select
switch
C
1- b
1- b
D
b
Production rate is unknown and is represented
symbolically by a variable (b).
54
Dynamic Dataflow (DDF)
  • Actors have firing rules
  • Set of finite prefixes on input sequences
  • For determinism No two such prefixes are
    joinable under a prefix order
  • Firing function applied to finite prefixes yield
    finite outputs
  • Scheduling objectives
  • Do not stop if there are executable actors
  • Execute in bounded memory if this is possible
  • Maintain determinacy if possible
  • Policies that fail
  • Data-driven execution
  • Demand-driven execution
  • Fair execution
  • Many balanced data/demand-driven strategies
  • Policy that succeeds (Parks 1995)
  • Execute with bounded buffers
  • Increase bounds only when deadlock occurs

DDF, like BDF and IDF is undecidable (deadlock,
bounded memory, schedule)
55
Undecidability(Buck 93)
  • Sufficient set of actors for undecidability
  • boolean functions on boolean tokens
  • switch and select
  • initial tokens on arcs
  • Undecidable
  • deadlock
  • bounded buffer memory
  • existence of an annotated schedule

These four parts are sufficient to build any
computable function.
1
b
b
boolean function
1
1
1
T
T
select
switch
F
F
initial token
1
1- b
1- b
1
1
BDF, IDF, DDF, and PN are all undecidable in this
sense. Fortunately, we can identify a large
decidable subset, which we call heterochronous
dataflow (HDF).
56
Example of a Heterochronous Dataflow Model
An actor consists of a state machine and
refinements to the states that define behavior.
57
Heterochronous Dataflow (HDF)(Girault, Lee, and
Lee, 1997)
  • An interconnection of actors.
  • An actor is either SDF or HDF.
  • If HDF, then the actor has
  • a state machine
  • a refinement for each state
  • where the refinement is an SDF or HDF actor
  • Operational semantics
  • with the state of each state machine fixed, graph
    is SDF
  • in the initial state, execute one complete SDF
    iteration
  • evaluate guards and allow state transitions
  • in the new state, execute one complete SDF
    iteration
  • HDF is decidable
  • but complexity can be high

Related to parameterized dataflow of
Bhattachrya and Bhattacharyya (2001).
58
Ptolemy II Software ArchitectureBuilt for
Extensibility
  • Ptolemy II packages have carefully constructed
    dependencies and interfaces

CSP
CT
PN
DE
FSM
SDF
59
Ptolemy II Component Library
UML package diagram of key actor libraries
included with Ptolemy II.
  • Data polymorphic components
  • Behaviorally polymorphic components

60
Polymorphic Components - Component Library Works
Across Data Types and Domains
  • Data polymorphism
  • Add numbers (int, float, double, Complex)
  • Add strings (concatenation)
  • Add composite types (arrays, records, matrices)
  • Add user-defined types
  • Behavioral polymorphism
  • In dataflow, add when all connected inputs have
    data
  • In a time-triggered model, add when the clock
    ticks
  • In discrete-event, add when any connected input
    has data, and add in zero time
  • In process networks, execute an infinite loop in
    a thread that blocks when reading empty inputs
  • In CSP, execute an infinite loop that performs
    rendezvous on input or output
  • In push/pull, ports are push or pull (declared or
    inferred) and behave accordingly
  • In real-time CORBA, priorities are associated
    with ports and a dispatcher determines when to add

By not choosing among these when defining the
component, we get a huge increment in component
re-usability. But how do we ensure that the
component will work in all these circumstances?
61
Shared InfrastructureModularity Mechanisms
execution
local class definition
instance
instance
inherited actors
override actors
subclass
62
More Shared Infrastructure Hierarchical
Heterogeneity and Modal Models
continuous-time model
modal model
dataflow controller
example Ptolemy II model hybrid control system
63
Branding
  • Ptolemy II configurations are Ptolemy II models
    that specify
  • welcome window
  • help menu contents
  • library contents
  • File-gtNew menu contents
  • default model structure
  • etc.
  • A configuration can identify its own brand
    independent of the Ptolemy II name and can have
    more targeted objectives.
  • An example is HyVisual, a tool for hybrid system
    modeling. VisualSense is another tool for
    wireless sensor network modeling.

64
Ptolemy II Extension Points
  • Define actors
  • Interface to foreign tools (e.g. Python, MATLAB)
  • Interface to verification tools (e.g. Chic)
  • Define actor definition languages
  • Define directors (and models of computation)
  • Define visual editors
  • Define textual syntaxes and editors
  • Packaged, branded configurations
  • All of our domains are extensions built on a
    core infrastructure.

65
Example Extension VisualSense
  • Branded
  • Customized visualization
  • Customized model of computation (an extension of
    DE)
  • Customized actor library
  • Motivated some extensions to the core (e.g.
    classes, icon editor).

66
Example Extensions Self-Repairing Models
  • Concept demonstration built together with Boeing
    to show how to write actors that adaptively
    reconstruct connections when the model structure
    changes.

67
Example ExtensionsPython Actors and Cal Actors
  • Cal is an experimental language for defining
    actors that is analyzable for key behavioral
    properties.

68
Example ExtensionsUsing Models to Control Models
  • This is an example of a higher-order component,
    or an actor that references one or more other
    actors.

69
Examples of ExtensionsMobile Models
Model-based distributed task management
Authors Yang Zhao Steve Neuendorffer Xiaojun Liu
MobileModel actor accepts a StringToken
containing an XML description of a model. It then
executes that model on a stream of input data.
PushConsumer actor receives pushed data provided
via CORBA, where the data is an XML model of a
signal analysis algorithm.
70
Examples of ExtensionsHooks to Verification Tools
New component interfaces to Chic verification tool
Authors Arindam Chakrabarti Eleftherios
Matsikoudis
71
Examples of ExtensionsHooks to Verification Tools
Synchronous assume/guarantee interface
specification for Block1
Authors Arindam Chakrabarti Eleftherios
Matsikoudis
72
Examples of ExtensionsHooks to Verification Tools
73
Conclusion
  • Threads suck
  • There are many alternative concurrent MoCs
  • The ones you know are the tip of the iceberg
  • Ptolemy II is a lab for experimenting with them
  • Specializing MoCs can be useful
  • Mixing specialized MoCs can be useful.
Write a Comment
User Comments (0)
About PowerShow.com