43
An Introduction to Synchronous Data Flow Model Dr. Haitao Wei CAPSL at UDEL CPEG-852:Advanced Topics in Computing Systems 9/22/15

An Introduction to Synchronous Data Flow Model Introduction to Synchronous Data Flow Model Dr. HaitaoWei ... return to its initial status after each node ... • If i is an input channel

  • Upload
    letuyen

  • View
    230

  • Download
    0

Embed Size (px)

Citation preview

An Introduction to

Synchronous Data Flow Model

Dr. Haitao WeiCAPSL at UDEL

CPEG-852:Advanced Topics in Computing Systems 9/22/15

Outline

• Synchronous Data Flow Model

– Definition

– Example

• Periodic Schedule and Consistency

• Stream Programming Language

– Structured SDF

• Apply SDF to Bigdata

1

Outline

• Synchronous Data Flow Model

– Definition

– Example

• Periodic Schedule and Consistency

• Stream Programming Language

– Structured SDF

• Apply SDF to Bigdata

2

Synchronous Data Flow Model

3

A B

C

D

E

3

4

2

1

2

1

4

2

• Synchronous Data Flow (SDF) is

represented as a graph

– Node (actor): Computation

– Edge: First In First Out (FIFO) Queue

• Each edge has two weights: produce

rate and consume rate

• Each edge can also have initial data

• Formal: Tuple<N, E, Ep,c,i>,

– N: node

– E: edge

– Ep,c,i: Produce rate, consume rate and initial

data

Synchronous Data Flow Model

4

SDF with no initial tokens SDF with initial token and loop

A

C

B

2

1 1

2

1

1

1

1

A

C

B

2

1 1

2

1

1

Synchronous Data Flow Model

5

A firing

A

C

B

2

1 1

2

1

1

Synchronous Data Flow Model

6

A firing, B firing

A

C

B

2

1 1

2

1

1

Synchronous Data Flow Model

7

A firing, B firing, C firing

A

C

B

2

1 1

2

1

1

Synchronous Data Flow Model

8

A firing, B firing, C firing, C firing

A

C

B

2

1 1

2

1

1

Synchronous Data Flow Model

9

SDF with initial token and loop

A

C

B

2

1 1

2

1

1

1

1

Synchronous Data Flow Model

10

A firing

A

C

B

2

1 1

2

1

1

1

1

Synchronous Data Flow Model

11

A firing, B firing

A

C

B

2

1 1

2

1

1

1

1

Synchronous Data Flow Model

12

A firing, B firing, C firing

A

C

B

2

1 1

2

1

1

1

1

Synchronous Data Flow Model

13

A firing, B firing, C firing, C firing

A

C

B

2

1 1

2

1

1

1

1

Synchronous Data Flow Model

• Question: Can any SDF graph find a firing sequences

that makes the state of the graph no changed?

– State of the graph means: the tokens on each edge are clean, no

more no less.

– Which leads to SDF Consistency Problem

14

Outline

• Synchronous Data Flow Model

– Definition

– Example

• Periodic Schedule and Consistency

• Stream Programming Language

– Structured SDF in StreamIt

• Apply SDF to Bigdata

15

Periodic Schedule and Consistency

• Firing sequence of a SDF is called a schedule

• A periodic schedule of an SDF clears all channels and

return to its initial status after each node repeats

execution a specified finite number of times

• Periodic schedule, permit SDF can process unbounded

data with bounded memory

• A SDF is Consistent if a periodic schedule exists

16

Periodic Schedule and Consistency

17

Periodic Schedule: ABCC

AB2C

A

C

B

2

1 1

2

1

1

Periodic Schedule and Consistency

18

Can you find the periodic schedule?

A

C

B

2

1 1

1

1

1

Periodic Schedule and Consistency

19

A

A

C

B

2

1 1

1

1

1

Periodic Schedule and Consistency

20

A, B

A

C

B

2

1 1

1

1

1

Periodic Schedule and Consistency

21

A, B, C

A

C

B

2

1 1

1

1

1

Periodic Schedule and Consistency

22

A, B, C, A

A

C

B

2

1 1

1

1

1

Periodic Schedule and Consistency

23

A, B, C, A, B

A

C

B

2

1 1

1

1

1

Periodic Schedule and Consistency

24

A, B, C, A, B, C

A

C

B

2

1 1

1

1

1

Tokens in channel (A-C) is accumulating

which makes the channel unbounded

Inconsistent!

Periodic Schedule and Consistency

25

A

C

B

d

f g

i

c

e

Problem: Given a general SDF, how can we

know it has periodic schedule or not?

Periodic Schedule and Consistency

26

A

C

B

d

f g

i

c

e

Topology Matrix

• Each row presents the edge

• Each column presents a node

