EE 384 y Packet Switch Architectures Matchings implementation

  • Slides: 45
Download presentation
EE 384 y: Packet Switch Architectures Matchings, implementation and heuristics Nick Mc. Keown Professor

EE 384 y: Packet Switch Architectures Matchings, implementation and heuristics Nick Mc. Keown Professor of Electrical Engineering and Computer Science, Stanford University nickm@stanford. edu www. stanford. edu/~nickm August 21 st, 2001 1

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight matchings as examples of maximum network flows • Definitions and example • Augmenting paths • Maximum size matching • Complexity of maximum size matchings and maximum weight matchings v What algorithms are used in practice? Ø Ø Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) i. SLIP Spring 2006 2

Network Flows Source s 10 10 • • • a c 10 1 b

Network Flows Source s 10 10 • • • a c 10 1 b 1 1 d 10 10 Sink t 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. Spring 2006 3

A maximum network flow example By inspection Source s a 10 10 1 b

A maximum network flow example By inspection Source s a 10 10 1 b Step 1: Source s a 1 1 10, 10 b d c 1 10, 10 10 c 10 1 1 d 10 10 10, 10 10 Sink t Flow is of size 10 Spring 2006 4

A maximum network flow example Step 2: Source s a c 1 10, 10

A maximum network flow example Step 2: Source s a c 1 10, 10 b 1 1, 1 d 10, 10 Sink t 10, 1 Flow is of size 10+1 = 11 Maximum flow: Source s a 10, 10 10, 2 b 10, 9 c 1, 1 d 10, 10 Not obvious Sink t 10, 2 Flow is of size 10+2 = 12 Spring 2006 5

Ford-Fulkerson method of augmenting paths 1. 2. 3. 4. 5. Set f(v, w) =

Ford-Fulkerson method of augmenting paths 1. 2. 3. 4. 5. Set f(v, w) = -f(w, v) on all edges. Define a Residual Graph, R, in which res(v, w) = cap(v, w) – f(v, w) Find paths from s to t for which there is positive residue. Increase the flow along the paths to augment them by the minimum residue along the path. Keep augmenting paths until there are no more to augment. Spring 2006 6

Example of Residual Graph a s 10, 10 10 b c 1 1 d

Example of Residual Graph a s 10, 10 10 b c 1 1 d 10, 10 10 t Flow is of size 10 Residual Graph, R res(v, w) = cap(v, w) – f(v, w) a 10 c 10 s 10 10 1 b 1 1 d 10 t Augmenting path Spring 2006 7

Example of Residual Graph Step 2: a s c 1 10, 10 b 1

Example of Residual Graph Step 2: a s c 1 10, 10 b 1 d 1, 1 10, 10 t 10, 1 Flow is of size 10+1 = 11 Residual Graph 10 s 1 9 a c 10 1 b 1 1 d 10 t 1 9 Spring 2006 8

Example of Residual Graph Step 3: a s 1, 1 10, 10 10, 2

Example of Residual Graph Step 3: a s 1, 1 10, 10 10, 2 c 10, 9 b 1, 1 d 10, 10 t 10, 2 Flow is of size 10+2 = 12 Residual Graph 10 s 2 8 a 1 c 9 1 b 1 1 d 10 t 2 8 Spring 2006 9

Complexity of network flow problems In general, it is possible to find a solution

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. v There are many variations, such as picking most augmenting path first. v Spring 2006 10

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight matchings as examples of maximum network flows • Definitions and example • Augmenting paths • Maximum size matching • Complexity of maximum size matchings and maximum weight matchings v What algorithms are used in practice? Ø Ø Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) i. SLIP Spring 2006 11

Finding a maximum size match v A 1 B 2 C 3 D 4

Finding a maximum size match v A 1 B 2 C 3 D 4 E 5 F 6 How do we find the maximum size (weight) match? Spring 2006 12

Network flows and bipartite matching Source s A 1 B 2 C 3 D

