EE 144/244: Fundamental Algorithms for System Modeling...

16
EE 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization Fall 2014 Dataflow – Timed SDF, Throughput Analysis Stavros Tripakis University of California, Berkeley Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 1 / 31 Main application of SDF: DSP hardware modeling Orthogonal Frequency Division Multiple Access (OFDMA) application modeled in (timed) SDF: ET=1 1 Src 1 Sink 2560 2048 IFFT 2048 600 ZeroPad ET=7838 ET=2048 24 32 FIR FIR 25 25 ET=144 ET=192 ET=1 IFFT and FIR actors are configurable IPs from the Xilinx Coregen library, while the rest are user defined actors (source: National Instruments, e.g., see [Tripakis et al., 2011, Tripakis et al., 2012]). Where do execution times come from? For existing hardware: measure clock cycles. To-be-synthesized hardware: estimate (harder problem). Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 2 / 31

Transcript of EE 144/244: Fundamental Algorithms for System Modeling...

Page 1: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

EE 144/244: Fundamental Algorithms for

System Modeling, Analysis, and Optimization

Fall 2014

Dataflow – Timed SDF, Throughput Analysis

Stavros TripakisUniversity of California, Berkeley

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 1 / 31

Main application of SDF: DSP hardware modeling

Orthogonal Frequency Division Multiple Access (OFDMA)application modeled in (timed) SDF:

ET=1

1

Src

1

Sink

25602048

IFFT

2048600

ZeroPad

ET=7838ET=2048

24 32

FIR FIR

25 25

ET=144 ET=192ET=1

IFFT and FIR actors are configurable IPs from the Xilinx Coregenlibrary, while the rest are user defined actors (source: NationalInstruments, e.g., see [Tripakis et al., 2011, Tripakis et al., 2012]).

Where do execution times come from?

For existing hardware: measure clock cycles.

To-be-synthesized hardware: estimate (harder problem).

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 2 / 31

Page 2: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

TIMED SDF and

THROUGHPUT ANALYSIS

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 3 / 31

Timed SDF

A

3

B

7

C

5

1 2 3 1

A Timed SDF Graph

3, 7, 5: execution timesI how long it takes an actor to complete a firingI we will assume discrete time, can be extended to dense time

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 4 / 31

Page 3: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Timed SDF semantics

A Timed SDFG defines a labeled transition system:

States record:I number of tokens in every channel;I number of instances of every actor running;I how much time is left for each instance until it completes its

firing.

Transitions: 3 typesI a new instance begins firing;I an instance ends firing;I time passes.

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 5 / 31

Example

A

3

B

7

C

5

1 2 3 1

This timed SDFG defines the following LTS:

(g = (0, 0), h = {}

) beginA−→(g = (0, 0), h(A) = {3}

) tick−→(g = (0, 0), h(A) = {2}

)(g = (0, 0), h(A) = {3, 3}

)beginA· · ·

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 6 / 31

Page 4: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Timed SDF formal semanticsA Timed SDFG defines a labeled transition system:

State = a tuple (g, h) containing

I a vector g describing how many tokens are in every channelI a vector h describing

F how many instances of each actor are running andF how much time is left until each instance completes its firing.F h associates to each actor A a multiset h(A), i.e., a set which

may contain multiple “copies” of the same element, e.g.,{2, 2, 0}.

F Why a multiset?⇒ could have multiple instances of the same actor active at thesame time (parallelism, called autoconcurrency in SDF jargon).

Initial state (unique):

I g(c) = number of initial tokens of channel cI h(A) = ∅ for all A (no instances running initially).

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 7 / 31

Timed SDF formal semanticsTransitions: of 3 possible forms

(g, h)beginA−→ (g′, h′): a new instance of A begins to fire.

Precondition on g: enough tokens must be in the input queues of A.

g′: obtained by g by removing the corresponding tokens from the inputqueues of A.

h′(A): add to h(A) the execution time of A.

(g, h)tick−→ (g, h′): one time unit elapses.

Precondition on h: there is no A such that 0 ∈ h(A) (this would mean oneactor instance is ready to finish firing).

h′: decrement all actor instance execution times by 1.

(g, h)endA−→ (g′, h′): one instance of A finishes firing.

Precondition on h: 0 ∈ h(A).h′: remove one 0 from h(A).

g′: add to the output queues of A the tokens that A produces.

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 8 / 31

Page 5: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Example

A

3

B

7

C

5

1 2 3 1

This timed SDFG defines the following LTS:

