Вы находитесь на странице: 1из 43

PARTITIONING

By
S.Umadevi
Asst.Prof(Sr)
INTRODUCTION
Components of Partitioning
Physical Design Flow
Needs for Partitioning
Partitioning at different levels
Golden Rules of Partitioning
Classification of Partitioning
Algorithm

 Availability of Initial Partitioning – Constructive and Iterative


 Nature of Algorithms – Deterministic and probabilistic

 Process used - Group Migration, Simulated annealing and Evolution based


Algorithm
Constructive Algorithm
Input :

Circuit Component + Netlist

Output:

Set of partitions + The new netlist

 Form initial partitioning and improved by using other


algorithms

 Preprocessing Algorithm

 Fast but far from optimal


Iterative Algorithm
Input:

Set of partitions + The netlist

Output:

Improved set of partitions with the modified netlist

 Iterates continuously until the partitions cannot be improved


further
Deterministic Algorithm
 Produce repeatable (or) deterministic solutions

 Generate same solution for a given problem


Probabilistic Algorithm
 Make use of Random function

 Capable of producing a different solution for the same


problem
Graph Partitioning

– Problem
– Kernighan and Lin Algorithm

– Presentation based on
• http://www.comp.nus.edu.sg/~cs5234/2007-
08/Lectures/L06/L06-Graph-Partitioning.ppt
Problem Formulation
• Input: A weighted graph G = (V, E) with
– Vertex set V. (|V| = 2n)
– Edge Set E. (|E| = e)
– Cost cAB for each edge (A, B) in E.
• Output: 2 subsets X & Y such that
– V = X  Y and X  Y = { } (i.e. partition)
– Each subset (group) has n vertices
– Total cost of edges “crossing” the partition is minimized.

• This problem is NP-Complete!!!!!


Kernighan and Lin heuristic
“An Efficient Heuristic Procedure for Partitioning
Graphs” B. W. Kernighan and S. Lin, The Bell System
Technical Journal, 49(2):291-307, 1970
Idea of KL Algorithm
• Start with any initial partition X and Y.
• A pass or iteration means exchanging each vertex A  X
with each vertex B  Y exactly once:
1. For i := 1 to n do
From the unlocked (unexchanged) vertices,
choose a pair (A,B) s.t. gain(A,B) is largest.
Exchange A and B. Lock A and B.
Let gi = gain(A,B).
2. Find the k s.t. G=g1+...+gk is maximized.
3. Switch the first k pairs.
• Repeat the pass until there is no improvement (G=0).
Kernighan-Lin Algorithm (1)
3
a b Given:
4 1 2 Initial weighted graph G with
2 c
2
d
V(G) = { a, b, c, d, e, f }
3 4 1
6 Start with any partition of
e f
V(G) into X and Y, say

X = { a, c, e }
Y = { b, d, f }
KL algorithm (2a)
a
3
b Compute the gain values of moving
1
node x to the others set:
4 2

2 c
2
d Gx = Ex - Ix
4
Ex = cost of edges connecting node x
3 1
6
with the other group (extra)
e f Ix = cost of edges connecting node x
within its own group (intra)
cut-size = 3+1+2+4+6 = 16
Ga = Ea – Ia = – 3 (= 3 – 4 – 2)
X = { a, c, e } Gc = Ec – Ic = 0 (= 1 + 2 + 4 – 4 – 3)
Y = { b, d, f } Ge = Ee – Ie = + 1 (= 6 – 2 – 3)
Gb = Eb – Ib = + 2 (= 3 + 1 –2)
Gd = Ed – Id = – 1 (= 2 – 2 – 1)
Gf = Ef – If = + 9 (= 4 + 6 – 1)
KL algorithm (2b)
3
a b Cost saving when exchanging a and b is
4 1 2 essentially Ga + Gb
2
2 c d However, the cost saving 3 of the direct
3 4 1 edge was counted twice. But this edge
6 still connects the two groups
e f
Hence, the real “gain” (i.e. cost saving)
of this exchange is gab = Ga + Gb - 2cab