Network flows and bipartite matching Source s A 1 B 2 C 3 D 4 E 5 F 6 Sink t Finding a maximum size bipartite matching is equivalent to solving a network flow problem with capacities and flows of size 1. Spring 2006 13

Network flows and bipartite matching Ford-Fulkerson method Residual Graph for first three paths: s

Network flows and bipartite matching Ford-Fulkerson method Residual Graph for first three paths: s A 1 B 2 C 3 D 4 E 5 F 6 t Spring 2006 14

Network flows and bipartite matching Residual Graph for next two paths: s A 1

Network flows and bipartite matching Residual Graph for next two paths: s A 1 B 2 C 3 D 4 E 5 F 6 t Spring 2006 15

Network flows and bipartite matching Residual Graph for augmenting path: s A 1 B

Network flows and bipartite matching Residual Graph for augmenting path: s A 1 B 2 C 3 D 4 E 5 F 6 t Spring 2006 16

Network flows and bipartite matching Residual Graph for last augmenting path: s A 1

Network flows and bipartite matching Residual Graph for last augmenting path: s A 1 B 2 C 3 D 4 E 5 F 6 t Note that the path augments the match: no input and output is removed from the match during the augmenting step. Spring 2006 17

Network flows and bipartite matching Maximum flow graph: s A 1 B 2 C

Network flows and bipartite matching Maximum flow graph: s A 1 B 2 C 3 D 4 E 5 F 6 t Spring 2006 18

Network flows and bipartite matching Maximum Size Matching: A 1 B 2 C 3

Network flows and bipartite matching Maximum Size Matching: A 1 B 2 C 3 D 4 E 5 F 6 Spring 2006 19

Complexity of Maximum Matchings v Maximum Size Matchings: Ø v Maximum Weight Matchings Ø

Complexity of Maximum Matchings v Maximum Size Matchings: Ø v Maximum Weight Matchings Ø v Algorithm by Dinic O(N 5/2) Algorithm by Kuhn O(N 3) In general: Ø Ø Hard to implement in hardware Slooooow. Spring 2006 20

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight matchings as examples of maximum network flows • Definitions and example • Augmenting paths • Maximum size matching • Complexity of maximum size matchings and maximum weight matchings v What algorithms are used in practice? Ø Ø Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) i. SLIP Spring 2006 21

Maximal Matching A maximal matching is one in which each edge is added one

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. v i. e. no augmenting paths allowed (they remove edges added earlier). v No input and output are left unnecessarily idle. v Spring 2006 22

Example of Maximal Size Matching A 1 A 1 B 2 B 2 C

Example of Maximal Size Matching A 1 A 1 B 2 B 2 C 3 3 D 4 C D 4 4 E 5 D 5 F F 6 E 5 6 E F 6 Maximal Size Matching Maximum Size Matching Spring 2006 23

Maximal Matchings In general, maximal matching is simpler to implement, and has a faster

Maximal Matchings In general, maximal matching is simpler to implement, and has a faster running time. v A maximal size matching is at least half the size of a maximum size matching. v A maximal weight matching is defined in the obvious way. v A maximal weight matching is at least half the weight of a maximum weight matching. v Spring 2006 24

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight matchings as examples of maximum network flows • Definitions and example • Augmenting paths • Maximum size matching • Complexity of maximum size matchings and maximum weight matchings v What algorithms are used in practice? Ø Ø Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) i. SLIP Spring 2006 25

Wave Front Arbiter (Tamir) Requests Match 1 1 2 2 3 3 4 4

Wave Front Arbiter (Tamir) Requests Match 1 1 2 2 3 3 4 4 Spring 2006 26

Wave Front Arbiter Requests Match Spring 2006 27

Wave Front Arbiter Requests Match Spring 2006 27

Wave Front Arbiter Implementation 1, 1 1, 2 1, 3 1, 4 2, 1

Wave Front Arbiter Implementation 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 2006 28

Wave Front Arbiter Wrapped WFA (WWFA) N steps instead of 2 N-1 Requests Match

Wave Front Arbiter Wrapped WFA (WWFA) N steps instead of 2 N-1 Requests Match Spring 2006 29