(g = (0, 0), h = {}

) beginA−→(g = (0, 0), h(A) = {3}

) tick−→(g = (0, 0), h(A) = {2}

)(g = (0, 0), h(A) = {3, 3}

)beginA· · ·

As with untimed SDF, this LTS is generally infinite.

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 9 / 31

Forbidding autoconcurrency

How to forbid a new instance from starting until the previous onefinishes?

A

3

B

7

C

5

1 2 3 1

• • •

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 10 / 31

Page 6: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Pictorially

-B

A

A

time

· · · A

3

B

7

C

5

1 2 3 1

with autoconcurrency

-B

AA

time

· · · A

3

B

7

C

5

• • •

1 2 3 1

without autoconcurrency

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 11 / 31

ASAP LTS (“self-timed execution”)

The As Soon As Possible (ASAP) LTS of a Timed SDFG is definedas before, with the additional rule that:

A tick transition is allowed only if no begin transitions areenabled.1

Justification: to estimate throughput, no need to delay actor firingsunnecessarily.

1also if no end transitions are enabled, but that was already the case in theoriginal semantics

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 12 / 31

Page 7: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Pictorially

-B

AA

time

· · ·

ASAP execution

-

A

B

A

· · ·

time

non-ASAP execution (with “slack”)

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 13 / 31

Determinacy of ASAP execution

We can group together all non-tick transitions in a single transition:

Group everything that happens instantaneously.

Deterministic! (as with Kahn networks – interleavings don’taffect final result)

s1

s2

s3

s4

beginA

beginB

beginB

beginA

≡ s1 s4beginA

beginB

Similarly with end transitions.

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 14 / 31

Page 8: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Strongly-connected (SDF) Graphs

Where every node (actor) can be reached by a directed path fromevery other node.

Strongly-connected:

A B C

2 2

1 1•

2 2

1 1•

Not strongly-connected:

A B C

2 2 2 2

1 1•

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 15 / 31

Determinacy and finiteness of ASAP execution

Theorem ([Ghamarian et al., 2006])

In consistent and strongly-connected timed SDFGs the deterministicASAP execution is a lasso (an initial segment followed by a cycle).

A lasso:

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 16 / 31

Page 9: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Example: lasso of deterministic ASAP execution

Timed SDFG:

A B

2 2

1 1•3 7

Deterministic ASAP execution:(g = (0, 1), h = {}

) beginA−→(g = (0, 0), h(A) = {3}

) tick−→(g = (0, 0), h(A) = {2}

) tick−→ tick−→(g = (0, 0), h(A) = {0}

)

(g = (2, 0), h(A) = {}, h(B) = {}

)

(g = (0, 0), h(A) = {}, h(B) = {7}

)

endA

beginB(g = (0, 0), h(A) = {}, h(B) = {0}

) tick←− tick←− tick←− tick←− tick←− tick←− tick←−

endB

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 17 / 31

Determinacy and finiteness of ASAP execution

Theorem ([Ghamarian et al., 2006])

In consistent and strongly-connected timed SDFGs the deterministicASAP execution is a lasso (an initial segment followed by a cycle).

Does the theorem hold also in graphs that deadlock?

Yes: tick transitions are always possible (time cannot be stopped).

tick

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 18 / 31

Page 10: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Strongly-connected SDFGs ⇒ finite state-space

and bounded queues

Strongly-connected ⇒ state space is finite ⇒ queues remainbounded.

A B C

2 2

1 1•

2 2

1 1•3 7 2

What about non-strongly-connected SDFGs?

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 19 / 31

Non-strongly-connected SDFGs

A can fire arbitrarily many times in parallel (autoconcurrency) ⇒queue from A to B grows unbounded ⇒ infinite state-space.

A B C

2 2 2 2

1 1•3 7 2

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 20 / 31

Page 11: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Non-strongly-connected SDFGs

What about timed SDFGs without autoconcurrency?

A B C

2 2 2 2

1 1•

3 7 5

A’s rate of firing (throughput) only depends on its execution time.

Rate of firing of B,C (downstream strongly-connected sub-graph)constrained by that of A (upstream strongly-connected sub-graph).

⇒ We will analyze throughput separately for each strongly-connectedsub-graph.

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 21 / 31

What about this example?The SDFG below is not strongly connected:

ET=1

1

Src

1

Sink

25602048

IFFT

2048600

ZeroPad

ET=7838ET=2048

24 32

FIR FIR

25 25

ET=144 ET=192ET=1

