Docsity

Low-Diameter Architectures - Parallel Processing - Lecture Slides, Slides of Parallel Computing and Programming

Partial preview of the text

Download Low-Diameter Architectures - Parallel Processing - Lecture Slides and more Slides Parallel Computing and Programming in PDF only on Docsity!

Part IV

Low-Diameter Architectures

IV Low-Diameter Architectures

Study the hypercube and related interconnection schemes:

  • Prime example of low-diameter (logarithmic) networks
  • Theoretical properties, realizability, and scalability
  • Complete our view of the “sea of interconnection nets”

Topics in This Part

Chapter 13 Hypercubes and Their Algorithms

Chapter 14 Sorting and Routing on Hypercubes

Chapter 15 Other Hypercubic Architectures

Chapter 16 A Sampler of Other Networks

13.1 Definition and Main Properties

P 1

P 2

P 3

P 5 P 4

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

Intermediate architectures: logarithmic or sublogarithmic diameter

Begin studying networks that are intermediate between diameter-1 complete network and diameter- p 1/2^ mesh

Complete network

1 2 log n / log log n log n n n /2 n − 1

Sublogarithmic diameter Superlogarithmic diameter

PDN Star, pancake

Binary tree, hypercube

Torus Ring Linear array

Hypercube and Its History

Binary tree has logarithmic diameter, but small bisection Hypercube has a much larger bisection Hypercube is a mesh with the maximum possible number of dimensions 2 × 2 × 2 ×... × 2 ← q = log 2 p → We saw that increasing the number of dimensions made it harder to design and visualize algorithms for the mesh Oddly, at the extreme of log 2 p dimensions, things become simple again!

Brief history of the hypercube (binary q -cube) architecture Concept developed: early 1960s [Squi63] Direct (single-stage) and indirect (multistage) versions: mid 1970s Initial proposals [Peas77], [Sull77] included no hardware Caltech’s 64-node Cosmic Cube: early 1980s [Seit85] Introduced an elegant solution to routing (wormhole switching) Several commercial machines: mid to late 1980s Intel PSC (personal supercomputer), CM-2, nCUBE (Section 22.3)

Only sample wraparound links are shown to avoid clutter

The 64-Node

Hypercube

Isomorphic to the 4 × 4 × 4 3D torus (each has 64 × 6/2 links)

Neighbors of a Node in a Hypercube

x (^) q –1 x (^) q –2... x 2 x 1 x 0 ID of node x

x (^) q –1 x (^) q –2... x 2 x 1 x 0 ′ dimension-0 neighbor; N 0 ( x ) x (^) q –1 x (^) q –2... x 2 x 1 ′ x 0 dimension-1 neighbor; N 1 ( x )

.. .. .. x (^) q –1′ x (^) q –2... x 2 x 1 x 0 dimension-( q – 1) neighbor; N q –1 ( x )

The q neighbors of node x

Nodes whose labels differ in k bits (at Hamming distance k ) connected by shortest path of length k Both node- and edge-symmetric Strengths: symmetry, log diameter, and linear bisection width Weakness: poor scalability

Dim 0

Dim 1

Dim 2 Dim 3

1101 1111

0111

0011

x

1011 0010

1010

x

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.3 Hamiltonian cycle in the q -cube.

(q – 1)-cube 0

x

(q – 1)-cube 1

N (x)k

N (^) q–1(x)

N (^) q–1(N (x)) (^) k

( q – 1)-bit Gray code 000... 000 000... 001 000... 011 . . . 100... 000

( q – 1)-bit Gray code in reverse

Basis: q -bit Gray code beginning with the all-0s codeword and ending with 10 q –1^ exists for q = 2: 00, 01, 11, 10

Mesh/Torus Embedding in a Hypercube

Is a mesh or torus a subgraph of the hypercube of the same size?

Dim 0

Dim 1

Dim 2 Dim 3

Column 0

Column 1

Column 2

Column 3

Fig. 13.5 The 4 × 4 mesh/torus is a subgraph of the 4-cube.

We prove this to be the case for a torus (and thus for a mesh)

Embedding Trees in the Hypercube

The (2 q^ – 1)-node complete binary tree is not a subgraph of the q -cube

even weight odd weights even weights

odd weights

even weights

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

