Top Banner
Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego
25

Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications

Hao Wang and Bill Lin

University of California, San Diego

Page 2: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 2

Introduction

• Priority queues used many network applications• Per-flow weighted fair queueing• Management of per-flow packet buffers using DRAM• Maintenance of exact statistics counters for real-time

network measurements

• Items in priority queue sorted at all times(e.g. smallest key first)

• Challenge: Need to operate at high speeds (e.g. 10+ Gb/s)

Page 3: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 3

Introduction

• Binary heap common data structure for priority queues

• O(lg n) time complexity, where n is # items

• e.g. in fine-grained per-flow weighted fair queueing, n can be very large (e.g. 1 million)

• O(lg n) may be too slow for high line rates

• Pipeline heaps [Bhagwan, Lin 2000][Ioannou, Katevenis 2001]

• Reduced time complexity to O(1)• At the expense of O(lg n) pipeline stages

Page 4: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 4

This Talk

• Instead of pipelining binary heaps, we present new approach based on pipelining van Emde Boas trees

• van Emde Boas (vEB) trees introduced in 1975• Instead of maintaining a priority queue of sorted

items, maintain a sorted dictionary of keys• In many applications, since keys are represented by

a w-bit integer, possible keys can only be from fixed universe of u = 2w values

• Only O(lg lg u) complexity vs. O(lg n) for heaps

• Main result: pipelined vEB with O(1) operation andO(lg lg u) pipeline stages

Page 5: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 5

van Emde Boas (vEB) Trees

• Goal: Maintain a sorted subset S from universe

U = {0, 1, …, u – 1} of size u = 2w, subject to INSERT, DELETE, EXTRACTMIN, SUCCESSOR, PREDECESSOR. e.g.

• INSERT – Inserts new item into the queue

• EXTRACTMIN – Removes item with smallest key

Page 6: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 6

vEB Trees

• Size u vs. n depends on application. e.g.

• If u is only polynomial in n, i.e. u = O(nc), then

O(lg lg u) = O(lg lg n), exponential speedup over O(lg n)

Per-flowFair Queues

24 bits 4 × 106

StatisticsCounters

106 counters512 groups

106 flows

Application w u = 2w n

5

3

O(lg lg u)

20

208

O(lg n)

u ≈ n

u « nu ≈ n

compare

5128 bits

Page 7: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 7

H and L[0], …,L[ – 1] recursivelydefined as vEB treeswith w/2 bits

H and L[0], …,L[ – 1] recursivelydefined as vEB treeswith w/2 bits

vEB Trees

• Conceptually think of the universe of w-bits,

U = {0, 1, …, 2w – 1}, as a binary tree with height w• Think of top part H of w/2 bits,

and bottom part of sub-trees ofw/2 bits, L[0], L[1], …, L[ – 1]

L[0] L[1] L[ -1]. . .

Hw/2 bits

w/2 bits

sub-trees

Page 8: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 8

vEB Trees

• Suppose w = 8 bits, consider e.g. a key x = 31

• Split x into high and low parts:

• Consider INSERT( x, S )

• If xh H, recursively call

• INSERT( xl , L[xh] )

• Else, recursively call

• INSERT( xh , H )

• INSERT( xl , L[xh] )

• Can avoid 2nd recursionby storing min[S]

L[0] L[1] L[ -1]. . .

H w/2 bits

w/2 bits

sub-trees

0 0 0 1 1 1 1 1

xh xl

Page 9: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 9

Representing vEB Trees

• min[S] : minimum key in S

• n[S] : number of elements in S

• H, L’s : just pointers to corresponding vEB sub-trees

H L[0] L[1] L[ – 1]

min[S] n[S]

Page 10: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 10

INSERT Operation

// if S empty set min to x

// if x is smaller swap them

// increment size of S

// recursive call to either L[xh] or H

Only One Recursive CallOnly One Recursive Call

Page 11: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 11

INSERT Operation

INSERT( x, S )

• If xh H, recursively call

• INSERT( xl , L[xh] )

• Else, recursively call

• INSERT( xh , H )

• min( L[xh] ) ← xl

L[0] L[1] L[255]. . .

H 4 bits

4 bits

Suppose w = 8 x = 0 0 0 1 1 1 1 1

xh xl

Page 12: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 12

INSERT Operation

INSERT( x, S )

• If xh H, recursively call

• INSERT( xl , L[xh] )

• Else, recursively call

• INSERT( xh , H )

• min( L[xh] ) ← xl

L[0] L[1] L[255]. . .

H 4 bits

4 bits

Suppose w = 8 x = 0 0 0 1 1 1 1 1

xh xl

Page 13: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 13

INSERT Operation

INSERT( x, S )

• If xh H, recursively call

• INSERT( xl , L[xh] )

• Else, recursively call

• INSERT( xh , H )

• min( L[xh] ) ← xl