Does it mean we won’t analyze throughput for this application?

In practice:

Problem: optimize buffer size.Target throughput: 25 M samples/sec.

⇒ buffer size is an input to the problem ⇒ finite queues ⇒strongly-connected graph.

P1

queue of size kP2

1 1= P1 P2

•k

1 1

1 1

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 22 / 31

Page 12: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

THROUGHPUT ANALYSIS

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 23 / 31

Throughput

Throughput (in general) = average rate.

e.g., communication networks: rate of data transmission

In our case:

average rate of token productions (in given channel)

average rate of actor firings (for given actor)

these are multiples of each other:I let µA be the rate of firings of actor AI let µα be the rate of token productions in channel αI if A produces k tokens in α every time it fires, then

µα = k · µA

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 24 / 31

Page 13: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Actor ThroughputLet A be an actor in the timed SDFG of interest.Let σ be an execution of the timed SDFG: σ is a trace in thecorresponding LTS.

Define throughput of A in σ:

Th(A, σ) =̂ limn→∞

# endA transitions up to first n ticks of σ

n

Let Th(A) denote the “best” (maximum) throughput:

Th(A) =̂ maxσ

Th(A, σ)

Theorem ([Ghamarian et al., 2006])

maxσ

Th(A, σ) = Th(A, the ASAP execution)

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 25 / 31

Actor Throughput

Quiz: Consider an SDFG that deadlocks and let A be an actor inthat SDFG.

What is the actor throughput Th(A)?

Does Th(A) depend on A in this case?

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 26 / 31

Page 14: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Computing the Actor Throughput

Let C denote the cycle of the ASAP execution lasso of the timedSDFG.

Theorem ([Ghamarian et al., 2006])

Th(A) =mA

m

where mA is the number of endA transitions in C and m is thenumber of tick transitions in C.

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 27 / 31

Example

A B

2 2

1 1•3 7

ASAP execution:(g = (0, 1), h = {}

) beginA−→(g = (0, 0), h(A) = {3}

) tick−→(g = (0, 0), h(A) = {2}

) tick−→ tick−→(g = (0, 0), h(A) = {0}

)

(g = (2, 0), h(A) = {}, h(B) = {}

)

(g = (0, 0), h(A) = {}, h(B) = {7}

)

endA

beginB(g = (0, 0), h(A) = {}, h(B) = {0}

) tick←− tick←− tick←− tick←− tick←− tick←− tick←−

endB

Th(A) = Th(B) =1

10

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 28 / 31

Page 15: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Couldn’t we do this more easily?

A B

2 2

1 1•3 7

1 Compute periodic schedule (while checking for deadlocks)

(AB)ω

2 Compute total duration of schedule

ET (A) + ET (B) = 3 + 7 = 10

3 Compute throughput

Th(A) =# times A appears in schedule

10=

1

10

Does this method work for all SDFGs?Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 29 / 31

Parallelism and pipelining!

A B

1 1

1 1

•3 6

The simplistic method of the previous slide gives:ET (A) + ET (B) = 9, therefore, estimates throughput to be 1

9.

The ASAP execution takes pipelining into account:

time

A

B

A

B

A

B

B

A

-

· · ·

and computes the correct (maximal, assuming parallelism)throughput:

Th(A) = Th(B) =2

9

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 30 / 31

Page 16: EE 144/244: Fundamental Algorithms for System Modeling ...embedded.eecs.berkeley.edu/eecsx44/lectures/Fall...Let Abe an actor in the timed SDFG of interest. Let ˙ be an execution

Bibliography

Ghamarian, A. H., Geilen, M., Stuijk, S., Basten, T., Theelen, B. D., Mousavi, M. R., Moonen, A. J. M., and Bekooij,

M. (2006).Throughput analysis of synchronous data flow graphs.In ACSD’06, pages 25–36.

Tripakis, S., Andrade, H., Ghosal, A., Limaye, R., Ravindran, K., Wang, G., Yang, G., Kornerup, J., and Wong, I.

(2011).Correct and non-defensive glue design using abstract models.In 9th Intl. Conf. Hardware/Software Codesign and System Synthesis (CODES+ISSS). ACM.

Tripakis, S., Limaye, R., Ravindran, K., and Wang, G. (2012).

On tokens and signals: Bridging the semantic gap between dataflow models and hardware implementations.Technical Report UCB/EECS-2012-164, EECS Department, University of California, Berkeley.

Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 Timed SDF, Throughput 31 / 31