data flow graphs intro - thecatweb.cecs.pdx.edu/~mperkows/temp/july/data-flow-graph.pdf · data...

31
Data Flow Graphs Data Flow Graphs Intro Intro Sources: Gang Quan

Upload: truongthuy

Post on 20-Mar-2018

220 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Data Flow GraphsData Flow GraphsIntroIntro

Sources: Gang Quan

Page 2: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Computational ModelsComputational Models� What:

– A conceptual notion for expressing the function of a system� E.g. DFG, FSM, Petri net, Turing machine, etc.

� Computational Models & Languages– Models express the behavior, languages capture models– Models are conceptual, languages are concrete

� What is in a computational model– A set of objects– Rules– Semantics

Page 3: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Data Flow Graph (DFG)Data Flow Graph (DFG)� A modem communications system

– Each box is a single function or sub systems– The activity of each block in the chain depends on the

input of the previous block– Data driven

� Each functional block may have to wait until it receives a"certain amount" of information before it begins processing

� Some place to output the results

Page 4: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Data Flow GraphData Flow Graph� Definition

– A directed graph that shows the data dependenciesbetween a number of functions

– G=(V,E)� Nodes (V): each node having input/output data ports� Arces (E): connections between the output ports and input

ports– Semantics

� Fire when input data are ready� Consume data from input ports and produce data to its output

ports� There may be many nodes that are ready to fire at a given time

Page 5: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Data Flow Graph ConstructionData Flow Graph Construction

aacbbx

242

1−+−=

aacbbx

242

2−−−=

Page 6: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

-1

+

-

x

/

**

sqrt

x

x

b 4 c a 2

-/

X1X2

aacbbx

242

1−+−=

aacbbx

242

2−−−=

Page 7: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Data flow graph constructionData flow graph construction

original code:x <= a + b;y <= a * c;z <= x + d;x <= y - d;x <= x + c;

a b c d

+ *

+

+

y xzx

-

x

Page 8: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Data flow graph constructionData flow graph constructionoriginal code:x <= a + b;y <= a * c;z <= x + d;x <= y - d;x <= x + c;

single-assignment form:x1 <= a + b;y <= a * c;z <= x1 + d;x2 <= y - d;x3 <= x2 + c;

Page 9: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Data flow graph constructionData flow graph constructionsingle-assignment form:x1 <= a + b;y <= a * c;z <= x1 + d;x2 <= y - d;x3 <= x2 + c;

a b c d

+ *

+

+y

x3

z

x1

-

x2

Page 10: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Design IssuesDesign Issues� Allocating� Mapping� Schedule� Memory management� Construction and usage of the queues

Page 11: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

GoalsGoals� Guarantee correct behavior� Utilize hardware efficiently.� Obtain acceptable performance.

Page 12: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

AllocationAllocation� Decide the numbers and types of different functional

units– E.g. register allocation

….x <= a + b;y <= a + c;x <= x - c;….….x …….y….

….x <= a + b;y <= a + c;x <= x - c;….….x …….y….

three registers

Page 13: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

MappingMapping

� Distributing nodes to different functionalunits on which they will fire– Functional units may provide different functions

� Adder or ALU, MUX or buses, etc

– Functional units may have different delay� Ripple adder or look ahead adder

– Determines area, cycle time.

Page 14: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

A Mapping ExampleA Mapping Example

Subject to:

• Two adders• Four registers• b and e cannot be assigned

to the same register

+

+

a b

c

e

+

d

f

Page 15: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

A Mapping ExampleA Mapping Example

R1: aR2: b, c, eR3: d, f

+

+

a b

c

e

+

d

f

Subject to:• Two adders• Three registers• a and e cannot be

assigned to the sameregister

R3

Adder 1

R1 R2

Adder 2

Mapping may not be unique !

Page 16: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Scheduling of DFGScheduling of DFG

� Schedule– Creating the sequence in which nodes fire– Determines number of clock cycles required

� Two simple schedules:– As-soon-as-possible (ASAP) schedule puts

every operation as early in time as possible– As-late-as-possible (ALAP) schedule puts

every operation as late in schedule as possible

Page 17: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

ASAPASAP

+

-

/

*-1

+

** t=0

t=1

t=2

t=3

t=4

+/ **-1

-

*

+

Nodes fire whenever the input data are available.

Page 18: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

ALAPALAP

+

-

/

*-1

+

** t=0

t=1

t=2

t=3

t=4

+/

**

-1

-

*

+

Nodes fire when absolutely necessary.

Page 19: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

More about ASAP and ALAPMore about ASAP and ALAP� Unlimited resources

– No limit for the number of registers, adders, etc� Longest path through data flow determines

minimum schedule length� Mobility

– tL – tS

Page 20: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

MobilityMobility

� u = tL - tS

t=0t=1t=2t=3t=4

+/ **-1-*+

t=0t=1t=2t=3t=4

+/**

-1-

*+

ASAP

ALAP

+

/

**

-1

-

*

+

u00

0

1

0

2

0The node mobility represents its flexibility in the fire sequence.

Page 21: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Restrained SchedulingRestrained Scheduling

� Time constraints– Time is given, minimize the resource

� Resource constraints� NP problem

Page 22: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Time ConstraintsTime Constraints

-1

+

-

x

/

**

sqrt

x

x

b 4 c a 2

- /X1

X2

T22

1

1

1

6 7 8

+/-*//

**sqrt

-1

12

11

1

11

1

1

1

Page 23: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Resource ConstraintsResource Constraints

� Resource is given, minimize the long time� List based scheduling

– Maintain a priority based ready list� The priority can be decide by mobility for example

– Fire the nodes according to their priorities until allthe resource are used in that stage

Page 24: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

List Based SchedulingList Based Scheduling

+

-

/

*+

+

+

t=0

t=1

t=2

t=3

t=4

+/

-

* +

+

S.t: one +/-, one *//

/ + + - * + +

u 0 0 1 0 0 2 0

t=5 +

Page 25: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

List Based SchedulingList Based Scheduling

� A general ASAP� Priority based ready list

Page 26: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Control/Data Flow GraphControl/Data Flow Graph(CDFG)(CDFG)

x <= a + b;if ( x > 100) y <= a * c;else y <= a + c;endif

Page 27: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Control/Data Flow GraphControl/Data Flow Graph� Definition

– A directed graph that represents the controldependencies among the functions

� branch� fall-through

– G=(V,E)� Nodes (V)

– Encapsulated DFG– Decision

� Arces (E)– flow of the controls

Page 28: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

CDFG ExampleCDFG Examplefun0();if (cond1) fun1();else fun2();fun3();switch(test1) {case 1: fun4();

break;case 2: fun5();

break;case 3: fun6();

break;}fun7();

fun0

cond1

fun3

fun2fun1

fun5 fun6fun4

fun7

test1

Y N

Page 29: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

CDFG ExampleCDFG Example

fun0();while(cond1) { fun1();}fun2();

fun0

cond1

fun3

fun2Y

N

Page 30: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

Design IssuesDesign Issues

� Code optimization– Loop optimization, dead code detection

� Register allocation

Page 31: Data Flow Graphs Intro - TheCATweb.cecs.pdx.edu/~mperkows/temp/JULY/data-flow-graph.pdf · Data Flow Graph (DFG) A modem communications system – Each box is a single function or

SummarySummary� Data Flow Graph (DFG)

– models data dependencies.– Does not require that nodes be fired in a particular

order.– Models operations in the functional model—no

conditionals.– Allocation and Mapping– Scheduling – ASAP, ALAP, List-based scheduling

� Control/Data Flow Graph– Represents control dependencies