Date post: | 21-Dec-2015 |
Category: |
Documents |
View: | 216 times |
Download: | 0 times |
Dataflow Process NetworksLee & Parks
Synchronous DataflowLee & Messerschmitt
Abhijit Davare
Nathan Kitchen
Dataflow
Data oriented Host Language
Java, C/C++ Coordination language
SDF, Cyclo-static Dataflow
Kahn Process Networks
Dataflow process networks are a special case of Kahn process networks.
P2
a, b, c A, B, C
unbounded
channels
P1 P3
Properties of Kahn Processes
The processes that we deal with are usually:ContinuousMonotonic
Which means that we can realistically compute them.
Continuous Processes
Formally:
Practically: A continuous process
will not wait for the end of an infinite input stream before producing an output.
)( FF
Monotonic Processes Adding to the input does not change the output
already produced. All continuous processes are monotonic.
monotonic not monotonic
P1, 2, 3 2, 4, 6
P1, 2 2, 4
P1, 2, 3 4, 2, 6
P1, 2 2, 4
Computing Continuous Processes Continuity means:
We can start producing the output stream before we have received all the input.
We can process an infinite stream with finite resources.
Networks of processes are determinate.
Nondeterminism
Pros: Compact system definition Incomplete specification OK
Cons: Loss of continuity Analysis more difficult
Nondeterminism (2) Nondeterminism can be added to KPN by:
Processes can test for empty channels Internal Nondeterminism Channel has multiple sources Channel has multiple sinks Processes have shared variables
rand()
x+=2
x=0 empty?
Streams Most relevant in real-time signal
processing Recursively defined or Channel oriented Be good at losing data, recycling memory,
and storing data.
Recursive Camp Channel Camp
Dataflow Processes
When a dataflow actor fires, it consumes inputs and produces outputs.
We get a dataflow process by repeatedly firing an actor.
2
2+ 4
Firing Rules for Actors
Dataflow processes are continuous if: Each actor firing is functional
(i.e., the outputs depend only on the inputs).
The firing rules are sequential. A firing rule is a set of patterns
that the inputs have to match.
Examples of Firing Rules
At least one token on each input: R1 = { [*], [*] }
The select channel chooses an input channel to take a token from: R1 = { [*], , [T] }
R2 = { , [*], [F] }
+[*]
[*]
[*]
[*]
F
T
Firing Rules in SDF
A synchronous dataflow actor has a single firing rule containing only wildcards—it is enabled by a fixed number of tokens.
downsample
4 1
R = { [*, *, *, *] }
Firing Rules with a Problem
At least one token on either input:
R1 = { [*, ] }, R2 = { [, *] } Which rule should be checked first? If we check
with a blocking read, we will deadlock.
These rules are not sequential.
merge merge
Sequential Firing Rules
If we can avoid deadlock by checking rules in the right order, the rules are sequential.
Example: the select actorR1 = { [*],, [T] }
R2 = { , [*], [F] }
We read the third input first, then we know which other input to read.
Implications of Sequentiality
All sequential processes are continuous, therefore determinate.
Networks of functional actors with sequential firing rules can be scheduled; we do not have to synchronize processes using blocking reads.
Execution models
For Dataflow Process Networks, execution independent of scheduling
1. Concurrent Processes
2. Dynamic Scheduling
3. Static Scheduling
B
Concurrent Processes
C
B
A
B
Concurrent Processes
C
B
A
hungry
B
Concurrent Processes
C
B
A
hungry
suspended
hungry
B
Concurrent Processes
C
B
A
hungrysuspended
hungry
suspended
hungry
enabled
Concurrent Processes(2)
Large overhead of context switching In general, increasing process granularity
decreases relative overhead
Dynamic Scheduling
Data dependencies can make static scheduling impossible
In particular, dynamic scheduling is necessary when number of input and output tokens for each actor cannot be defined a priori
Can be done in hardware or software Actors activated when inputs available
Static Scheduling
Must have number of input & output tokens predetermined for all actors
Best schedule chosen among several based on objective (e.g. minimum buffer size, minimum code size)
Used for:Code generation by code stitchingHW synthesis
Formalism for Static Scheduling
Rank: Number of linearly independent vectors
1
2
4
3
4080
1200
0120
0063
T
1
2
3
43
6
2
8
4
1
2
1
Formalism for Static Scheduling
Rank: Number of linearly independent vectors
1
2
4
3
4080
1200
0120
0063
T
1
2
3
43
6
2
8
4
1
2
1
Full rankNo periodic solution
Formalism for Static Scheduling
Rank: Number of linearly independent vectors
4080
2200
0120
0063
T
1
2
4
3
1
2
3
43
6
2
8
4
1
2
2
2
2
1
2
Jq
Correctness of SDF graphs
1 2
3
A
BC
1 1
1
11
2
Correctness of SDF graphs
1 2
3
A
BC
1 1
2
11
2
Correctness of SDF graphs
1 2
3
A
BC
1 1
1
11
1
Delays
On startup, need to make sure that arcs have enough tokens to activate nodes
b(i) represents number of tokens in buffer i
b(n+1) = b(n) + T v(n) b(0) affects which startup options are legal
Single Processor Static Scheduling
Class S algorithms:Given a firing vector (q) and the initial number
of tokens in each bufferSelect each runnable node and update b(n)
iterativelyList of these selected nodes forms schedule If schedule cannot be met, deadlock has
occurred
Parallel Processor Static Scheduling
Exploit concurrency to increase throughput
In this example, nodes 1 and 3 can be scheduled at the same time on different processors
Periodic Admissible Schedules:
{1,3,1,2}
{3,1,1,2}
{1,1,3,2}
Static Buffering
Minimize execution time by having memory locations embedded as constants in the code, not variables
iq = KN Where
i = Number of tokens emitted per firing q = Number of firings in one period N = Size of buffer K = an integer
Functional Behavior & Hierarchy
Dataflow Process Networks allow hierarchy
Functionality may be present at the higher level
Delay, internal state, and unbalanced subsystems can cause nodes to be non-functional
Dataflow and Functional Languages Actors correspond to first-order functions:
Processes are higher-order functions (they take functions as arguments):
Process F results from applying first-order function f to a stream that starts with R and continues with X.
yxyxf ),(
)(:)():( XRXR FfF
Language Features
RecursionIterationCarrying state
PolymorphismParallelism
Recursion Not needed in dataflow to carry state
(we have feedback loops) Can be used with high-order functions
for compact models (e.g., FFT)Expensive unless unrolled at setup time
Polymorphism
Tokens can have arbitrary typeArrays as sequence of tokensArrays as single tokens
In PtolemyOne actor can operate on several types
add doubles add ints (without converting to doubles)
Parallelism
Functional languages Explicit Thwarted by recursion Use higher-order functions for parallelism instead
Dataflow Implicit Use higher-order functions as syntactic sugar
Unrolled at setup time Still parallel!
Credits
Sean Connery as James Bond: http://www.speakeasy.org/~wvt3rd/ BONDLIT1.HTM
Screen Beans © 1995, 1996, 1997, 1998, 1999, 2000 A Bit Better Corporation
Screen Beans is a registered trademark of A Bit Better Corporation. Figures from “Dataflow Process Networks,” Lee & Parks, Proc.
IEEE, May 1995, and “Synchronous Data Flow,” Lee & Messerschmitt, Proc. IEEE, Sep 1987.
All episodes are filmed before a live studio audience. No animals were harmed during the production of this presentation.
Tagged Token Model
Tokens have tags + values
Out of order execution Channels are not FIFO Actors fire when input tags
match Graph would deadlock as
dataflow More expressive Limited value