L[1] 4 bits

Now w = 4 x = 1 1 1 1

xh xl

Page 14: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 14

INSERT Operation

INSERT( x, S )

• If xh H, recursively call

• INSERT( xl , L[xh] )

• Else, recursively call

• INSERT( xh , H )

• min( L[xh] ) ← xl

L[0] L[1] L[255]. . .

2 bits

2 bits

H

Now w = 4 x = 1 1 1 1

xh xl

Page 15: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 15

INSERT Operation

INSERT( x, S )

• If xh H, recursively call

• INSERT( xl , L[xh] )

• Else, recursively call

• INSERT( xh , H )

• min( L[xh] ) ← xl

L[0] L[1] L[255]. . .

H 2 bits

2 bits

Now w = 4 x = 1 1 1 1

xh xl

Page 16: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 16

INSERT Operation

INSERT( x, S )

• If xh H, recursively call

• INSERT( xl , L[xh] )

• Else, recursively call

• INSERT( xh , H )

• min( L[xh] ) ← xl

L[0] L[1] L[255]. . .

2 bits

2 bits

H

Now w = 4 x = 1 1 1 1

xh xl

Overall O(lg w) or O(lg lg u) timeOverall O(lg w) or O(lg lg u) time

Page 17: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 17

EXTRACTMIN Operation

// if S empty, nothing to return// set return to current min

// decrement size of S

// recursive call to either H or L[mh]

// set new minimum and return value

Page 18: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 18

EXTRACTMIN Operation

// if S empty, nothing to return// set return to current min

// decrement size of S

// recursive call to either H or L[mh]

// set new minimum and return value

Again Only One Recursive CallAgain Only One Recursive Call

Page 19: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 19

Basic Idea of Pipelining

• vEB operations are recursively defined• Each operation only makes one recursive call at each

level of recursion• Each call goes down to a sub-tree with universe

defined by w/2 bits (then w/4 bits,

w/8 bits, etc)

• Therefore, intuitively canunroll into lg lg u steps

L[0] L[1] L[ -1]. . .

H w/2 bits

w/2 bits

sub-trees

Page 20: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 20

Pipeline Structure

stage 1

op1 arg1

stage 2

op2 arg2

stage 3

op3 arg3

op4 arg4

input

: :

M1 = pointers to all subtrees of width w/2

output

min n

H L0 L1…

min n

H L0 L1…

min n

H L0 L1…

min n

H L0 L1…

stage 4

M2 = pointers to all subtrees of width w/4

M3 = pointers to all subtrees of width w/8

M4 = pointers to all subtrees of width w/16

Page 21: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 21

Main Issues

• Want to initiate new operation at every pipeline cycle(e.g. initiate an INSERT or EXTRACTMIN)

• Even if throughput is O(1),• Don’t want to wait lg lg u pipeline cycles to retrieve

data (e.g. want data in same pipeline cycle for EXTRACTMIN)

• But previous INSERT and EXTRACTMIN operation(s) may still be in pipeline

• Two pipeline stages may need to access same data• Need to resolve memory access orders

Page 22: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 22

Basic Idea• Operations proceed

from top to bottom

• min[S] for the vEB tree rooted at that level is updated immediately as operations flow thru pipeline

• e.g. INSERT at Stage 1 will update min[S] immediately so next EXTRACTMIN at Stage 1 will retrieve correct min[S]

stage 1

op1 arg1

stage 2

op2 arg2

stage 3

op3 arg3

op4 arg4

input

: :

output

min n

H L0 L1…

min n

H L0 L1…

min n

H L0 L1…

min n

H L0 L1…

stage 4

Page 23: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 23

Other Operations• In addition to INSERT and EXTRACTMIN, paper describes

• SUCCESSOR( x, S ) – Returns next element in S larger

than x in the universe U

• Can also define in a similar pipeline fashion

• PREDECESSOR( x, S ) – Returns next element in S smaller than x in the universe U

• EXTRACTMAX( S ) – Removes item with largest key

• To facilitate these operations, we also• Store max[S] for corresponding S at each pipeline stage• Provide another pipeline memory structure for tracking

“in-flight” SUCCESSOR and PREDECESSOR operations

Page 24: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

IEEE Infocom 2007 24

Conclusions

• Pipelined van Emde Boas trees can achieve O(1) operations with O(lg lg u) pipelined stages

• Same O(1) time complexity as pipelined heaps, but exponentially fewer pipeline stages than O(lg n) required for pipelined heaps when u is a polynomial of n

• Can simultaneously support EXTRACTMIN and EXTRACTMAX, which is harder to do with heaps

• Can support other operations like SUCCESSOR and PREDECESSOR, which have potential application to various network problem instances

Page 25: Pipelined van Emde Boas Tree: Algorithms, Analysis, and Applications Hao Wang and Bill Lin University of California, San Diego.

Thank You