




























































































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!





























































































Fall 2008
Parallel Processing, Extreme Models
Slide 1
Fall 2008
Parallel Processing, Extreme Models
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, 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
Fall 2008
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
Fall 2008
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:
Fall 2008
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
Fall 2008
Parallel Processing, Extreme Models
Slide 10
i + j =
j
⎡ n^ /
p ⎤ segments
p elements
Fall 2008
Parallel Processing, Extreme Models
Slide 11
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
Fall 2008
Parallel Processing, Extreme Models
Slide 13
Each person write down an arbitrary nonnegativeinteger with 3 or fewer digits on a piece of paper Students take turn broadcasting their numbers bycalling them out aloud Each student puts an X on paper for every numbercalled out that is smaller than his/her own number, or isequal but was called out before the student’s own value
j
Each student counts the number of Xs on paper to determinethe rank of his/her number
p^ – 1
0
Students call out their numbers in order of the computed rank
Fall 2008
Parallel Processing, Extreme Models
Slide 14
5.3 Semigroup or Fan-in Computation
EREW PRAM semigroup computation algorithm Proc
j , 0
≤^ j
<^ p
, copy
X
[ j ] into
S
[ j ]
s^ := 1while
s^ <^ p
Proc
j , 0
≤^ j
<^ p
-^ s
, do
S [
j^ +
s ] :=
S
[ j ]^
⊗^
S [
j^ +
s ]
s^ := 2
s
endwhileBroadcast
S
[ p^
processors^ If we use
p^
processors on a list
of size
n^
= O(
p^ log
p ), then optimal
This algorithm is optimal for PRAM,but its speedup of O(speedup can be achieved
p^ / log
p ) is not
Fig. 5.
Semigroup computation
in EREW PRAM. 0 1 2 3 4 5 6 7 8 9
S^ 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:
Fig. 5.
Intuitive justification of why parallel slack helps improve the efficiency.
Higher degre
e
of parallelis
m
near the leav
e
Lower degreeof parallelis
m
near the root
Fall 2008
Parallel Processing, Extreme Models
Slide 16
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
Each verticalline representsa location inshared memory
Fall 2008
Parallel Processing, Extreme Models
Slide 17
Fig. 5.8 Another divide-and-conquer scheme for parallel prefix computation.
Strictly optimalalgorithm, butrequirescommutativity
x^0
x 1
x^2
x 3
x^ n
x^ n -
0:
0:
0:
0:
0: n
-2 0:
n -
Parallel prefixcomput ation on
n /
Parallel prefixcomput ation on odd-indexed inputs
n /
even-index ed inputs ⊗ ⊗ ⊗ ⊗ ⊗ ⊗^
⊗ ⊗ ⊗ ⊗
T (
p ) =
T ( p /2) + 1
T (
p ) = log
p 2
Each verticalline representsa location inshared memory
Fall 2008
Parallel Processing, Extreme Models
Slide 19
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
Fall 2008
Parallel Processing, Extreme Models
Slide 20
Question: Which PRAMsubmodel is implicit inthis algorithm?
If we do notwant to modifythe original list,we simply makea copy of it first,in constant time
A B C D E F
(^435310)
info
next
rank
0 1 2 3 4 5
head
PRAM list ranking algorithm (via pointer jumping) Processor
j , 0
≤^ j
<^ p
, do {initialize the partial ranks}
if^ next
[^ j ] =
j
then
rank
[^ j^
] := 0
else
rank
[^ j^
] := 1
endifwhile
rank
[ next
[ head
]]^ ≠
0 Processor
j , 0
≤^
j^ <
p , do
rank
[^ j^
] :=
rank
[^ j^
] +
rank
[ next
[^ j ]]
next
[^ j ] :=
next
[ next
[^ j ]]
endwhile^ Answer: CREW