CS137: Dynamic Programming Electronic Design Automation Solution - - PDF document

cs137 dynamic programming electronic design automation
SMART_READER_LITE
LIVE PREVIEW

CS137: Dynamic Programming Electronic Design Automation Solution - - PDF document

CS137b: Day2 CS137: Dynamic Programming Electronic Design Automation Solution Solution described is general instance of dynamic programming Require: optimal solution to subproblems is optimal solution Day 10: February 1, 2006


slide-1
SLIDE 1

1

CALTECH CS137 Winter2006 -- DeHon

1

CS137: Electronic Design Automation

Day 10: February 1, 2006 Dynamic Programming

CALTECH CS137 Winter2006 -- DeHon

2

Dynamic Programming Solution

  • Solution described is general instance of

dynamic programming

  • Require:

– optimal solution to subproblems is optimal solution to whole problem – (all optimal solutions equally good) – divide-and-conquer gets same (finite/small) number of subproblems

  • Same technique used for instruction selection

CS137b: Day2

CALTECH CS137 Winter2006 -- DeHon

3

Dynamic Programming

  • Two Examples

– SPLASH sequence matching/edit distances

  • O(N2) operation in O(N) time with O(N)

hardware

– CMU parenthesis matching

  • O(N3) operation in O(N) time with O(N2)

hardware

CALTECH CS137 Winter2006 -- DeHon

4

Sequence Matching

  • Find edit distance between two strings

– E.g.

  • Insert cost 1
  • Delete cost 1
  • Replace cost 2
  • Match 0
  • Primary Application:

– DNA Sequence comparison – Often compare new sequence against database

CALTECH CS137 Winter2006 -- DeHon

5

Edit Example

  • SHMOO

– Add E (cost 1)

  • SHMOOE

– Remove M (cost 1 + 1=2)

  • SHOOE

– Replace O with R (cost 2+2=4)

  • SHORE

CALTECH CS137 Winter2006 -- DeHon

6

Dynamic Programming

  • Build a table representing string prefixes

– Only m×n cases compute

  • Fill in costs
  • Cell (m,n) is

result

slide-2
SLIDE 2

2

CALTECH CS137 Winter2006 -- DeHon

7

Local Move Costs

  • D(0,0) = 0
  • D(i,0)=D(i-1,0)+Delete(Si)
  • D(0,j)=D(0,j-1)+Insert(Tj)
  • D(i,j)=min

D(i-1,j)+Delete(Si) D(i,j-1)+Insert(Tj) D(i-1,j-1)+Replace(Si,Tj)

[Constant work per cell to fillin]

CALTECH CS137 Winter2006 -- DeHon

8

Edit Distance Table

CALTECH CS137 Winter2006 -- DeHon

9

Systolic Array

  • Feed Strings from opposite ends
  • Compute along diagonals

CALTECH CS137 Winter2006 -- DeHon

10

Systolic Array

  • Feed Strings from opposite ends
  • Compute along diagonals

O O M H S S H O R E

CALTECH CS137 Winter2006 -- DeHon

11

Systolic Array

  • Feed Strings from opposite ends
  • Compute along diagonals

O O M H S S H O R E

CALTECH CS137 Winter2006 -- DeHon

12

Systolic Array

  • Feed Strings from opposite ends
  • Compute along diagonals

O O M H S S H O R E

When Src[i] and Targ[j] line up, Compute cell (i,j)

slide-3
SLIDE 3

3

CALTECH CS137 Winter2006 -- DeHon

13

Systolic Array

  • PEDist = minimum of

TDin+Cost(Delete(SCin)) SDin+Cost(Insert(TCin)) PEDist + Cost(Substitute(TCin,SCin))

  • SDout=TDout=PEDist
  • ….plus details for edge cases

