


















































































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!



















































































Spring 2006
Parallel Processing, Extreme Models
Slide 1
Spring 2006
Parallel Processing, Extreme Models
Slide 2
About This Presentation
Edition
Released
Revised
Revised
First
Spring 2005
Spring 2006
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
Spring 2006
Parallel Processing, Extreme Models
Slide 4
5 PRAM and Basic Algorithms
PRAM Submodels and Assumptions
Data Broadcasting
Semigroup or Fan-in Computation
Parallel Prefix Computation
Ranking the Elements of a Linked List
Matrix Multiplication
Spring 2006
Parallel Processing, Extreme Models
Slide 5
5.1 PRAM Submodels and Assumptions Fig. 4.
Conceptual view of a parallel
random-access machine (PRAM).
Processor
i^ can do
the following in threephases of one cycle:1.^
Fetch a valuefrom address
s^ i
in sharedmemory
2.^
Performcomputations ondata held in localregisters
3.^
Store a valueinto address
di
in
shared memory
Spring 2006
Parallel Processing, Extreme Models
Slide 7
Undefined:
The value written is undefined (CRCW-U)
Detecting:
A special code for “detected collision” is written (CRCW-D)
Common:
Allowed only if they all store the same value (CRCW-C) [ This is sometimes called the consistent-write submodel ]
Random:
The value is randomly chosen from those offered (CRCW-R)
Priority:
The processor with the lowest index succeeds (CRCW-P)
Max / Min:
The largest / smallest of the values is written (CRCW-M)
Reduction:
The arithmetic sum (CRCW-S), logical AND (CRCW-A), logical XOR (CRCW-X), or another combination of values is written
CRCW submodels are distinguished by the way they treat multiple writes:
Spring 2006
Parallel Processing, Extreme Models
Slide 8
Theorem 5.1:
A
p -processor CRCW-P (priority) PRAM can be simulated
(emulated) by a
p -processor EREW PRAM with slowdown factor
Θ
(log
p ).
Intuitive justification for concurrent read emulation (write is similar):
Write the
p^
memory addresses in a list
Sort the list of addresses in ascending order Remove all duplicate addresses Access data at desired addresses Replicate data via parallel prefix computation
Each of these steps requires constant or O(log
p ) time
Model U is more powerful than model V if
T U
( n ) = o(
T V
( n )) for some problem
EREW < CREW < CRCW-D
< CRCW-C < CRCW-R < CRCW-P
1 6 5 2 3 6 1 1 2
1 1 1 2 2 3 5 6 6
1 2 3 5 6
Spring 2006
Parallel Processing, Extreme Models
Slide 10
5.2 Data Broadcasting
Fig. 5.
Data broadcasting in EREW PRAM
via recursive doubling.
(^01234567891011)
B Fig. 5.
EREW PRAM data broadcasting
0 1 2 3 4 5 6 7 8 9 1011 without redundant copying.
B
Can modify the algorithmso that redundant copyingdoes not occur and arraybound is not exceeded
Spring 2006
Parallel Processing, Extreme Models
Slide 11
EREW PRAM algorithm for all-to-all broadcasting Processor
j , 0
≤^
j^ <
p , write own data value into
B [ j ]
for
k^
= 1 to
p^
j , 0
≤^
j^ <
p , do
Read the data value in
B
[( j^
+^ k
) mod
p ]
endfor This O(
p )-step algorithm is time-optimal
Naive EREW PRAM sorting algorithm (using all-to-all broadcasting) Processor
j , 0
≤^
j^ <
p , write 0 into
R
[^ j^
]
for
k^
= 1 to
p^
j , 0
≤^
j^ <
p , do
l^ := (
j^ +
k ) mod
p
if^ S
[^ l^
] <
S
[^ j^
] or
S
[^ l^
] =
S
[^ j^
] and
l^ <
j
then
R
[^ j^
] :=
R
[^ j^
] + 1
endif endfor Processor
j , 0
≤^
j^ <
p , write
S
[^ j^
] into
S
[ R
[^ j^
]]
j
This O(
p )-step sorting
algorithm is far fromoptimal; sorting is possiblein O(log
p ) time
p^ – 1
0
Spring 2006
Parallel Processing, Extreme Models
Slide 13
5.4 Parallel Prefix Computation Fig. 5.
Parallel prefix computation in EREW PRAM
via recursive doubling.
0 1 2 3 4 5 6 7 8 9
0:01:12:23:34:45:56:67:78:89:
0:00:11:22:33:44:55:66:77:88:
0:00:10:20:31:42:53:64:75:86:
0:00:10:20:30:40:50:60:71:82:
0:00:10:20:30:40:50:60:70:80:
Same as the first part of semigroup computation (no final broadcasting)
Spring 2006
Parallel Processing, Extreme Models
Slide 14
Fig. 5.
Parallel prefix computation using a divide-and-conquer scheme. ⊗^
⊗^
⊗^
⊗
⊗
⊗^
⊗^
⊗^
⊗
x^0
x 1
x^2
x 3
x^ n
x^ n
0:
0:
0:
0:
0: n
-2 0:
n -
T ( In hardware,this is the basisfor Brent-Kungcarry-lookaheadadder
p ) =
T ( p /2) + 2
T (
p ) ≅^
2 log
p 2
Spring 2006
Parallel Processing, Extreme Models
Slide 16
5.5 Ranking the Elements of a Linked List^ C
F^
A^
E^
B^
D
Rank:
5
4
3
2
1
0
info next head
Terminal element
(or distance from terminal)Distance from head:
1
2
3
4
5
6
Fig. 5.
Example linked list and the ranks of its elements.
Fig. 5.
PRAM data structures
representing a linked list and theranking results.
A B C D E F
(^435310)
info
next
rank
0 1 2 3 4 5
head
List ranking appears to behopelessly sequential;one cannot get to a listelement except throughits predecessor!
Spring 2006
Parallel Processing, Extreme Models
Slide 17
Fig. 5.
Element ranks initially and after each of the three iterations.
Many problemsthat appear to beunparallelizableto the uninitiatedare parallelizable;Intuition can bequite misleading!
1
1
1
1
1
0
2
2
2
2
1
0
4
4
3
2
1
0
5
4
3
2
1
0
A B C D E F
(^435310) info
next
0 1 2 3 4 5 head
Spring 2006
Parallel Processing, Extreme Models
Slide 19
×
i
j
ij
k =0 to
m
kj
PRAM solution with^3 m
processors: each processor doesone multiplication(not very efficient)
m^
×^ m matrices
Spring 2006
Parallel Processing, Extreme Models
Slide 20
2
Fig. 5.
PRAM matrix multiplication;
p^
=^ m
2 processors.
Θ(
m ) steps: Time-optimal CREW model is implicit Processors are numbered (
i ,^ j
),
instead of 0 to
m
2 – 1