Presentation is loading. Please wait.

Presentation is loading. Please wait.

CALTECH CS137 Winter2006 -- DeHon 1 CS137: Electronic Design Automation Day 10: February 1, 2006 Dynamic Programming.

Similar presentations


Presentation on theme: "CALTECH CS137 Winter2006 -- DeHon 1 CS137: Electronic Design Automation Day 10: February 1, 2006 Dynamic Programming."— Presentation transcript:

1 CALTECH CS137 Winter2006 -- DeHon 1 CS137: Electronic Design Automation Day 10: February 1, 2006 Dynamic Programming

2 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

3 CALTECH CS137 Winter2006 -- DeHon 3 Dynamic Programming Two Examples –SPLASH sequence matching/edit distances O(N 2 ) operation in O(N) time with O(N) hardware –CMU parenthesis matching O(N 3 ) operation in O(N) time with O(N 2 ) hardware

4 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

5 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

6 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

7 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]

8 CALTECH CS137 Winter2006 -- DeHon 8 Edit Distance Table

9 CALTECH CS137 Winter2006 -- DeHon 9 Systolic Array Feed Strings from opposite ends Compute along diagonals

10 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

11 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

12 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)

13 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,Tj) On previous cycle: Cell computes (i-1,j-1) T-neighbor (i-1,j) S-neighbor (i,j-1)

14 CALTECH CS137 Winter2006 -- DeHon 14 In Operation (2,0)(1,0) (0,0)(0,1) (0,2) (2,0)(3,0) 2110112223 S H HSM

15 CALTECH CS137 Winter2006 -- DeHon 15 (2,0)(1,0) (0,0)(0,1) (0,2) (2,0)(3,0) 2110112223 S H HSM (2,0) (1,0)(1,1)(0,1)(0,2) (0,3)(3,0) S HO HSM

16 CALTECH CS137 Winter2006 -- DeHon 16 (2,0) (1,0)(1,1)(0,1)(0,2) (0,3)(3,0) 2210122333 S HO HSM

17 CALTECH CS137 Winter2006 -- DeHon 17 (3,0)(2,0)(2,1)(1,1)(1,2)(0,2)(0,3) (3,0)(4,0) SH O MHSO (2,0) (1,0)(1,1)(0,1)(0,2) (0,3)(3,0) 2210122333 S HO HSM

18 CALTECH CS137 Winter2006 -- DeHon 18 (3,0)(2,0)(2,1)(1,1)(1,2)(0,2)(0,3) (3,0)(4,0) 3210123334 SH O MHSO

19 CALTECH CS137 Winter2006 -- DeHon 19 (3,0)(3,1)(2,1)(2,2)(1,2)(1,3)(0,3)(0,4)(4,0) SH OR MHSO (3,0)(2,0)(2,1)(1,1)(1,2)(0,2)(0,3) (3,0)(4,0) 3210123334 SH O MHSO

20 CALTECH CS137 Winter2006 -- DeHon 20 (3,0)(3,1)(2,1)(2,2)(1,2)(1,3)(0,3)(0,4)(4,0) 321012344 SH OR MHSO

21 CALTECH CS137 Winter2006 -- DeHon 21 Edit Distance Table

22 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

23 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%)

24 CALTECH CS137 Winter2006 -- DeHon 24 Performance (un-normalized)

25 CALTECH CS137 Winter2006 -- DeHon 25 Normalized Computational Density (CM5 used Sparc Processors)

26 CALTECH CS137 Winter2006 -- DeHon 26 Non-Local

27 CALTECH CS137 Winter2006 -- DeHon 27 Sub-dividing into Trees Optimal parenthesization Deciding where to split a tree –Perhaps for covering Search Tree

28 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)))

29 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 V i, such that   (Cost(V i )) minimized  IO(V i ) < IO limit  A(V i ) < Area limit  Cost(V i ) =  (cost(e) | e  E st. e 1  V i and e 2  V i ) PEs PE Communication

30 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

31 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

32 CALTECH CS137 Winter2006 -- DeHon 32 Feasible Clusters (mult16a)

33 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

34 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 start  midpoint, midpoint  end may each either be single or multiple clusters

