ee384y: packet switch architectures matchings, implementation and heuristics

45
1 Spring 2006 EE384y: Packet Switch Architectures Matchings, implementation and heuristics Nick McKeown Professor of Electrical Engineering and Computer Science, Stanford University [email protected] www.stanford.edu/~nickm

Upload: caroun

Post on 30-Jan-2016

38 views

Category:

Documents


0 download

DESCRIPTION

EE384y: Packet Switch Architectures Matchings, implementation and heuristics. Nick McKeown Professor of Electrical Engineering and Computer Science, Stanford University [email protected] www.stanford.edu/~nickm. Outline. Finding a maximum match. Maximum network flow problems - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

1

Spring 2006

High PerformanceSwitching and RoutingTelecom Center Workshop: Sept 4, 1997.

EE384y: Packet Switch Architectures

Matchings, implementation and heuristics

Nick McKeownProfessor of Electrical Engineering and Computer Science, Stanford University

[email protected]/~nickm

Page 2: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

2

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

Page 3: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

3

Network Flows

Sources

Sinkt

a c

b d

10

10

10

1

1

1

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

Page 4: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

4

A maximum network flow example

By inspectionSource

sSink

t

a c

b d

10

10

10

1

1

1

10

10

Step 1:

Sources

Sinkt

a c

b d

10, 10

10

10, 10

1

1

1

10

10, 10

Flow is of size 10

Page 5: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

5

A maximum network flow example

Sources

Sinkt

a c

b d

10, 10

10, 1

10, 10

1

1

1, 1 10, 1

10, 10

Step 2:

Flow is of size 10+1 = 11

Sources

Sinkt

a c

b d

10, 10

10, 2

10, 9

1,1

1,1

1, 1 10, 2

10, 10

Maximum flow:

Flow is of size 10+2 = 12

Not obvious

Page 6: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

6

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.

Page 7: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

7

Example of Residual Graph

s t

a c

b d

10, 10

10

10, 10

1

1

1

10

10, 10

Flow is of size 10

t

a c

b d

10

10

10

1

1

1

10

10

s

res(v,w) = cap(v,w) – f(v,w) Residual Graph, R

Augmenting path

Page 8: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

8

Example of Residual Graph

s t

a c

b d

10, 10

10, 1

10, 10

1

1

1, 1 10, 1

10, 10

Step 2:

Flow is of size 10+1 = 11

s t

a c

b d

10

1

10

1

1

1

1

10

Residual Graph

9 9

Page 9: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

9

Example of Residual Graph

s t

a c

b d

10, 10

10, 2

10, 9

1, 1

1, 1

1, 1 10, 2

10, 10

Step 3:

Flow is of size 10+2 = 12

s t

a c

b d

10

2

9

1

1

1

2

10

Residual Graph

8 8

1

Page 10: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

10

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.

Page 11: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

11

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

Page 12: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

12

Finding a maximum size match

How do we find the maximum size (weight) match?

A

B

C

D

E

F

1

2

3

4

5

6

Page 13: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

13

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

B

C

D

E

F

2

3

4

5

6

Page 14: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

14

Network flows and bipartite matchingFord-Fulkerson method

A 1

s t

B

C

D

E

F

2

3

4

5

6

Residual Graph for first three paths:

Page 15: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

15

Network flows and bipartite matching

A 1

s t

B

C

D

E

F

2

3

4

5

6

Residual Graph for next two paths:

Page 16: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

16

Network flows and bipartite matching

A 1

s t

B

C

D

E

F

2

3

4

5

6

Residual Graph for augmenting path:

Page 17: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

17

Network flows and bipartite matching

A 1

s t

B

C

D

E

F

2

3

4

5

6

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.

Page 18: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

18

Network flows and bipartite matching

A 1

s t

B

C

D

E

F

2

3

4

5

6

Maximum flow graph:

Page 19: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

19

Network flows and bipartite matching

A 1

B

C

D

E

F

2

3

4

5

6

Maximum Size Matching:

Page 20: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

20

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.

Page 21: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

21

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

Page 22: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

22

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.

Page 23: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

23

Example of Maximal Size Matching

A 1

B

C

D

E

F

2

3

4

5

6

A 1

B

C

D

E

F

2

3

4

5

6

Maximal Size Matching

Maximum Size Matching

A

B

C

D

E

F

1

2

3

4

5

6

Page 24: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

24

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.

Page 25: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

25

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

Page 26: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

26

Wave Front Arbiter(Tamir)

Requests Match

1

2

3

4

1

2

3

4

1

2

3

4

1

2

3

4

Page 27: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

27

Wave Front Arbiter

Requests Match

Page 28: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

28

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

Page 29: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

29

Wave Front ArbiterWrapped WFA (WWFA)

Requests Match

N steps instead of2N-1

Page 30: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

30

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.

Page 31: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

31

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

Page 32: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

32

Parallel Iterative Matching

1

2

3

4

1

2

3

4

1: Requests

1

2

3

4

1

2

3

42: Grant

1

2

3

4

1

2

3

43: Accept/Match

uar selection

1

2

3

4

1

2

3

4

uar selection

1

2

3

4

1

2

3

4

#1

#2

Itera

tion

:

1

2

3

4

1

2

3

4

Page 33: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

33

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?

Page 34: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

34

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:

Page 35: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

35

Parallel Iterative Matching

Page 36: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

36

Parallel Iterative Matching

PIM with a single iteration

Page 37: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

37

Parallel Iterative Matching

PIM with 4 iterations

Page 38: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

38

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

Page 39: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

39

iSLIP

1

2

3

4

1

2

3

4

1: Requests

1

2

3

4

1

2

3

43: Accept/Match

1

2

3

4

1

2

3

4

#1

#2

1

2

3

4

1

2

3

4

1

2

3

4

1

2

3

4

1

2

3

4

1

2

3

42: Grant

12

3

4

Page 40: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

40

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.

Page 41: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

41

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.

Page 42: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

42

iSLIP

Page 43: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

43

iSLIP

Page 44: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

44

iSLIPImplementation

Grant

Grant

Grant

Accept

Accept

Accept

1

2

N

1

2

N

State

N

N

N

Decision

log2N

log2N

log2N

ProgrammablePriority Encoder

Page 45: EE384y: Packet Switch Architectures Matchings, implementation and heuristics

Spring 2006

45

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).

A maximal match with a speedup of 2 is stable for non-uniform traffic.