EE384y Heuristics

download EE384y Heuristics

of 45

Transcript of EE384y Heuristics

  • 8/9/2019 EE384y Heuristics

    1/45

    1Spring 2006

    H i g h P e r f o r m a n c eS w i tc h i n g a n d R o u t ing

    Tel eco m Cen ter Wo rks hop : Sep t4, 19 97.

    EE384y: Packet Switch Architectures

    Matchings, implementation and heuristics

    Nick McKeownProfessor of Electrical Engineeringand Computer Science, Stanford University

    [email protected]/~nickm

  • 8/9/2019 EE384y Heuristics

    2/45

    Spring 20062

    Outline Finding a maximum match.

    Maximum network flowproblems Definitions and example Augmenting paths

    Maximum size/weight matchings as examples of maximum networkflows

    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

  • 8/9/2019 EE384y Heuristics

    3/45

    Spring 20063

    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 capacitycap(v,w) on edge [v,w].

    A flowis an (integer) function,f, that is chosenfor each edge so that

    We wish to maximize the flow allocation.

    ( , ), .( ) capf vv ww

  • 8/9/2019 EE384y Heuristics

    4/45

    Spring 20064

    A maximum network flow exampleBy inspection

    Sources

    Sinkt

    a c

    b d

    10

    10

    10

    1

    1

    1

    10

    10

    Step 1:

    Source

    s

    Sink

    t

    a c

    b d10, 1010

    10, 10

    11

    1

    10

    10, 10

    Flow is of size 10

  • 8/9/2019 EE384y Heuristics

    5/45

    Spring 20065

    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

    Source

    s

    Sink

    t

    a c

    b d10, 1010, 2

    10, 9

    1,11,1

    1, 1 10, 2

    10, 10

    Maximum flow:

    Flow is of size 10+2 = 12

    Notobvious

  • 8/9/2019 EE384y Heuristics

    6/45

    Spring 20066

    Ford-Fulkerson method ofaugmenting paths

    1. Setf(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 froms to tfor which there ispositive residue.

    4. Increase the flow along the paths to

    augment them by the minimum residuealong the path.5. Keep augmenting paths until there are no

    more to augment.

  • 8/9/2019 EE384y Heuristics

    7/45

    Spring 20067

    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

  • 8/9/2019 EE384y Heuristics

    8/45

    Spring 20068

    Example of Residual Graph

    s ta 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

    11

    1

    1

    10

    Residual Graph

    9 9

  • 8/9/2019 EE384y Heuristics

    9/45

  • 8/9/2019 EE384y Heuristics

    10/45

    Spring 200610

    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.

  • 8/9/2019 EE384y Heuristics

    11/45

    Spring 200611

    Outline Finding a maximum match.

    Maximum network flowproblems Definitions and example Augmenting paths

    Maximum size/weight matchings as examples of maximum networkflows

    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

  • 8/9/2019 EE384y Heuristics

    12/45

  • 8/9/2019 EE384y Heuristics

    13/45

    Spring 200613

    Network flows and bipartite matching

    Finding a maximum size bipartite matching is equivalentto 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

  • 8/9/2019 EE384y Heuristics

    14/45

    Spring 200614

    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:

  • 8/9/2019 EE384y Heuristics

    15/45

    Spring 200615

    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:

  • 8/9/2019 EE384y Heuristics

    16/45

    Spring 200616

    Network flows and bipartite matching

    A 1

    s t

    B

    C

    D

    E

    F

    2

    3

    4

    5

    6

    Residual Graph for augmenting path:

  • 8/9/2019 EE384y Heuristics

    17/45

    Spring 200617

    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.

  • 8/9/2019 EE384y Heuristics

    18/45

    Spring 200618

    Network flows and bipartite matching

    A 1

    s t

    B

    C

    D

    E

    F

    2

    3

    4

    5

    6

    Maximum flow graph:

  • 8/9/2019 EE384y Heuristics

    19/45

    Spring 200619

    Network flows and bipartite matching

    A 1

    B

    C

    D

    E

    F

    2

    3

    4

    5

    6

    Maximum Size Matching:

  • 8/9/2019 EE384y Heuristics

    20/45

    Spring 200620

    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.

  • 8/9/2019 EE384y Heuristics

    21/45

    Spring 200621

    Outline Finding a maximum match.

    Maximum network flowproblems Definitions and example Augmenting paths

    Maximum size/weight matchings as examples of maximum networkflows

    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

  • 8/9/2019 EE384y Heuristics

    22/45

    Spring 200622

    Maximal Matching

    A maximal matching is one in which eachedge 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.

  • 8/9/2019 EE384y Heuristics

    23/45

    Spring 200623

    Example of Maximal Size Matching

    A 1B

    C

    DE

    F

    2

    3

    45

    6

    A 1B

    C

    DE

    F

    2

    3

    45

    6

    MaximalSize Matching

    MaximumSize Matching

    AB

    C

    DE

    F

    12

    3

    45

    6

  • 8/9/2019 EE384y Heuristics

    24/45

    Spring 200624

    Maximal Matchings

    In general, maximalmatching is simpler toimplement, and has a faster running time.

    A maximal size matching is at least half thesize of a maximum size matching.

    A maximal weight matching is defined inthe obvious way.

    A maximal weight matching is at least halfthe weight of a maximum weight matching.

  • 8/9/2019 EE384y Heuristics

    25/45

    Spring 200625

    Outline Finding a maximum match.

    Maximum network flowproblems Definitions and example Augmenting paths

    Maximum size/weight matchings as examples of maximum networkflows

    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

  • 8/9/2019 EE384y Heuristics

    26/45

  • 8/9/2019 EE384y Heuristics

    27/45

    Spring 2006 27

    Wave Front Arbiter

    Requests Match

  • 8/9/2019 EE384y Heuristics

    28/45

    Spring 2006 28

    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

  • 8/9/2019 EE384y Heuristics

    29/45

    Spring 2006 29

    Wave Front Arbiter

    Wrapped WFA (WWFA)

    Requests Match

    Nsteps instead of

    2N-1

  • 8/9/2019 EE384y Heuristics

    30/45

    Spring 2006 30

    Wavefront Arbiters

    Properties Feed-forward (i.e. non-iterative) design

    lends itself to pipelining.

    Always finds maximal match. Usually requires mechanism to prevent Q

    11

    from getting preferential service.

    In principle, can be distributed overmultiple chips.

  • 8/9/2019 EE384y Heuristics

    31/45

    Spring 2006 31

    Outline Finding a maximum match.

    Maximum network flowproblems Definitions and example Augmenting paths

    Maximum size/weight matchings as examples of maximum networkflows

    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

  • 8/9/2019 EE384y Heuristics

    32/45

    Spring 2006 32

    Parallel Iterative Matching

    1

    2

    3

    4

    1

    2

    3

    4

    1: Requests

    1

    2

    3

    4

    1

    2

    3

    4

    2: Grant

    1

    2

    3

    4

    1

    2

    3

    4

    3: Accept/Match

    uar selection

    1

    2

    3

    4

    1

    2

    3

    4

    uar selection

    1

    2

    3

    4

    1

    2

    3

    4

    #1

    #2

    Iterati

    on:

    1

    2

    3

    4

    1

    2

    3

    4

  • 8/9/2019 EE384y Heuristics

    33/45

    Spring 2006 33

    PIM Properties

    Guaranteed to find a maximal match in atmostNiterations.

    In each phase, each input and outputarbiter can make decisions independently. In general, will converge to a maximal

    match in

  • 8/9/2019 EE384y Heuristics

    34/45

    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:

    P ll l It ti M t hin

  • 8/9/2019 EE384y Heuristics

    35/45

    Spring 2006 35

    Parallel Iterative Matching

    P r ll l It r tiv M tchin

  • 8/9/2019 EE384y Heuristics

    36/45

    Spring 2006

    36

    Parallel Iterative Matching

    PIM with asingle iteration

    Parallel Iterative Matching

  • 8/9/2019 EE384y Heuristics

    37/45

    Spring 2006

    37

    Parallel Iterative Matching

    PIM with 4iterations

  • 8/9/2019 EE384y Heuristics

    38/45

    Spring 2006

    38

    Outline Finding a maximum match.

    Maximum network flowproblems Definitions and example Augmenting paths

    Maximum size/weight matchings as examples of maximum networkflows

    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

  • 8/9/2019 EE384y Heuristics

    39/45

    Spring 2006

    39

    iSLIP

    1

    2

    3

    4

    1

    2

    3

    4

    1: Requests

    1

    2

    3

    4

    1

    2

    3

    4

    3: 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

    4

    2: Grant

    1

    2

    3

    4

  • 8/9/2019 EE384y Heuristics

    40/45

    Spring 2006

    40

    iSLIP Operation

    Grant phase: Each output selects therequesting input at the pointer, or the next

    input in round-robin order. It only updatesits 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.

  • 8/9/2019 EE384y Heuristics

    41/45

    Spring 2006

    41

    iSLIP

    Properties Random under low load TDM under high load Lowest priority to MRU 1 iteration: fair to outputs Converges in at mostNiterations. (On average,

    simulations suggest < log2N) Implementation:Npriority encoders 100% throughput for uniform i.i.d. traffic. Butsome pathological patterns can lead to low

    throughput.

    iSLIP

  • 8/9/2019 EE384y Heuristics

    42/45

    Spring 2006

    42

    iSLIP

    iSLIP

  • 8/9/2019 EE384y Heuristics

    43/45

    Spring 2006

    43

    iSLIP

  • 8/9/2019 EE384y Heuristics

    44/45

    Spring 2006

    44

    iSLIP

    Implementation

    Grant

    Grant

    Grant

    Accept

    Accept

    Accept

    1

    2

    N

    1

    2

    N

    State

    N

    N

    N

    Decision

    log2N

    log2N

    log2N

    Programmable

    Priority Encoder

  • 8/9/2019 EE384y Heuristics

    45/45

    Spring 2006

    Maximal Matches

    Maximal matching algorithms are widelyused 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.