35 CALTECH CS137 Winter2006 -- DeHon 35 Minimization Problem c(i,j)=w(i,j)+min k (c(i,k)+c(k,j)) Also filling in a table Work per table entry O(N) –Must look at all k’s O(N 3 ) total work

36 CALTECH CS137 Winter2006 -- DeHon 36 Systolic Solution Solve in O(N) time Using O(N 2 ) hardware Each PE is one cell in table –PE computes the local min

37 CALTECH CS137 Winter2006 -- DeHon 37 Challenge Getting right pair of data to show up on each cycle c(i,j)=w(i,j)+min k (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)

38 CALTECH CS137 Winter2006 -- DeHon 38 Computational Array (0,0)(1,0)(2,0)(3,0)(4,0)(5,0)(6,0) (1,1)(2,1)(3,1)(4,1)(5,1)(6,1) (2,2)(3,2)(4,2)(5,2)(6,2) (3,3)(4,3)(5,3)(6,3) (4,4)(5,4)(6,4) (5,5)(6,5) (6,6)

39 CALTECH CS137 Winter2006 -- DeHon 39 Computational Array (0,0)(1,0)(2,0)(3,0)(4,0)(5,0)(6,0) (1,1)(2,1)(3,1)(4,1)(5,1)(6,1) (2,2)(3,2)(4,2)(5,2)(6,2) (3,3)(4,3)(5,3)(6,3) (4,4)(5,4)(6,4) (5,5)(6,5) (6,6) (5,1) (0,0) (5,2) (1,0) (5,3) (2,0) (5,4) (3,0) (5,5) (4,0)

40 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

41 CALTECH CS137 Winter2006 -- DeHon 41 Computational Array (0,0)1357(5,0)(6,0) (1,1)(2,1)(3,1)(4,1)(5,1) 8 (6,1) (2,2)(3,2)(4,2)(5,2)(6,2) (3,3)(4,3)(5,3)(6,3) (4,4)(5,4)(6,4) (5,5)(6,5) (6,6) (5,1) (0,0) (5,2) (1,0) (5,3) (2,0) (5,4) (3,0) (5,5) (4,0)

42 CALTECH CS137 Winter2006 -- DeHon 42 Computational Array (0,0)(1,0) 2 357(5,0)(6,0) (1,1)(2,1)(3,1)(4,1)7(6,1) (2,2)(3,2)(4,2)(5,2) 6 (6,2) (3,3)(4,3)(5,3)(6,3) (4,4)(5,4)(6,4) (5,5)(6,5) (6,6) (5,1) (0,0) (5,2) (1,0) (5,3) (2,0) (5,4) (3,0) (5,5) (4,0)

43 CALTECH CS137 Winter2006 -- DeHon 43 Computational Array (0,0)(1,0)(2,0) 4 56(5,0)(6,0) (1,1)(2,1)(3,1)(4,1)6(6,1) (2,2)(3,2)(4,2)5(6,2) (3,3)(4,3)(5,3) 4 (6,3) (4,4)(5,4)(6,4) (5,5)(6,5) (6,6) (5,1) (0,0) (5,2) (1,0) (5,3) (2,0) (5,4) (3,0) (5,5) (4,0)

44 CALTECH CS137 Winter2006 -- DeHon 44 Computational Array (0,0)(1,0)(2,0)(3,0) 6 7(5,0)(6,0) (1,1)(2,1)(3,1)(4,1)7(6,1) (2,2)(3,2)(4,2)5(6,2) (3,3)(4,3)3(6,3) (4,4)(5,4) 2 (6,4) (5,5)(6,5) (6,6) (5,1) (0,0) (5,2) (1,0) (5,3) (2,0) (5,4) (3,0) (5,5) (4,0)

45 CALTECH CS137 Winter2006 -- DeHon 45 Message With a little bit of coordination –Can solve dynamic programming problems with parallelism –Using simple, nearest-neighbor connections

46 CALTECH CS137 Winter2006 -- DeHon 46 Admin Friday: GraphStep Programming Baseline comparison due Friday Monday: Sorting


Download ppt "CALTECH CS137 Winter2006 -- DeHon 1 CS137: Electronic Design Automation Day 10: February 1, 2006 Dynamic Programming."

Similar presentations


Ads by Google