Wavefront Arbiters Properties Feed-forward (i. e. non-iterative) design lends itself to pipelining. v Always

Wavefront Arbiters Properties Feed-forward (i. e. non-iterative) design lends itself to pipelining. v Always finds maximal match. v Usually requires mechanism to prevent Q 11 from getting preferential service. v In principle, can be distributed over multiple chips. v Spring 2006 30

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight matchings as examples of maximum network flows • Definitions and example • Augmenting paths • Maximum size matching • Complexity of maximum size matchings and maximum weight matchings v What algorithms are used in practice? Ø Ø Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) i. SLIP Spring 2006 31

Iteration: #1 Parallel Iterative Matching uar selection 1 2 3 1 2 3 4

Iteration: #1 Parallel Iterative Matching uar selection 1 2 3 1 2 3 4 4 4 f 1: Requests f 2: Grant f 3: Accept/Match 1 2 #2 3 1 2 3 1 2 3 4 4 4 Spring 2006 32

PIM Properties Guaranteed to find a maximal match in at most N iterations. v

PIM Properties Guaranteed to find a maximal match in at most N iterations. v In each phase, each input and output arbiter can make decisions independently. v In general, will converge to a maximal match in < N iterations. v How many iterations should we run? v Spring 2006 33

Parallel Iterative Matching Convergence Time Number of iterations to converge: Spring 2006 34

Parallel Iterative Matching Convergence Time Number of iterations to converge: Spring 2006 34

Parallel Iterative Matching Spring 2006 35

Parallel Iterative Matching Spring 2006 35

Parallel Iterative Matching PIM with a single iteration Spring 2006 36

Parallel Iterative Matching PIM with a single iteration Spring 2006 36

Parallel Iterative Matching PIM with 4 iterations Spring 2006 37

Parallel Iterative Matching PIM with 4 iterations Spring 2006 37

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight

Outline v Finding a maximum match. Ø Maximum network flow problems Ø Maximum size/weight matchings as examples of maximum network flows • Definitions and example • Augmenting paths • Maximum size matching • Complexity of maximum size matchings and maximum weight matchings v What algorithms are used in practice? Ø Ø Maximal Matches Wavefront Arbiter (WFA) Parallel Iterative Matching (PIM) i. SLIP Spring 2006 38

i. SLIP 1 4 #1 1 2 3 4 4 F 1: Requests F

i. SLIP 1 4 #1 1 2 3 4 4 F 1: Requests F 2: Grant 2 3 1 2 3 4 4 F 3: Accept/Match 1 2 #2 3 1 2 3 1 2 3 4 4 4 Spring 2006 39

i. SLIP Operation Grant phase: Each output selects the requesting input at the pointer,

i. SLIP 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. v Accept phase: Each input selects the granting output at the pointer, or the next output in round-robin order. v Consequence: Under high load, grant pointers tend to move to unique values. v Spring 2006 40

i. SLIP Properties v v v v Random under low load TDM under high

i. SLIP Properties v v v v 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 < log 2 N) Implementation: N priority encoders 100% throughput for uniform i. i. d. traffic. But…some pathological patterns can lead to low throughput. Spring 2006 41

i. SLIP Spring 2006 42

i. SLIP Spring 2006 42

i. SLIP Spring 2006 43

i. SLIP Spring 2006 43

Programmable Priority Encoder N N i. SLIP Implementation 1 Grant 1 Accept log 2

Programmable Priority Encoder N N i. SLIP Implementation 1 Grant 1 Accept log 2 N 2 2 log 2 N Grant Accept State Decision N N Grant N Accept log 2 N Spring 2006 44

Maximal Matches Maximal matching algorithms are widely used in industry (PIM, i. SLIP, WFA

Maximal Matches Maximal matching algorithms are widely used in industry (PIM, i. SLIP, WFA and others). v PIM and i. SLIP are rarely run to completion (i. e. they are sub-maximal). v A maximal match with a speedup of 2 is stable for non-uniform traffic. v Spring 2006 45