• (i, j): the number of data items placed on i

after each invocation of j

• If i is an input channel for j, element (i, j)

is negative

A B C

AB

AC

BC

Periodic Schedule and Consistency

27

A

C

B

d

f g

i

c

e

A necessary condition for the existence of a

periodic schedule

•the rank of the topology matrix is s − 1,

where s is the number of nodes

•Proof: please refer to “Lee’s 87 paper:

Synchronous Data Flow”

A B C

AB

AC

BC

Periodic Schedule and Consistency

28

A B C

AB

AC

BC

A

C

B

2

1 1

1

1

1

Rank=3 > 2

A necessary condition for the existence of a

periodic schedule

•the rank of the topology matrix is s − 1,

where s is the number of nodes

•Proof: please refer to “Lee’s 87 paper:

Synchronous Data Flow”

Outline

• Synchronous Data Flow Model

– Definition

– Example

• Periodic Schedule and Consistency

• Stream Programming Language

– Structured SDF

• Apply SDF to Bigdata

29

An Stream Example—Average Pairs

30

SourceModule

AveragePairs

SinkModule

while ( true ) { int itm = geneDataItem (); push(itm);

}

while(inStream.moreData()) {int first=peek(0); int second=peek(1);push ((first+second)/2);pop(0); }

while (inStream .moreData ()) { print(pop(0));

}

Average Pairs to Synchronous Dataflow

Graph

31

Source SinkAverage

Pairspush=1

peek=2

pop=1 push=1

Extend the SDF to support “peek” sematic

pop=1

Average Pairs to Synchronous Dataflow

Graph

32

Source SinkAverage

Pairs

2 86 4…

Average Pairs to Synchronous Dataflow

Graph

33

Source SinkAverage

Pairs

… 2 86 4…

Average Pairs to Synchronous Dataflow

Graph

34

Source SinkAverage

Pairs

526 4…

Average Pairs to Synchronous Dataflow

Graph

35

Source SinkAverage

Pairs

36 4… 5

Average Pairs to Synchronous Dataflow

Graph

36

Source SinkAverage

Pairs

36… 55

Structured SDF In StreamIt

• Filter

• Pipeline

• Split-Join

• Feedback Loop

37

Structured Streams

i li

filter • Each structure is single-

input single-outputmay be

any StreamIt

language

pipeline input, single-output

• Hierarchical and

composableconstruct

splitjoin

composable

joinersplitter

feedback loopp

joiner splitter

Structured Streams

i li

filter • Each structure is single-

input single-outputmay be

any StreamIt

language

pipeline input, single-output

• Hierarchical and

composableconstruct

splitjoin

composable

joinersplitter

feedback loopp

joiner splitter

Structured Streams

i li

filter • Each structure is single-

input single-outputmay be

any StreamIt

language

pipeline input, single-output

• Hierarchical and

composableconstruct

splitjoin

composable

joinersplitter

feedback loopp

joiner splitter

Structured Streams

i li

filter • Each structure is single-

input single-outputmay be

any StreamIt

language

pipeline input, single-output

• Hierarchical and

composableconstruct

splitjoin

composable

joinersplitter

feedback loopp

joiner splitter

Courtesy by: PACT 2010 paper of streamit: “An Empirical Characterization of

Stream Programs and its Implications for Language and Compiler Design ”

Part of JPEG transcoder

38Courtesy by: PACT 2010 paper of streamit: “An Empirical Characterization of

Stream Programs and its Implications for Language and Compiler Design ”

Weakness of SDF

39

• Does not support condition (branch)

• Does not support recursion—because it is a static

dataflow model

• But still the model is used widely in many

application fields

Some Projects Based on SDF model

• Early Ptolemy Project at UC Berkeley

– Software Synthesis for Embedded system

• StreamIt at MIT

– streaming program language and compiler

• InforStream and SPL

– IBM streaming computing product

• Our work COStream

– hierarchical date flow programming language and compiler

• OpenStream

– language and compiler support for streaming in OpenMP

40

Homework

• Write a Fibonacci number generator using Synchronous

Data Flow Model

– Pseudo code for each node in SDF using “peek, push and pop”

statements

– Push Token: PPT animation to show how the tokens flow in SDF

graph

– Periodic Schedule of the SDF

41

Reference

[1] Early Ptolemy Project at UC Berkeley

– http://ptolemy.eecs.berkeley.edu/projects/index.htm

[2] StreamIt at MIT

– http://groups.csail.mit.edu/cag/streamit/

[3] InforStream and SPL

– http://www-03.ibm.com/software/products/en/infosphere-streams

[4] COStream

– http://www.capsl.udel.edu/pub/doc/papers/dfm12.pdf

[5] OpenStream

– http://openstream.info/

42