X = { a, c, e } Ga = Ea – Ia = – 3 (= 3 – 4 – 2)
Y = { b, d, f } Gb = Eb – Ib = + 2 (= 3 + 1 – 2)
gab = Ga + Gb – 2cab = – 7 (= – 3 + 2 – 2.3)
KL algorithm
G = (3)
–3
G = 0
a Gb = +2
Gd = –1
c
3
a b Ge = +1 Gf = +9
4 1 2
2 Compute all the gains
2 c d
4
3 1
gab = Ga + Gb – 2wab = –3 + 2 – 23 = –7
6
e f gad = Ga + Gd – 2wad = –3 – 1 – 20 = –4
gaf = Ga + Gf – 2waf = –3 + 9 – 20 = +6
cut-size = 16 gcb = Gc + Gb – 2wcb = 0 + 2 – 21 = 0
gcd = Gc + Gd – 2wcd = 0 – 1 – 22 = –5
Pair with gcf = Gc + Gf – 2wcf = 0 + 9 – 24 = +1
maximum gain geb = Ge + Gb – 2web = +1 + 2 – 20 = +3
ged = Ge + Gd – 2wed = +1 – 1 – 20 = 0
gef = Ge + Gf – 2wef = +1 + 9 – 26 = –2
KL algorithm (4)
3
a b f b
1
4 1 2 4 1 2
3
2 2
2 c d c d
3 4 1 6 3 4
6 2
e f e a

cut-size = 16 cut-size = 16 – 6 = 10

Exchange nodes Then lock up


a and f nodes a and f
gaf = Ga + Gf – 2caf = –3 + 9 – 20 = +6
KL algorithm
G = (5)
–3
G = 0
a Gb = +2
Gd = –1
c
f
1
b Ge = +1 Gf = +9
4 1 2
3
2 X’ = { c, e }
c d
Y’ = { b, d }
6 3 4
2
e a

Update the G-values of unlocked nodes


cut-size = 10
G’c = Gc + 2cca – 2ccf = 0 + 2(4 – 4) = 0
G’e = Ge + 2cea – 2cef = 1 + 2(2 – 6) = –7
G’b = Gb + 2cbf – 2cba= 2 + 2(0 – 3) = –4
G’d = Gd + 2cdf – 2cda = –1 + 2(1 – 0) = 1
KL algorithm
G’ =(6)
0
G’ = –7
c G’b = –4
G’d = +1
e
f b
1
4 1 2
3 X’ = { c, e }
c
2
d Y’ = { b, d }
6 3 4
2 Compute the gains
e a

g’cb = G’c + G’b – 2ccb = 0 – 4 – 21 = –6


cut-size = 10
g’cd = G’c + G’d – 2ccd = 0 + 1 – 22 = –3
g’eb = G’e + G’b – 2ceb = –7 – 4 – 20 = –11
g’ed = G’e + G’d – 2ced = –7 + 1 – 20 = –6

Pair with maximum gain


(can also be neative)
KL algorithm (7)
f b f b
1 4
4 2 1 1
1 3 2 3
2 2
c d d c
6 3 6 3
4 4
2 2
e a e a

cut-size = 10 cut-size = 10 – (–3) = 13

Exchange nodes c Then lock up


and d nodes c and d
g’cd = G’c + G’d – 2ccd = 0 + 1 – 22 = –3
KL algorithm (8)
f b G’c = 0 G’b = –4
1
4
1
G’e = –7 G’d = +1
2 3
2
d c X” = { e }
6 3 4 Y” = { b }
2
e a Update the G-values of unlocked nodes

cut-size = 13
G”e = G’e + 2ced – 2cec = –7 + 2(0 – 3) = –1
G”b = G’b + 2cbd – 2cbc= –4 + 2(2 – 1) = –2

Compute the gains


Pair with max. gain
is (e, b) g”eb = G”e + G”b – 2ceb = –1 – 2 – 20 = –3
KL algorithm (9)
• Summary of the Gains…
– g = +6
– g + g’ = +6 – 3 = +3
– g + g’ + g” = +6 – 3 – 3 = 0
• Maximum Gain = g = +6
• Exchange only nodes a and f.
• End of 1 pass.

 Repeat the Kernighan-Lin.


Summary of Pass 1
Iteration No Vertex Pair g(i) Cumulative Cut size
gain
0 - - - 16
1 (a,f) 6 6 10
2 (c,d) -3 3 13
3 (b,e) -3 0 16
Time Complexity of KL
• For each pass,
– O(n2) time to find the best pair to exchange.
– n pairs exchanged.
– Total time is O(n3) per pass.
• Better implementation can get O(n2lg n) time per
pass.

• Number of passes is usually small.


Advantage of KL
• Quite robust

• It can accommodate additional constraints, such as a group of


vertices requiring to be in a specified partition [very
important in layout because some blocks of the circuit are to
be kept together due to the functionality]
Disadvantage of KL
• Not applicable for hypergraphs

• Can not handle arbitrarily weighted graphs

• Partition sizes have to be specified before partitioning

• Complexity of the algorithm is considered too high even for


moderate size problems
Fiduccia-Mattheyses Algorithm
• Modified version ok KL Algorithm

Modification

 Only a single vertex is moved across the cut in a single move

 Extension of the concept of cutsize to hypergraphs

Вам также может понравиться