1 correct and efficient implementations of synchronous models on asynchronous execution platforms...
TRANSCRIPT
1
Correct and efficient implementations of synchronous models on asynchronous execution platforms
Stavros TripakisUC Berkeley and Verimag
EC^2 Workshop, Grenoble, June 2009
2
Some observations
• Concurrency => interleaving– C.f., synchronous systems (e.g., circuits)
• Concurrency => non-determinism– synchronous circuits are deterministic
• Concurrency => shared memory– C.f., data flow models
• Asynchronous concurrency (interleaving) => non-determinism – C.f., Kahn Process Networks
Threads have conquered the world, but …
3
What are the problems we (as a community) are trying to solve?
• Cope with concurrency… but what does it mean?• What are the right execution platforms?– Which multicore architecture, memory model, …
• What are the right programming models?• For which types of applications?• How to map the latter to the former?– Correctly and efficiently!
• How to verify stuff?
± given,synchronous
given,asynchronous
focus
4
Synchronous vs. asynchronous concurrency
• Synchronous concurrency– Execution platforms: synchronous hardware– Programming models: Simulink, SCADE, synchronous
languages (Esterel, Lustre, …), …• Asynchronous concurrency– Execution platforms: many, including distributed
platforms– Programming models: thread-based (often
communicating by shared-memory)
5
Concurrency => non-determinism
• Most synchronous models are deterministic: synchronous hardware, Simulink, SCADE, most synchronous languages, …
Copyright The Mathworks
Engine control model in Simulink
6
Concurrency => non-determinism
• Some asynchronous models are also deterministic, e.g.:– Kahn Process Networks: the sequence of values
(stream) produced at each FIFO is the same independent of process interleaving
7
Our choice of programming model: synchronous
• Set of parallel processes, notion of global synchronous cycle– Simulink, SCADE, VHDL, Verilog, Lustre, Esterel, …
• Main advantages:– Determinism, no process interleaving:
• Easier to understand, easier to verify (less state explosion)
• Main objections:– “Synchrony is impossible/hard/too expensive to implement”– “This is especially true for distributed systems”
• “You need clock synchronization”– Practice seems to agree with this…
• Most available implementations of synchronous systems are either synchronous hardware, or centralized “read; compute; write;” control loops.
– …but it is not quite true.
8
Semantics-preserving implementation of synchronous models
Simulink
single-processorsingle-task
single-processormulti-task
distributed,synchronous(TTA) …
…
distributed,asynchronous(KPN, LTTA, ...)
application
executionplatform
design
implementation
9
From synchronous models to asynchronous distributed implementations
Joint work with Claudio Pinello, Cadence
Alberto Sangiovanni-Vincentelli, UC BerkeleyAlbert Benveniste, IRISA (France)
Paul Caspi, VERIMAG (France)Marco di Natale, SSSA (Italy)
[IEEE Trans. Computers, Oct’08]
10
Implementation on asynchronous distributed platforms
• Asynchronous distributed platforms:– Many computers, each with a
local clock• No clock synchronization
– Computers communicate using some network/protocol• Don’t care which network, as
long as finite FIFO queues (TCP) can be implemented on top
synchronous model
asynchronous platformwith some communication network
11
Implementation on asynchronous distributed platforms
synchronous model
asynchronous platformwith some communication network
Intermediate layer:asynchronous processes
communicating with finite FIFO queues
12
Implementation on asynchronous distributed platforms
synchronous model
Intermediate layer:asynchronous processes
communicating with finite FIFO queues
This is like Kahn Process Networks with blocking write()
when FIFO is full.
FIFOs must be largeenough to avoid
deadlocks.
=> semantical (stream) preservation
Semantical preservation: proof
• Use old theories [1970s]:
• Marked graphs– Subclass of Petri Nets– Used to show FFP liveness (no
deadlock)
• Kahn Process Networks– Used Kahn’s fundamental result:
determinism– Streams do not depend on
process interleaving13
14
Performance analysis: worst-case logical-time throughput and latency
Computing worst-case logical-time throughput
1Reachability lasso of marked graph
LT thput = 3/4
deterministic firing policy
Relating real-time and logical-time throughput
P1 P2
P1 P2
WCLTT = 1/2
WCLTT = 1
15
From synchronous models toasynchronous multitask implementations
Joint work with Paul Caspi,
Norman Scaife, Christos Sofronis,
VERIMAG
[ACM Trans. Embed. Comp. Sys., Feb’08]
16
Implementation on centralized, multitasking platforms
Sync
Single-processorPriority scheduling(fixed priority or EDF)
scheduler
T1 T2 T3
tasks
• Why multitasking and not single “real-compute-write” loop?
• For multi-rate models:– Multitask implementation
schedulable, but single-task not schedulable
17
Implementation on centralized, multitasking platforms
Sync
Single-processorPriority scheduling(fixed priority or EDF)
scheduler
T1 T2 T3
tasks
Goal:semantical preservation
18
Implementation on centralized, multitasking platforms
Sync
Single-processorPriority scheduling(fixed priority or EDF)
1
“Naïve” implementations don’t work
Q PrioQ > PrioA > PrioB
A
Q
BA
AQ
A B
A B
ERROR
The Dynamic Buffering Protocol
scheduler
T1 T2 T3
tasks
- non-blocking (wait-free)- memory-optimal- semantics-preserving
19
Conclusions
• Concurrency => non-determinism• Synchronous models are deterministic– easier to understand and verify
• Synchronous models can be implemented on a variety of asynchronous execution platforms, using non-trivial techniques:– Implementations are correct-by-construction– They are memory-optimal– Performance (throughput, latency, …) can be analyzed
and optimized
20
Open questions• For which applications is the synchronous
programming model suitable?– Traditionally for control: avionics, automotive, …– Some recent works trying to apply it to multimedia/signal
processing
• To what extent these methods apply to multicores?
• Are dataflow computers going to come back?