




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































III Mesh-Type Architectures
9.1 Mesh-Connected Computers
Fig. 9.1 Two-dimensional mesh-connected computer.
2D, four-neighbor (NEWS) mesh; other types in Chapter 12
Square p 1/2^ × p 1/2^ or rectangular r × p / r
MIMD, SPMD, SIMD, Weak SIMD
Single/All-port model
Diameter-based or bisection-based lower bound: O( p 1/2^ ) Row wrap-around link for torus
Input/output via boundary processors?
Column wraparound link for torus
Row wraparound link for torus
Some communication modes.
a. MIMD all-port b. MIMD Single-port
c. SIMD single-port d. Weak SIMD
All-port: Processor can communicate with all its neighbors at once (in one cycle or time step)
Single-port: Processor can send/receive one message per time step
MIMD: Processors choose their communication directions independently
SIMD: All processors directed to do the same
Weak SIMD: Same direction for all (uniaxis)
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
a. Row-major
0 1 2 3
7 6 5 4
8 9 10 11
15 14 13 12
b. Snakelike row-major
0 1 4 5
2 3 6 7
8 9 12 13
10 11 14 15
c. Shuffled row-major
1 2 5 6
0 3 4 7
15 12 11 8
14 13 10 9
d. Proximity order
**--- --- | | | |
| | | | -- --**
Fig. 9.3 Some linear indexing schemes for the processors in a 2D mesh.
Our focus will be on row-major and snakelike row-major indexing
Fig. 9.6 A pair of dirty rows create at least one clean row in each shearsort iteration
Assume that in doing the column sorts, we first sort pairs of elements in the column and then sort the entire column
0 0 0 1 1 1 1 1 0 0
0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0
0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1
0 0 1 1 1 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
Row 2i Row 2i + 1
Case (a): More 0s
Case (b): More 1s
Case (c): Equal # 0s & 1s
⇒
⇒
⇒
Bubbles up in the next column sort
Sinks down in the next column sort
Fig. 9.7 The number of dirty rows halves with each shearsort iteration.
Dirty x^ dirty Dirty rows
At most x/ dirty rows
After log 2 r iterations, only one dirty row remains
00111010011010110
9.3 Variants of Simple Shearsort
Observation: On a linear array, odd-even transposition sort needs only k steps if the “dirty” (unsorted) part of the array is of length k
0 0 0 0 0 0 1 1 0 1 0 0 0 1 0 1 1 1 1 1 1 Unsorted part
Dirty xrows^ dirty Dirty At most x/ dirty rows
0
1
0
1
⇒
In shearsort, we do not have to sort columns completely, because only a portion of the column is unsorted (the portion shrinks in each phase)
On a square mesh: T opt shearsort = p 1/2^ (½ log 2 p + 3) – 2
T opt shearsort = ( p / r )(log 2 r + 1) + r + r /2 +... + 2 2 r – 2
Thus, 2 r – 2 replaces r log 2 r in simple shearsort
Fig. 9.9 Example of shearsort on a 4 × 4 mesh with two keys stored per processor.
Perform ordinary shearsort, but replace compare-exchange with merge-split ( n / p ) log 2 ( n / p ) steps for the initial sort; the rest multiplied by n / p
1 12 21 4 15 20 13 2 5 9 18 7 22 3 14 17
1 6 12 25 31 20 15 2 5 8 11 19 28 23 17 3
Keys
Row sort
1 6 11 2 5 9 15 13 28 20 17 19 31 24 21 26
The final row sort (snake-like or row-major) is not s hown.
6 26 25 10 31 32 16 30 11 19 27 8 28 23 29 24
4 10 21 26 32 30 16 13 7 9 18 27 29 24 22 14
4 8 12 3 7 10 16 14 29 23 18 25 32 30 22 27 1 3 6 11 15 13 9 5 17 19 23 28 31 27 24 21
2 4 8 12 16 14 10 7 18 20 25 29 32 30 26 22
1 3 6 5 15 13 9 11 17 19 23 21 31 27 25 28
2 4 8 7 16 14 10 12 18 20 24 22 32 30 26 29
Row sort
Column sort
Column sort
x y
Two keys held by one processor
Fig. 9. The proof of the first recursive sorting algorithm for 2D meshes.
x + x' ≥ b + c + ( a – b )/2 + ( d – c )/2 + a' + d' + ( b' – a' )/2 + ( c' – d' )/2 ≥ b + c + a' + d' + ( a – b )/2 + ( d – c )/2 + ( b' – a' )/2 + ( c' – d' )/2 – 4×½ = ( a + a' )/2 + ( b + b' )/2 + ( c + c' )/2 + ( d + d' )/2 – 2 ≥ p 1/2^ – 4
x ≥ b + c + ( a – b )/2 + ( d – c )/2 A similar inequality applies to x'
0
1
Dirty
x rows
x' rows
0
0
(^00)
1 1
(^11)
a
a'
b
b'
c
c'
d
d' Numbers of clean rows in each of the four quadrants
p – x – x' rows
State of the array after Phase 3
Let b (a power of 2) be the block length for snakelike sorting
...
. ..
.. .
snakelike-mesh-sort( b ) snakelike-mesh-sort( b /2) snakelike-row-sort( b ) column-sort( b ) snake-odd-even-xpose(4 b )
R 1 R^2
R 3 R^4
R (^5)
R (^5)
R (^5)
R 5
R 5 R^2
R 3 R^4
R 1
R (^5)
R (^5)
R 6 R 6 R 7
R 7
R (^8)
R (^8)
Fig. 9.
Fig. 9.
snakelike-row-sort( b ) for k = 0 to b – 1 Proc ( i , j ), j even, do case i , k even, even: if j ≠ 0 mod b AND (R5) < (R3) then R5 ↔ R even, odd: if (R2) < (R5) then R2 ↔ R
...
Fig. 9.13 The proof of the second recursive sorting algorithm for 2D meshes.
0
0 0
(^00)
1 1
(^11)
a b
c d
Numbers of clean 0 rows in the four quadrants
... ...
Numbers of 0s in two different double-columns differ by Š 2
a b
c (^) d
... ...
Š 2¦p elements
0 0 0 0 0 0
0 0 0 0 0
0 0 0
1 1 1
≤ 2 √ p elements
Numbers of 0s in two different double-columns differ by ≤ 2
Numbers of clean 0 rows in the four quadrants
Upper bounds: Deriving/analyzing algorithms and proving them correct
Lower bounds: Theoretical arguments based on bisection width, and the like
p 1/2^ log 2 p Shearsort
2 p 1/2 9 p 1/2 11 p 1/ Diameter
3 p 1/ For snakelike order only (proved next)
Problem
Schnorr/Shamir algorithm