Circuit Partitioning - Bangladesh University of

Download Report

Transcript Circuit Partitioning - Bangladesh University of

A 46
X=(AB*CD)+
(A+D)+(A(B+C))
Y = (A(B+C)+AC+
D+A(BC+D))
F 8
E
23
H
37
G 19
I 12
K 27
D 56
VLSI Layout Algorithms
CSE 6404
Dr. Md. Saidur Rahman
J 14
B
65
C 11
Circuit Partitioning
Why is circuit partitioning necessary?
The circuit is too large to be placed on a single chip.
The larger the gate count of the circuit, the larger the
number of I/O pins associated with the circuit. So
circuit partitioning is necessary due to I/O pin
limitations.
Decomposition of a complex system into smaller subsystems
Done hierarchically
Partitioning done until each subsystem has manageable size
Each subsystem can be designed independently
Interconnections between partitions minimized
Less hassle interfacing the subsystems
Communication between subsystems usually costly
Example: Partitioning of a Circuit
Input size: 48
Cut 1=4
Size 1=15
Cut 2=4
Size 2=16
Size 3=17
[©Sherwani]
Hierarchical Partitioning
• Levels of partitioning:
– System-level partitioning:
Each sub-system can be designed as a single PCB
– Board-level partitioning:
Circuit assigned to a PCB is partitioned into subcircuits
each fabricated as a VLSI chip
– Chip-level partitioning:
Circuit assigned to the chip is divided into
manageable sub-circuits
[©Sherwani]
System Hierarchy
Levels of Partitioning
System
System Level Partitioning
PCBs
Board Level Partitioning
Chips
Chip Level Partitioning
Subcircuits
/ Blocks
Delay at Different Levels of
Partitions
A
x
B
10x
D
C
PCB1
20x
PCB2
[©Sherwani]
Problem Definition
5
4
6
3
2
5
1
4
6
2
3
1
Problem Definition
5
4
6
3
2
5
1
4
6
2
3
Given a graph G=(V,E), where each vertex v in V has a size
s(v), and each edge e in E has a weight w(e), the problem is to
divide the set V into k subsets V1, V2, ….Vk, such that an
objective function is optimized, subject to certain constraints.
1
Cost Functions and Constraints
Bounded size partitions
Minimize external wiring
Delay due to partitioning
Number of terminals
Number of partitions
Bounded size partitions
Each subcircuit has an upper bound on size.
 s(v)  A
vVi
i
It is desirable to divide the circuit into roughly equal sizes.
1
 1
Vi   s(v)    s(v)  V
vVi
 k vV
 k
Two-way partitioning problem
Each node has unit size
Each edge has unit weight
Find two partition V1 and V2 such that
Each of V1 and V2 has equal size
External wiring will be minimum (cut-set will have
to minimize)
16
13
12
11
14
10
4
9
8
6
7
15
5
2
3
st-numbering
t = 16
13
12
11
j  i  k.
5
2
s=1
15
4
6
7
has two neighbors j, k
10
9
8
i  s, t
14
3
st-numbering
t = 16
13
12
11
Size of cutset = 4
14
10
4
9
8
6
7
5
2
s=1
15
3
st-numbering
t = 16
15
14
11
Size of cutset = 3
12
10
7
13
8
9
4
6
5
3
2
s=1
To find a bipartition with the minimum cutset, we have to
enumerate all bipartitions.
We need to enumerate all st-numbering.
Two-way partitioning problem
Each node has unit size
Each edge has unit weight
Find two partitions V1 and V2 such that
Each of V1 and V2 has equal size
External wiring will be minimum (cut-set will have
to minimmize)
NP-hard problem.
Heuristic techniques to approximate solutions.
Classification of Partitioning Algorithms
Deterministic algorithms
Stochastic algoritms
Classification of Partitioning Algorithms
Constructive algorithms
Iterative algorithms
Problem instance
Constructive heuristic
Iterative heuristic
Stopping criteria
output
Kernighan-Lin (KL) Algorithm
•
•
•
•
On non-weighted graphs
An iterative improvement technique
A two-way (bisection) partitioning algorithm
The partitions must be balanced (of equal size)
Kernighan-Lin (KL) Algorithm
Initial partition A, B
Size of the cut set
A  B n
A B  
T
c
ab
aA,bB
We have to minimize the size of the cut set.
Optimal Partition
Initial Partition
A*, B*
A, B
Swap
X  A with Y  B
X  Y
X  A  B*
Y  A*  B
such that
Optimal Partition
Initial Partition
A
X
B
Y
Swap
A*
Y
B*
X
X  A with Y  B
X  Y
X  A  B*
Y  A*  B
How to find X and Y ?
such that
GA
Internal
cost
a1
a2
a3
a5
an
a6
xA
b6
a4
I ai   Cai x ,
Likewise,
b2
ai
b1
b 5 b4 b3
b7
GB
bj
Eai   Cai y
External
cost
yB
Dai  Eai  I ai
Db j  Eb j  I b j   Cb j x   Cb j y
xA
yB
[©Kang]
Gain Calculation (cont.)
• Lemma: Consider any ai  A, bj  B.
If ai, bj are interchanged, the gain is
g  Dai  Db j  2Cai b j
• Proof:
Total cost before interchange (T) between A and B
T  Eai  Eb j  Cai b j  (cost for all others)
Total cost after interchange (T’) between A and B
T  I ai  I b j  Caib j  (cost for all others)
Therefore
Dai
Db j
g  T  T  Eai  I ai  Eb j  I b j  2Cai b j
[©Kang]
Gain Calculation (cont.)
• Lemma:
– Let Dx’, Dy’ be the new D values for elements of
A - {ai} and B - {bj}. Then after interchanging ai & bj,

