Docsity

Low-Diameter Architectures: Hypercubes and Their Algorithms, Study notes of Psychology

Partial preview of the text

Download Low-Diameter Architectures: Hypercubes and Their Algorithms and more Study notes Psychology in PDF only on Docsity!

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 1

Part IV

Low-Diameter Architectures

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 2

About This Presentation

Edition

Released

Revised

Revised

First

Spring 2005

Spring 2006

Fall 2008

This presentation is intended to support the use of the textbook Introduction to Parallel Processing: Algorithms and Architectures (Plenum Press, 1999, ISBN 0-306-45970-1). It was prepared bythe author in connection with teaching the graduate-level courseECE 254B: Advanced Computer Architecture: Parallel Processing,at the University of California, Santa Barbara. Instructors can usethese slides in classroom teaching and for other educationalpurposes. Any other use is strictly prohibited. © Behrooz Parhami

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 4

13 Hypercubes and Their Algorithms

Study the hypercube and its topological/algorithmic properties:

  • Develop simple hypercube algorithms (more in Ch. 14)• Learn about embeddings and their usefulness

Topics in This Chapter 13.

Definition and Main Properties

Embeddings and Their Usefulness

Embedding of Arrays and Trees

A Few Simple Algorithms

Matrix Multiplication

Inverting a Lower-Triangular Matrix

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 5

13.1 Definition and Main Properties

P^1

P^2 P^3

P^4

P^5

P^6 P^7

P^8

P^0

P^

P^

P

P^

P^

P

P^

P^

P

0

1

2

3

4

5

6

7

8

Intermediatearchitectures:logarithmic orsublogarithmic

diameter

Begin studying networks that are intermediate betweendiameter-1 complete network and diameter-

p 1/

mesh

Completenetwork

n /

log

n

log

n

/ log log

n

n^

−^

1

1

n

2 Sublogarithmic diameter

Superlogarithmic diameter

PDN

Star, pancake

Binary tree,hypercube

Torus

Ring

Lineararray

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 7

Basic Definitions Hypercube is generic term;3-cube, 4-cube,... ,

q

-cube

in specific cases

0

1

00

01

10

11

(a) Binary 1-cube,built of twobinary 0-cubes,labeled 0 and 1

(b) Binary 2-cube,built of twobinary 1-cubes,labeled 0 and 1

0 1

(c) Binary 3-cube, built of two binary 2-cubes, labeled 0 and 1

0

000

001

010

011

100

101

110

111

1

000

001

010

011

100

101

110

111

(d) Binary 4-cube, built of two binary 3-cubes, labeled 0 and 1

0

1

0000

0001

0010

0011

0100

0101

0110

0111

1000

1001

1010

1011

1100

1101

1110

1111

Fig. 13.1The recursivestructure ofbinaryhypercubes. Parameters: p

q

B

p

q –

D

q

= log

p 2

d

q

= log

p 2

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 8

The 64-NodeHypercube^ Only samplewraparoundlinks areshown toavoid clutter^ Isomorphic tothe 4

×

×

3D torus(each has 64

×

6/2 links)

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 10

13.2 Embeddings and Their Usefulness

Fig. 13.2Embedding aseven-nodebinary treeinto 2Dmeshes ofvarious sizes.

0

2

4

3

1

6

5

0

2

4

1 3

6

5

0,

2

3 4

6

5 6

0

1

3,

2,

a^

b

c^

d^

e^

f

a^

b

c

d

e

f

a^

b

c d

e f

b

f

c, d

Dilation = 1Congestion = 1Load factor = 1

Dilation = 2Congestion = 2Load factor = 1

Dilation = 1Congestion = 2Load factor = 2

Dilation:

Longest path onto which an edge is mapped (routing slowdown)

Congestion:

Max number of edges mapped onto one edge (contention slowdown)

Load factor:

Max number of nodes mapped onto one node (processing slowdown)

Expansion: ratio of thenumber ofnodes (9/7, 8/7,and 4/7 here)

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 11

13.3 Embedding of Arrays and Trees

Alternate inductive proof: Hamiltonicity of the

q

-cube

is equivalent to the existence of a

q

-bit Gray code

Fig. 13.

Hamiltonian cycle in the

q

-cube.

(q – 1)-cube 0

x

(q – 1)-cube 1

N (x)

k

N

(x) q– N

(N (x)) q–

k

( q

  • 1)-bit Gray code 000... 000000... 001000... 011

000... 011000... 010000... 000^ ( q

  • 1)-bit Gray codein reverse

Basis:

q

-bit Gray code beginning with the all-0s codeword

and ending with 10

q –

exists for

q

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 13

Torus is a Subgraph of Same-Size Hypercube

A tool used in our proof Product graph

G

1

×

G

Has

n

1

×

n

2

nodes

Each node is labeled by apair of labels, one from eachcomponent graphTwo nodes are connected ifeither component of the twonodes were connected in thecomponent graphs

Fig. 13.

Examples of product graphs.

The 2

a^

×

b^

×

c^

... torus is the product of 2

a -, 2

b -, 2

c -,... node rings

The (

a

b

c

  • ... )-cube is the product of

a

-cube,

b

-cube,

c

-cube,...

The 2

q -node ring is a subgraph of the

q

-cube

If a set of component graphs are subgraphs of another set, the productgraphs will have the same relationship

×^

=

3-by-2torus

×^

×^

=

×^

=

0 1

2

a