The 2 q -node double-rooted complete binary tree is a subgraph of the q -cube

Fig. 13. The 2 q -node double-rooted complete binary tree is a subgraph of the q -cube.

New Roots

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

2 -node double-rooted complete binary tree

q (^) Double-rooted tree in the (q–1)-cube 0

Double-rooted tree in the (q–1)-cube 1

N (x)c

N (x)b

N (x)a

b c c b

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

c a a c

A Useful Tree Embedding in the Hypercube

The (2 q^ – 1)-node complete binary tree can be embedded into the ( q – 1)-cube

Fig. 13.7 Embedding a 15-node complete binary tree into the 3-cube.

Processor 000

001

010

011

100

101

110

111

Dim- link

Dim- links

Dim- links

Despite the load factor of q , many tree algorithms entail no slowdown

Parallel Prefix Computation

Fig. 13.8 Semigroup computation on a 3-cube.

Commutativity of the operator ⊗ is implicit in this algorithm as well.

How can we remove this assumption?

t : subcube “total”

u : subcube prefix 0

2

1

3

4

6

5

7

0-

2-

0-

2-

4-

6-

4-

6-

0-

0-

0-

0-

4-

4-

4-

4-

(^4) 4-

0 0- (^6) 6-

2 2-

t: Subcube "total" u: Subcube prefix

4

0

0-

4-

0-

0-

4-

4-

0-

0 0-

0-

0-

0-6 (^) 0-

0-

All " totals" 0-

Legend (^) t

u

Parallel prefix computation on the q -cube Processor x , 0 ≤ x < p , do t [ x ] := u [ x ] := v [ x ] {initialize subcube “total” and partial prefix} for k = 0 to q – 1 processor x , 0 ≤ 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

Dim 0

Dim 1

Dim 2

Sequence Reversal on the Hypercube

Fig. 13.11 Sequence reversal on a 3-cube.

Reversing a sequence on the q -cube for k = 0 to q – 1 Processor x , 0 ≤ x < p , do get y := v [N k ( x )] set v [ x ] := y endfor

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 b a

d c

f e

h g

a b

c (^) d

e f

g

h

h g

f e

d c

b a

d c

b a

h g

f e

Dim 0

Dim 1

Dim 2

13.5 Matrix Multiplication

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

(^100 )

(^110 )

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 5

15

28

6 32

18

19 22

43 50

R RAB

R RAB R^ C

R RRAB RAB

R (^) C:= R A ×R B

  1. Place elements of A and B in registers R A & R B of m^2 processors with the IDs 0 jk

p = m^3 = 2 q^ processors, indexed as ijk (with three q /3-bit segments)

  1. Replicate inputs: communicate across 1/3 of the dimensions

3, 4. Rearrange the data by communicating across the remaining 2/3 of dimensions so that processor ijk has A (^) ji and Bik

  1. Move Cjk to processor 0 jk

Dim 0

Dim 1

Dim 2

Analysis of Matrix Multiplication

The algorithm involves communication steps in three loops, each with q / 3 iterations (in one of the 4 loops, 2 values are exchanged per iteration)

T mul ( m , m^3 ) =

O( q ) = O(log m )

0

2

1

3

4

6

5

7

1 (^526)

3 (^7 ) 1 2 3 4

5 6 [ (^) ] × [ 7 8 ]

000 001

(^010 )

(^100 )

(^110 )

1 5

2 6

3 (^748)

1 5 2 6

3 (^748)

1 5

1 6

3 (^738)

2 5 2 6

(^474) 8

1 5

1 6

3 5

3 6

2 7

2 8

4 (^748)

14 16 5

15

28

6 32 18

19 22

43 50

RRA B

RRA B R^ C

RRA RRAB B

R (^) C:= R A ×R B

Analysis in the case of block matrix multiplication ( m × m matrices): Matrices are partitioned into p 1/3^ × p 1/3^ blocks of size ( m / p 1/3^ ) × ( m / p 1/3^ ) Each communication step deals with m^2 / p 2/3^ block elements Each multiplication entails 2 m^3 / p arithmetic operations

T mul ( m , p ) = m^2 / p 2/3^ × O(log p ) + 2 m^3 / p Communication Computation

Dim 0

Dim 1

Dim 2