D(i,j)=min D(i-1,j)+Delete(Si) D(i,j-1)+Insert(Tj) D(i-1,j-1)+Replace(Si, On previous cycle: Cell computes (i-1,j-1) T-neighbor (i-1,j) S-neighbor (i,j-1)

CALTECH CS137 Winter2006 -- DeHon

14

In Operation

(2,0) (1,0) (1,0) (0,0) (0,1) (0,1) (0,2) (0,2) (2,0) (3,0) 2 1 1 1 1 2 2 2 3 S H H S M

CALTECH CS137 Winter2006 -- DeHon

15

(2,0) (1,0) (1,0) (0,0) (0,1) (0,1) (0,2) (0,2) (2,0) (3,0) 2 1 1 1 1 2 2 2 3 S H H S M (2,0) (2,0) (1,0) (1,1) (0,1) (0,2) (0,2) (0,3) (3,0) (3,0) S H O H S M

CALTECH CS137 Winter2006 -- DeHon

16

(2,0) (2,0) (1,0) (1,1) (0,1) (0,2) (0,2) (0,3) (3,0) (3,0) 2 2 1 1 2 2 3 3 3 S H O H S M

CALTECH CS137 Winter2006 -- DeHon

17

(3,0) (2,0) (2,1) (1,1) (1,2) (0,2) (0,3) (0,3) (3,0) (4,0) S H O M H S O (2,0) (2,0) (1,0) (1,1) (0,1) (0,2) (0,2) (0,3) (3,0) (3,0) 2 2 1 1 2 2 3 3 3 S H O H S M

CALTECH CS137 Winter2006 -- DeHon

18

(3,0) (2,0) (2,1) (1,1) (1,2) (0,2) (0,3) (0,3) (3,0) (4,0) 3 2 1 1 2 3 3 3 4 S H O M H S O

slide-4
SLIDE 4

4

CALTECH CS137 Winter2006 -- DeHon

19

(3,0) (3,1) (2,1) (2,2) (1,2) (1,3) (0,3) (0,4) (4,0) (4,0) S H O R M H S O (3,0) (2,0) (2,1) (1,1) (1,2) (0,2) (0,3) (0,3) (3,0) (4,0) 3 2 1 1 2 3 3 3 4 S H O M H S O

CALTECH CS137 Winter2006 -- DeHon

20

(3,0) (3,1) (2,1) (2,2) (1,2) (1,3) (0,3) (0,4) (4,0) (4,0) 3 2 1 1 2 3 4 4 S H O R M H S O

CALTECH CS137 Winter2006 -- DeHon

21

Edit Distance Table

CALTECH CS137 Winter2006 -- DeHon

22

Details/Variations

  • Can have one stationary

– Unidirectional: compute row at a time – Most useful when matching single target to large collection of sources

  • Only need constant state per cell

– Delta from neighbor bounded – Similarly, small, constant-width cost datapaths

CALTECH CS137 Winter2006 -- DeHon

23

Implementation

  • On Splash2
  • Board with 16 XC4010s
  • 12MHz
  • 16PEs per XC4010

– XC4010 has 400CLBs=800 4-LUTs

  • 50 4-LUTs/PE

– Entire Splash 2: 12,800 4-LUTs

  • Less than XC2V6000 (40%)

CALTECH CS137 Winter2006 -- DeHon

24

Performance (un-normalized)

slide-5
SLIDE 5

5

CALTECH CS137 Winter2006 -- DeHon

25

Normalized Computational Density

(CM5 used Sparc Processors)

CALTECH CS137 Winter2006 -- DeHon

26

Non-Local

CALTECH CS137 Winter2006 -- DeHon

27

Sub-dividing into Trees

  • Optimal parenthesization
  • Deciding where to split a tree

– Perhaps for covering

  • Search Tree

CALTECH CS137 Winter2006 -- DeHon

28

Parenthesization

  • Have an associative sequence of operations
  • What is least cost way to parenthesize?

– E.g. 1 2 3 4 – (((1 2) 3 4) – (((1 (2 3)) 4) – ((1 2) (3 4)) – (1 ((2 3) 4)) – (1 (2 (3 4)))

CALTECH CS137 Winter2006 -- DeHon

29

Abstract Covering Problem

  • Given: Graph (V,E) with a single weight

(area) on each node and two weights (IO, cost) on the edges.

  • Cluster nodes into subsets Vi, such that

Σ (Cost(Vi)) minimized IO(Vi) < IO limit A(Vi) < Area limit Cost(Vi) = Σ(cost(e) | e ∈ E st. e1 ∈ Vi and e2 ∉Vi) PEs PE Communication

CALTECH CS137 Winter2006 -- DeHon

30

Idea

  • If we had an ordering of nodes

– (wishful thinking)

  • Then easy to know how to include more

– Just pick the next node

  • Order: 1D list of nodes
  • Cluster: a contiguous sequence of

nodes in list

– Specify start, finish

slide-6
SLIDE 6

6

CALTECH CS137 Winter2006 -- DeHon

31

From Sequence to Clusters

  • Easy to know if a contiguous

subsequence

– Meets area constraints – Meets io constraints

  • Cover

– Set of (non-overlapping) subsequences – Include all nodes

CALTECH CS137 Winter2006 -- DeHon

32

Feasible Clusters (mult16a)

CALTECH CS137 Winter2006 -- DeHon

33

Covering

  • Not clear when to put more or less stuff

in a cluster…versus leave with next cluster

– Can’t build clusters greedily

CALTECH CS137 Winter2006 -- DeHon

34

Dynamic Programming

  • For each subsequence start,end

– Either the area and io match – OR want to find a breakpoint between cluster sets

  • Cluster sets startmidpoint, midpointend may

each either be single or multiple clusters

CALTECH CS137 Winter2006 -- DeHon

35

Minimization Problem

  • c(i,j)=w(i,j)+mink(c(i,k)+c(k,j))
  • Also filling in a table
  • Work per table entry O(N)

– Must look at all k’s

  • O(N3) total work

CALTECH CS137 Winter2006 -- DeHon

36

Systolic Solution

  • Solve in O(N) time
  • Using O(N2) hardware
  • Each PE is one cell in table

– PE computes the local min

slide-7
SLIDE 7

7

CALTECH CS137 Winter2006 -- DeHon

37

Challenge

  • Getting right pair of data to show up on each

cycle

  • c(i,j)=w(i,j)+mink(c(i,k)+c(k+1,j))
  • E.g. (5,0) wants to see

– (5,1) (0,0) – (5,2) (1,0) – (5,3) (2,0) – (5,4) (3,0) – (5,5) (4,0)

CALTECH CS137 Winter2006 -- DeHon

38

Computational Array

(6,6) (6,5) (5,5) (6,4) (5,4) (4,4) (6,3) (5,3) (4,3) (3,3) (6,2) (5,2) (4,2) (3,2) (2,2) (6,1) (5,1) (4,1) (3,1) (2,1) (1,1) (6,0) (5,0) (4,0) (3,0) (2,0) (1,0) (0,0)

CALTECH CS137 Winter2006 -- DeHon

39

Computational Array

(6,6) (6,5) (5,5) (6,4) (5,4) (4,4) (6,3) (5,3) (4,3) (3,3) (6,2) (5,2) (4,2) (3,2) (2,2) (6,1) (5,1) (4,1) (3,1) (2,1) (1,1) (6,0) (5,0) (4,0) (3,0) (2,0) (1,0) (0,0)

(5,1) (0,0) (5,2) (1,0) (5,3) (2,0) (5,4) (3,0) (5,5) (4,0)

CALTECH CS137 Winter2006 -- DeHon

40

Systolic Algorithm

  • For cell at distance t from edge

– Has completed data at time 2t – Send data along row and column

  • Data travels 1 cell / cycle for t units of time
  • Then travels 2 cells / cycle for rest of time

CALTECH CS137 Winter2006 -- DeHon

41

Computational Array

(6,6) (6,5) (5,5) (6,4) (5,4) (4,4) (6,3) (5,3) (4,3) (3,3) (6,2) (5,2) (4,2) (3,2) (2,2) (6,1) (5,1) 8 (4,1) (3,1) (2,1) (1,1) (6,0) (5,0) 7 5 3 1 (0,0)

(5,1) (0,0) (5,2) (1,0) (5,3) (2,0) (5,4) (3,0) (5,5) (4,0)

CALTECH CS137 Winter2006 -- DeHon

42

Computational Array

(6,6) (6,5) (5,5) (6,4) (5,4) (4,4) (6,3) (5,3) (4,3) (3,3) (6,2) (5,2) 6 (4,2) (3,2) (2,2) (6,1) 7 (4,1) (3,1) (2,1) (1,1) (6,0) (5,0) 7 5 3 (1,0) 2 (0,0)

(5,1) (0,0) (5,2) (1,0) (5,3) (2,0) (5,4) (3,0) (5,5) (4,0)

slide-8
SLIDE 8

8

CALTECH CS137 Winter2006 -- DeHon

43

Computational Array

(6,6) (6,5) (5,5) (6,4) (5,4) (4,4) (6,3) (5,3) 4 (4,3) (3,3) (6,2) 5 (4,2) (3,2) (2,2) (6,1) 6 (4,1) (3,1) (2,1) (1,1) (6,0) (5,0) 6 5 (2,0) 4 (1,0) (0,0)

(5,1) (0,0) (5,2) (1,0) (5,3) (2,0) (5,4) (3,0) (5,5) (4,0)

CALTECH CS137 Winter2006 -- DeHon

44

Computational Array

(6,6) (6,5) (5,5) (6,4) (5,4) 2 (4,4) (6,3) 3 (4,3) (3,3) (6,2) 5 (4,2) (3,2) (2,2) (6,1) 7 (4,1) (3,1) (2,1) (1,1) (6,0) (5,0) 7 (3,0) 6 (2,0) (1,0) (0,0)

(5,1) (0,0) (5,2) (1,0) (5,3) (2,0) (5,4) (3,0) (5,5) (4,0)

CALTECH CS137 Winter2006 -- DeHon

45

Message

  • With a little bit of coordination

– Can solve dynamic programming problems with parallelism – Using simple, nearest-neighbor connections

CALTECH CS137 Winter2006 -- DeHon

46

Admin

  • Friday: GraphStep Programming
  • Baseline comparison due Friday
  • Monday: Sorting