b

0a 1a

2a

0b

1b

2b

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 14

Embedding Trees in the Hypercube

The (

q^

  • 1)-node complete binary tree

is not a subgraph of the

q

-cube

even we

igh

t

odd weights

even weights

odd wei

ght

s

even weights

Proof by contradiction based on the parity ofnode label weights (number of 1s is the labels)^ The

q -node

double-rooted

complete

binary tree is a subgraph of the

q

-cube

Fig. 13.6The 2

q -node

double-rootedcompletebinary tree isa subgraph ofthe

q

-cube.

New Roots x^

N

(N (x)) N (N (x))

q 2 -node double-rootedcomplete binary tree

Double-rooted treein the (q–1)-cube 0

N (x) Double-rooted treein the (q–1)-cube 1 c

N (x)b

N (x) a

b^

c b c

N (N (x))N (N (x)) c^

a c a

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 16

13.4 A Few Simple Algorithms

Fig. 13.

Semigroup computation on a 3-cube.

Semigroup computation on the

q

-cube

Processor

x

x

p

do

t [ x

] :=

v

[ x

]

{initialize “total” to own value} for

k

= 0 to

q

  • 1 processor

x

x

p

, do

get

y

t [N

( k x )]

set

t [ x

] :=

t [ x

]^

y

endfor

0 2

1 3 4 6

5 7

0-1 2-

0-1 2-

4-5 6-

4-5 6-

0-3 0-

0-3 0- 4-7 4-

4-7 4-

0-7 0-

0-7 0- 0-7 0-

0- 0-

Commutativityof the operator

is implicit here.How can weremove thisassumption?

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 17

Parallel Prefix Computation

Fig. 13.

Semigroup computation on a 3-cube.

Commutativityof the operator

is implicit in thisalgorithm as well.How can weremove thisassumption?

t^ : subcube “total” u : subcube prefix

0 2

1 3

4

6

5

7

0-1 2-

0-1 2-

4-5 6-

4-5 6-

0-3 0-

0-3 0- 4-7 4-

4-7 4-

4

4-

0

0- 6

6-

2

2-

t: Subcube "total" u: Subcube prefix

4

(^0) 0-

4-

0-1 0-

4- 4-

0-

0

0-

0-

0-

0-

0-

0-

All "totals" 0-

Legend

t u

Parallel prefix computation on the

q

-cube

Processor

x

x

p

, do

t [ x

] :=

u

[ x

] :=

v

[ x

]

{initialize subcube “total” and partial prefix} for

k

= 0 to

q

  • 1 processor

x

x

p

, do

get

y

t [N

( k x )]

set

t [ x

] :=

t [ x

]^

y

if^

x^

> N

( k x ) then set

u

[ x

] :=

y

u

[ x

]

endfor

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 19

Ascend, Descend, and Normal

Algorithms

Graphical depiction of ascend, descend,and normal algorithms. HypercubeDimensionq–

3 2 1 0

Algorithm Steps

0

1

2

3

... ...

Ascend Descend Normal

0 2

1 3 4 6

5 7

0-1 2-

0-1 2- 4-5 6-

4-5 6-

0-3 0-

0-3 0- 4-7 4-

4-7 4-

4

4-

0

0- 6

6-

2

2-

t: Subcube "total" u: Subcube prefix

4 (^0) 0-

4-

0-1 0-

4- 4-

0- 0

0-

0-

0-

0-^

0- 0- All "totals" 0-

Legend

t u^

Parallelprefix

000

001

010

011 100

101

110

111

000

001

010

011

101

110

111

000

001

010

011 100

101

110

111

000

001

010

011 100

101

110

111

100

a

b

c

d

e

f

g

h

a^

b

c^

d

e^

f

g^

h

g h

e

f

c

d

a

b

c

d

a

b

g

h

e

f

Semigroup^ Sequencereversal

0 2

1 3 4 6

5 7

0-1 2-

0-1 2- 4-5 6-

4-5 6-

0-3 0-

0-3 0- 4-7 4-

4-7 4-

0-7 0-

0-7 0-7 0-7 0-

0-7 0-

Dimension-ordercommunication

Fall 2008

Parallel Processing, Low-Diameter Architectures

Slide 20

13.5 Matrix Multiplication^ Fig. 13.

Multiplying two 2

×

2 matrices on a 3-cube.

0 2

1 3

4 6

5 7

1 5

2 6

3 7

4 8

1

2 3

4

5

6 7

8

×^

[^

]

[^

] 000

001

010

011

100

101

110

111

1 5

2 6

3 7

4 8

1 5

2 6

3 7

4 8

1 5

1 6

3 7

3 8

2 5

2 6

4 7

4 8

1 5

1 6

3 5

3 6

2 7

2 8

4 7

4 8

14

16

(^515)

28

6

32

18

19

22

43

50

RARB

RARB

R^ RARB C

RARB

R^

:= R

R

C^

A^

B ×

  1. Place elementsof

A

and

B

in

registers R

A^

& R

B

of

m

2

processors

with the IDs 0

jk

  1. Replicate inputs: communicateacross 1/3 of the dimensions

3, 4. Rearrangethe data bycommunicatingacross theremaining 2/3 ofdimensions sothat processor

ijk

has

A

ji^ and

B

ik

  1. Move

C

jk^

to

processor 0

jk

p^

= m

3 = 2

q^

processors, indexed as

ijk

(with three

q

/3-bit segments)