View
35
Download
4
Category
Preview:
DESCRIPTION
EE384y: Packet Switch Architectures Matchings, implementation and heuristics. Nick McKeown Professor of Electrical Engineering and Computer Science, Stanford University nickm@stanford.edu www.stanford.edu/~nickm. Outline. Finding a maximum match. Maximum network flow problems - PowerPoint PPT Presentation
Citation preview
1Spring 2004
Hi gh Pe rf orm a nceSwi tc hi ng and Routi ngTe lec om Ce nter W orks ho p: Sep t 4 , 19 97.
EE384y: Packet Switch ArchitecturesMatchings, implementation and heuristics
Nick McKeownProfessor of Electrical Engineering and Computer Science, Stanford Universitynickm@stanford.eduwww.stanford.edu/~nickm
Spring 20042
Outline Finding a maximum match.
Maximum network flow problems• Definitions and example• Augmenting paths
Maximum size/weight matchings as examples of maximum network flows
• Maximum size matching• Complexity of maximum size matchings and maximum weight
matchings What algorithms are used in practice?
Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) iSLIP
Spring 20043
Network FlowsSource
sSink
ta c
b d
10
10
101
11
10
10
• Let G = [V,E] be a directed graph with capacity cap(v,w) on edge [v,w].
• A flow is an (integer) function, f, that is chosen for each edge so that
• We wish to maximize the flow allocation.( , ), .( ) capf vv ww
Spring 20044
A maximum network flow example
By inspectionSource
sSink
ta c
b d
10
10
101
11
10
10
Step 1: Source
sSink
ta c
b d10, 1010
10, 101
11
10
10, 10
Flow is of size 10
Spring 20045
A maximum network flow example
Sources
Sinkt
a c
b d10, 1010, 1
10, 101
11, 1 10, 1
10, 10Step 2:
Flow is of size 10+1 = 11
Sources
Sinkt
a c
b d10, 1010, 2
10, 91,1
1,11, 1 10, 2
10, 10
Maximum flow:
Flow is of size 10+2 = 12
Not obvious
Spring 20046
Ford-Fulkerson method of augmenting paths
1. Set f(v,w) = -f(w,v) on all edges.2. Define a Residual Graph, R, in which
res(v,w) = cap(v,w) – f(v,w)3. Find paths from s to t for which there is
positive residue.4. Increase the flow along the paths to
augment them by the minimum residue along the path.
5. Keep augmenting paths until there are no more to augment.
Spring 20047
Example of Residual Graph
s t
a c
b d10, 1010
10, 101
11
10
10, 10
Flow is of size 10
t
a c
b d
10
10
101
11
10
10s
res(v,w) = cap(v,w) – f(v,w) Residual Graph, R
Augmenting path
Spring 20048
Example of Residual Graph
s ta c
b d10, 1010, 1
10, 101
11, 1 10, 1
10, 10Step 2:
Flow is of size 10+1 = 11
s ta c
b d
10
1
101
11
1
10Residual Graph
9 9
Spring 20049
Example of Residual Graph
s ta c
b d10, 1010, 2
10, 91, 1
1, 11, 1 10, 2
10, 10Step 3:
Flow is of size 10+2 = 12
s ta c
b d
10
2
91
11
2
10Residual Graph
8 8
1
Spring 200410
Complexity of network flow problems
In general, it is possible to find a solution by considering at most |V|.|E| paths, by picking shortest augmenting path first.
There are many variations, such as picking most augmenting path first.
Spring 200411
Outline Finding a maximum match.
Maximum network flow problems• Definitions and example• Augmenting paths
Maximum size/weight matchings as examples of maximum network flows
• Maximum size matching• Complexity of maximum size matchings and maximum weight
matchings What algorithms are used in practice?
Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) iSLIP
Spring 200412
Finding a maximum size match
How do we find the maximum size (weight) match?
ABCDEF
123456
Spring 200413
Network flows and bipartite matching
Finding a maximum size bipartite matching is equivalent to solving a network flow problem with
capacities and flows of size 1.
A 1
Sources
Sinkt
BCDEF
23456
Spring 200414
Network flows and bipartite matchingFord-Fulkerson method
A 1
s t
BCDEF
23456
Residual Graph for first three paths:
Spring 200415
Network flows and bipartite matching
A 1
s t
BCDEF
23456
Residual Graph for next two paths:
Spring 200416
Network flows and bipartite matching
A 1
s t
BCDEF
23456
Residual Graph for augmenting path:
Spring 200417
Network flows and bipartite matching
A 1
s t
BCDEF
23456
Residual Graph for last augmenting path:
Note that the path augments the match: no input and outputis removed from the match during the augmenting step.
Spring 200418
Network flows and bipartite matching
A 1
s t
BCDEF
23456
Maximum flow graph:
Spring 200419
Network flows and bipartite matching
A 1BCDEF
23456
Maximum Size Matching:
Spring 200420
Complexity of Maximum Matchings
Maximum Size Matchings: Algorithm by Dinic O(N5/2)
Maximum Weight Matchings Algorithm by Kuhn O(N3)
In general: Hard to implement in hardware Slooooow.
Spring 200421
Outline Finding a maximum match.
Maximum network flow problems• Definitions and example• Augmenting paths
Maximum size/weight matchings as examples of maximum network flows
• Maximum size matching• Complexity of maximum size matchings and maximum weight
matchings What algorithms are used in practice?
Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) iSLIP
Spring 200422
Maximal Matching A maximal matching is one in which
each edge is added one at a time, and is not later removed from the matching.
i.e. no augmenting paths allowed (they remove edges added earlier).
No input and output are left unnecessarily idle.
Spring 200423
Example of Maximal Size MatchingA 1BCDEF
23456
A 1BCDEF
23456
Maximal Size Matching
Maximum Size Matching
ABCDEF
123456
Spring 200424
Maximal Matchings In general, maximal matching is simpler to
implement, and has a faster running time. A maximal size matching is at least half
the size of a maximum size matching. A maximal weight matching is defined in
the obvious way. A maximal weight matching is at least half
the weight of a maximum weight matching.
Spring 200425
Outline Finding a maximum match.
Maximum network flow problems• Definitions and example• Augmenting paths
Maximum size/weight matchings as examples of maximum network flows
• Maximum size matching• Complexity of maximum size matchings and maximum weight
matchings What algorithms are used in practice?
Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) iSLIP
Spring 200426
Wave Front Arbiter(Tamir)
Requests Match123
4
123
4
123
4
123
4
Spring 200427
Wave Front Arbiter
Requests Match
Spring 200428
Wave Front ArbiterImplementation
1,1 1,2 1,3 1,4
2,1 2,2 2,3 2,4
3,1 3,2 3,3 3,4
4,1 4,2 4,3 4,4
Simple combinational logic blocks
Spring 200429
Wave Front ArbiterWrapped WFA (WWFA)
Requests Match
N steps instead of2N-1
Spring 200430
Wavefront ArbitersProperties
Feed-forward (i.e. non-iterative) design lends itself to pipelining.
Always finds maximal match. Usually requires mechanism to prevent
Q11 from getting preferential service. In principle, can be distributed over
multiple chips.
Spring 200431
Outline Finding a maximum match.
Maximum network flow problems• Definitions and example• Augmenting paths
Maximum size/weight matchings as examples of maximum network flows
• Maximum size matching• Complexity of maximum size matchings and maximum weight
matchings What algorithms are used in practice?
Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) iSLIP
Spring 200432
Parallel Iterative Matching
1234
1234
1: Requests
1234
1234
2: Grant
1234
1234
3: Accept/Match
uar selection
1234
1234
uar selection
1234
1234
#1
#2
Iteration:
1234
1234
Spring 200433
PIM Properties Guaranteed to find a maximal match in
at most N iterations. In each phase, each input and output
arbiter can make decisions independently.
In general, will converge to a maximal match in < N iterations.
How many iterations should we run?
Spring 200434
Parallel Iterative MatchingConvergence Time
E C Nlog
E Ui N2
4i------- C # of iterations required to resolve connections=N # of ports =
Ui # of unresolved connections after iteration i=
Number of iterations to converge:
Spring 200435
Parallel Iterative Matching
Spring 200436
Parallel Iterative Matching
PIM with a single iteration
Spring 200437
Parallel Iterative Matching
PIM with 4 iterations
Spring 200438
Outline Finding a maximum match.
Maximum network flow problems• Definitions and example• Augmenting paths
Maximum size/weight matchings as examples of maximum network flows
• Maximum size matching• Complexity of maximum size matchings and maximum weight
matchings What algorithms are used in practice?
Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) iSLIP
Spring 200439
iSLIP
1234
1234
1: Requests
1234
1234
3: Accept/Match1234
1234
#1
#2
1234
1234
1234
1234
1234
1234
2: Grant
12
3
4
Spring 200440
iSLIP Operation Grant phase: Each output selects the
requesting input at the pointer, or the next input in round-robin order. It only updates its pointer if the grant is accepted.
Accept phase: Each input selects the granting output at the pointer, or the next output in round-robin order.
Consequence: Under high load, grant pointers tend to move to unique values.
Spring 200441
iSLIPProperties
Random under low load TDM under high load Lowest priority to MRU 1 iteration: fair to outputs Converges in at most N iterations. (On
average, simulations suggest < log2N) Implementation: N priority encoders 100% throughput for uniform i.i.d. traffic. But…some pathological patterns can lead to
low throughput.
Spring 200442
iSLIP
Spring 200443
iSLIP
Spring 200444
iSLIPImplementation
Grant
Grant
Grant
Accept
Accept
Accept
1
2
N
1
2
N
State
N
N
N
Decision
log2N
log2N
log2N
ProgrammablePriority Encoder
Spring 200445
Maximal Matches Maximal matching algorithms are widely
used in industry (PIM, iSLIP, WFA and others).
PIM and iSLIP are rarely run to completion (i.e. they are sub-maximal).
We will see shortly that a maximal match with a speedup of 2 is stable for non-uniform traffic.
Recommended