Dx  Dx  2C xai  2C xb j , x  A  {ai }

D y  D y  2C yb j  2C yai , y  B  {b j }
• Proof:
– The edge x-ai changed from internal in Dx to external in Dx’
– The edge y-bj changed from internal in Dx to external in Dx’
– The x-bj edge changed from external to internal
– The y-ai edge changed from external to internal
• More clarification in the next two slides
[©Kang]
Clarification of the Lemma
b
a
bj
x
ai
• Decompose Ix and Ex to separate edges from ai and
bj:
I x  Cxai  a
Ex  Cxb j  b
Write the equations before the move
Dx  E x  I x  (C xb j  b )  (C xai  a )
 a  b  C xai  C xb j
• ... And after the move


I x  C xb j  a
E x  C xai  b

Dx  a  b  C xai  C xb j
 Dx  2C xai  2C xb j
Kernighan-Lin (KL) Algorithm
• Iterate as long as the cutsize improves:
– Find a pair of vertices that result in the largest
decrease in cutsize if exchanged
– Exchange the two vertices (potential move)
– “Lock” the vertices
– If no improvement possible, and
still some vertices unlocked, then
exchange vertices that result in smallest
increase in cutsize
Example: KL
5
4
6
2
5
1
3
• Step 1 - Initialization
A = {2, 3, 4},
B = {1, 5, 6}
A’ = A = {2, 3, 4}, B’ = B = {1, 5, 6}
• Step 2 - Compute D values
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
4
6
2
1
3
Initial partition
[©Kang]
Example: KL (cont.)
– Step 3 - compute gains
g21 = D2 + D1 - 2C21 = (-1) + (+1) - 2(1) = -2
g25 = D2 + D5 - 2C25 = (-1) + (+0) - 2(0) = -1
g26 = D2 + D6 - 2C26 = (-1) + (+0) - 2(0) = -1
g31 = D3 + D1 - 2C31 = (-1) + (+1) - 2(0) = 0
g35 = D3 + D5 - 2C35 = (-1) + (0) - 2(0) = -1
g36 = D3 + D6 - 2C36 = (-1) + (0) - 2(0) = -1
g41 = D4 + D1 - 2C41 = (+1) + (+1) - 2(0) = +2
g45 = D4 + D5 - 2C45 = (+1) + (+0) - 2(+1) = -1
g46 = D4 + D6 - 2C46 = (+1) + (+0) - 2(+1) = -1
– The largest g value is g41 = +2
interchange 4 and 1 (a1, b1) = (4, 1)
A’ = A’ - {4} = {2, 3}
B’ = B’ - {1} = {5, 6}
both not empty
[©Kang]
Example: KL (cont.)
• Step 4 - update D values of node connected to vertices (4, 1)
D2’ = D2 + 2C24 - 2C21 = (-1) + 2(+1) - 2(+1) = -1
D5’ = D5 + 2C51 - 2C54 = +0 + 2(0) - 2(+1) = -2
D6’ = D6 + 2C61 - 2C64 = +0 + 2(0) - 2(+1) = -2
• Assign Di = Di’, repeat step 3 :
g25 = D2 + D5 - 2C25 = -1 - 2 - 2(0) = -3
g26 = D2 + D6 - 2C26 = -1 - 2 - 2(0) = -3
g35 = D3 + D5 - 2C35 = -1 - 2 - 2(0) = -3
g36 = D3 + D6 - 2C36 = -1 - 2 - 2(0) = -3
• All values are equal;
arbitrarily choose g36 = -3 
(a2, b2) = (3, 6)
A’ = A’ - {3} = {2}, B’ = B’ - {6} = {5}
New D values are:
D2’ = D2 + 2C23 - 2C26 = -1 + 2(1) - 2(0) = +1
D5’ = D5 + 2C56 - 2C53 = -2 + 2(1) - 2(0) = +0
• New gain with D2  D2’, D5  D5’
g25 = D2 + D5 - 2C52 = +1 + 0 - 2(0) = +1  (a3, b3) = (2, 5)
[©Kang]
Example: KL (cont.)
5
• Step 5 - Determine the # of
moves to take
6
g1 = +2
g1 + g2 = +2 - 3 = -1
g1 + g2 + g3 = +2 - 3 + 1 = 0
• The value of k for max G is 1
X = {a1} = {4}, Y = {b1} = {1}
• Move X to B, Y to A  A = {1, 2, 3}, B = {4, 5, 6}
• Repeat the whole process:
•••••
• The final solution is A = {1, 2, 3}, B = {4, 5, 6}
4
2
3
1
Kernighan-Lin (KL) Algorithm
• Initialize
– Bipartition G into V1 and V2, s.t., |V1| = |V2|  1
– n = |V|
• Repeat
– for i=1 to n/2
• Find a pair of unlocked vertices vai V1 and vbi V2 whose
exchange makes the largest decrease or smallest increase
in cut-cost
• Mark vai and vbi as locked
• Store the gain gi.
– Find k, s.t. i=1..k gi=Gaink is maximized
– If Gaink > 0 then
move va1,...,vak from V1 to V2 and
vb1,...,vbk from V2 to V1.
• Until Gaink  0
Kernighan-Lin (KL) Example
Step No.
0
a
e
b
f
c
g
d
h
Vertex Pair
--
Gain
0
1
{ d, g }
3
2
{ c, f }
1
3
{ b, h }
-2
4
{ a, e }
-2
Gain sum
0
3
4
2
0
Cut-cost
5
2
1
3
5
[©Sarrafzadeh]
Kernighan-Lin (KL) Example
a
e
f
b
c
g
d
Step No.
0
Vertex Pair
--
Gain
0
1
{ d, g }
3
2
{ c, f }
1
3
{ b, h }
-2
4
{ a, e }
-2
h
Gain sum
0
3
4
2
0
Cut-cost
5
2
1
3
5
[©Sarrafzadeh]
Kernighan-Lin (KL) : Analysis
• Time complexity?
– Inner (for) loop
• Iterates n/2 times
• Iteration 1: (n/2) x (n/2)
• Iteration i: (n/2 – i + 1)2.
– Passes? Usually independent of n
– O(n3)
• Drawbacks?
– Local optimum
– Balanced partitions only
– No weight for the vertices
– High time complexity
References and Copyright
• Some of the slides are used from the following references (with
some modification if necessary).
– [©Sarrafzadeh] © Majid Sarrafzadeh, 2001;
Department of Computer Science, UCLA
– [©Sherwani] © Naveed A. Sherwani, 1992
(companion slides to [She99])
– [©Keutzer] © Kurt Keutzer, Dept. of EECS,
UC-Berekeley
http://www-cad.eecs.berkeley.edu/~niraj/ee244/index.htm
– [©Gupta] © Rajesh Gupta
UC-Irvine
http://www.ics.uci.edu/~rgupta/ics280.html
– [©Kang] © Steve Kang
UIUC
http://www.ece.uiuc.edu/ece482/
– [@Kia] @ Kia Bazargan, University of Minnesota
– [@Pan] @ Prof. David Z. Pan,
http://users.ece.utexas.edu/~dpan/2008Fall_EE382V/