Title: Circuit Partitioning : KernighanLin and FiducciaMattheyses Algorithms
1Circuit Partitioning Kernighan-Lin and
Fiduccia-Mattheyses Algorithms
- EE652 class presentation by
- Bernadeta Srijanto
- instr. Dr. D. Bouldin
2Presentation Outline
- Introduction
- Defining Problem what
- Kernighan-Lin Algorithm example
- Fiduccia-Mattheyses Algorithm example
- Summary
- comparison between KL FM algorithms
- whats next ?
3Introduction
- Background
- Advance technology causes more logic used and
increasing system size -
- Partitioning is needed here because
- too large of a circuit subcircuits / ICs
- I/O pin limitation more pins more money
- IO t G r
4Defining Problem General
- Visualization transform circuit to graph
- vertices represent circuit elements
- edges represents interconnects
5- Defining problem from graph
- Given graph G(V,E), where each vertex v ÎV has a
size of s(v) and each edge e Î E has a weight of
w(e). We need to divide the set V into k subsets
V1, V2, V3, , Vk that is, divides the graph
G(V,E) into k subgraph - Gi(Vi,Ei), i
1,2,3, ,k -
6- Partitioning Constraints
- placing an upper bound on the size of each
subcircuit. Prefer to have roughly equal size. - Vi V / k , where Vi size of set Vi
- V size of V
- thus,
- ni n / k , ni number of elements
in Vi - n number
of elements in V
7- Partitioning Constraints
- minimizing external wiring wiring between
subcircuits (see Figure 2.1)
8Defining Problem Specific
- TWPP (two way partitioning problem)
- G1(V1,E1) and G2(V2,E2)
- Lets call blocks of partitioning A and B
- Constraints
- balance if we have 2n elements, we want n
elements for each partitioning - minimum size of cutset (min. external wiring)
9Kernighan-Lin algorithm
- heuristic technique iterative
- idea in TWPP, optimizing partitioning from
initial partition PA,B to PA,B by
swapping a subset XÍA with YÍB such that - X Y
- XAÇB
- YBÇA
- (see Figure 2.4)
- now, how to determine the X and the Y ?
10Kernighan-Lin algorithm
- Step1 Initialization
- Step2 Compute D-values for all vÎV
- Step3 Compute gains between 2 nodes in
A and B - Step4 Re-compute D-values for nodes connected
to (ai, bi) - Step5 Determine k
11KL Step1 Initialization
- Initial partition PA,B is done randomly, where
A B n, and AÇBÆ - use example in Fig. 2.2(b), initial partition
- A2,3,4
- B1,5,6
12KL Step2 compute D-values
- If Da is the benefit of moving cell a from
block A to B so that cutset would decrease - Da Ea - Ia
- Ea vÎBS Cav External cost of node a
in block A - the number of edges from aÎA
and and end in B - Ia vÎAS Cav Internal cost of node
a in block A -
- Update i 1, and queue Æ
-
13KL Step2 example Fig 2.2(b)
- D1 E1 - I1 1 - 0 1
- D2 E2 - I2 1 - 2 -1
- D3 E3 - I3 0 - 1 -1
- D4 E4 - I4 2 - 1 1
- D5 E5 - I5 1 - 1 0
- D6 E6 - I6 1 - 1 0
-
-
- i 1
- Q Æ
14KL Step3 compute gains between 2 nodes in A and
B
- gain gi Dai Dbi -2caibi, where aiÎA bi Î B
-
- find the largest gain
-
- add this pair to queue Q(ai , bi)
-
- update the blocks AA-ai
- BB-bi
-
15KL Step3 example fig 2.2(b)
- g21D2D1-2c21(-1)(1)-2(1)-2
- g25D2D5-2c25(-1)(0)-2(0)-1
- g26D2D6-2c26(-1)(0)-2(0)-1
- g31D3D1-2c31(-1)(1)-2(0)0
- g35D3D5-2c35(-1)(0)-2(0)-1
- g36D3D6-2c36(-1)(0)-2(0)-1
- g41D4D1-2c41(1)(1)-2(0)2
- g45D4D5-2c45(1)(0)-2(1)-1
- g46D4D6-2c46(1)(0)-2(1)-1
-
- largest gain 2 of (4,1)
16- KL Step3 example (contd)
-
- Q(4 , 1)
-
- update the blocks AA-42,3
- BB-15,6
-
17KL Step4 re-compute Ds for new updated block
A and B
- (if A and B are empty, go to step 5)
- re-compute Ds for vÎV connected to(ai, bi)
-
- update i 1 i
-
- go to step3
-
18KL Step4 example fig 2.2(b)
- re-compute Ds for v connected to(ai, bi)
- D2 -1 D5-2 D6 -2
-
- update i 2
-
- go to step3 g25g26g35g36-3 arbitrarily
choose g36 -
- Q 3,6
-
- A2, B5 etc
-
19KL Step5 determine k which gives maximum of
total gains
- (if A and B are empty)
- find k so that Gi1to kSgi g1g2g3gk is
max -
- If Ggt0 swap Xa1,a2,,ak from A to B
- and Yb1,b2,,bk from B to A
-
- update new A and B as initial partition for the
next loop -
- go to step2
-
20KL Step5 determine k (contd)
- If Glt0 Stop
- (partitioning cannot be improved)
21KL Step5 example fig 2.2(b)
- as A and B are empty
- updated i 3
- g1 2 g1 g2 -1 g1 g2 g3 0
- we found Gmax g1
- thus k 1
-
- since Ggt0 swap Xa14 in A and Yb11
in B -
- new A 1,2,3 and B 4,5,6
-
- go to step2, with new A and B as the initial
partition -
22Fiduccia-Mattheyses algorithm
- heuristic technique iterative
- idea in TWPP, Partition of circuit consisting C
cells into 2 blocks A and B by moving a cell
(called base cell) at a time from one block of
partition to the other in attempt to minimize the
number of nets cut (instead of minimizing the
number of edges cut) - now, how to select the base cell, and what is the
base sequence moves of base cells ?
23Fiduccia-Mattheyses algorithm
- Example of circuit for FM algorithm
24Fiduccia-Mattheyses algorithm
- Step1 Compute gains of all cells
- Step2 Select base cell
- Step3 Lock base cell
- Step4 Checking for more free cells
- Step5 Choose for best sequence of moves for
k-base cells - Step6 Make k moves permanent and free all cells
25FM Step1 Compute gains for all cells
- Gain computed gi FS(i) - TE(i)
- FS(i) number of nets connected to cell(i) and
not connected to any other cell in From_block
F(i) of cell (i) - TE(i) number of nets that are connected to
cell(i) and not crossing the cut - F(i) From_block of cell i
- T(i) To_block of cell i
26FM Step1 example fig 2.8(a)
- If A(n) and B(n) are the numbers of cells of net
n in block A and block B, from fig 2.8(a) we have
- A(j) 0, A(m) 3, A(q) 2, A(k) 1, A(p) 1
- B(j) 2, B(m) 0, B(q) 1, B(k) 1, B(p) 1
27FM Step1 example contd fig 2.8(a)
- Defining block A as From_block and block B as
To_block, - F(j) 0, F(m) 3, F(q) 2, F(k) 1, F(p) 1
- T(j) 2, T(m) 0, T(q) 1, T(k) 1, T(p) 1
- (vice versa if B is the From_block, and A is the
To_block)
28FM Step1 example contd fig 2.8(a)
- Since only the critical nets affect the gain, we
looking at F(n) 1 and T(n)0 - moving from block A to B, we look at F(k) 1,
F(p) 1 and T(m) 0. - For the cell number i
- i 1 net on cell 1 is m T(m) 0 g(1) 0 -
1 -1 - i 2 net on cell 2 are m, q, k, p F(k) F(p)
1 and T(m) 0 g(2) 2 - 1 -1 - i 3 net on cell 3 are m, q T(m) 0 g(1)
0 - 1 -1
29FM Step2 Select base cells
- initial i 1
-
- base cell ci selected if
- has maximum gi
- satisfies balance criterion
-
- if no base cell found Exit
30FM Step3 Lock base cell
- lock cell ci
-
- update gain of cell affected critical nets
31FM Step4 Checking for more free cells
- If free cell ¹ Æ update i 1 i
-
- select next base cell ci
-
- If ci ¹ Æ go to step3
-
32FM Step5 Choose best sequence of moves
- (if no more free cell)
- find k so that Gi1to kSgi g1g2g3gk is
max -
- sequence of moves is then
- c1,c2,c3, , ck
-
- If Glt0 Stop
-
33FM Step6 Makes k moves permanent
- Move cells in sequence of c1, c2, c3, , ck
permanently to To_block -
- free all cells
-
- go back to step1
34Comparison between KL and FM algorithms
35Whats next ?
- Variation of KL-FM Algorithm
- for KL 1. Unequal sized blocks
- 2. Unequal sized elements
36The End