Docsity

Dense Matrix Algorithms-Parallel Computing-Lecture Slides, Slides of Parallel Computing and Programming

Partial preview of the text

Download Dense Matrix Algorithms-Parallel Computing-Lecture Slides and more Slides Parallel Computing and Programming in PDF only on Docsity!

Dr. Hanif Durad

Lecture Outline  Parallel Algorithms for  Matrix-Vector Multiplication  Matrix-Matrix Multiplication  Solving a System of Linear Equations  Performance Analysis

Introduction (1/2)  Due to their regular structure, parallelcomputations involving matrices and vectorsreadily lend themselves to data-decomposition.  Typical algorithms rely on input, output, orintermediate data decomposition.  Most algorithms use one- and two-dimensionalblock, cyclic, and block-cyclic partitions forparallel processing.

Dr. Hanif Durad

cz4102_le11.pdf

8.1 Matrix-Vector Multiplication(MVM)

^ We aim to multiply a dense

n^ x^ n^ matrix

A^ with an

n^ x^^1

vector^ x to yield the

n x 1^ result vector

y.

^ The serial algorithm requires

(^2) n multiplications and

additions.

Dr. Hanif Durad

^ The total workload is

Serial Work=Problem Size

cz4102_le11.pdf

8.1.1 MVM : Rowwise 1-DPartitioning (1/5)  The^ n^ x^ n^

matrix^ A

is partitioned among

n^ processors,

with each processor storing a complete row of the matrix.  The^ n^ x^

1 vector

x^ is distributed such that each process owns one of its elements.

cz4102_le11.pdf

MVM : Rowwise 1-D Partitioning(3/5)  Process^ P now computes i^

cz4102_le11.pdf

MVM : Rowwise 1-DPartitioning (4/5)  All-to-all broadcast:

Θ(p) =

Θ(n)^ time

^ each process must receive vector y, which is oflength n  Computation of

y[i]:^ Θ

(p)=^ Θ

(n ) time

^ each process performs dot product of length n  Overall algorithm:

Θ(p)=^

Θ(n)^ time

^ both communication and computation are

Θ(n)

Analysis for p = n

comp422-2010-Lecture23-DenseMatrix.pdf,P-

Recap: All-to-All Broadcast basedon Doubling-up Approach:All-to-all broadcast on an eight-node hypercube.

cz4102_le11.pdf

Recap: All-to-All Broadcastbased on Doubling-up Approach:  log n^ communication rounds  messages of size

(i-1)^ 2 m^ are exchanged in round

i

^ Now m = 1, and p = n , we have ^ T = t^ s

log n + t

x^ (n-1)w ≈^ t^ log n + ts^

x^ (n -1)w = O(n)

p^ n   T=^ p+ t p^ s

log p + t w Computationx^ (p -1)^ Communication

cz4102_le11.pdf

Recap: All-to-All Broadcastbased on Doubling-up Approach:

^ Now^

nm, we havep^ t^ log^

t^

(^ -1) t^ log^ s^ w t s^

n w T^

p^

p p p^

n ^

^ ^

 ^ 

p^ n   (^2) T= n/p. + t p log p + ts

x^ nw Computation Communication

comp422-2010-Lecture23-DenseMatrix.pdf, P-7 + cz4102_le11.pdf ^ Cost-optimal execution for

p = O(n)

^ 1st term dominates overhead terms

8.1.2 MVM: 2-D Partitioning( p = n

^ The^ n x n

matrix is partitioned among

(^2) n processors such

that each processor owns a single element.  The^ n^ x^

1 vector

x^ is distributed only in the last column of^ n^ processors.

cz4102_le11.pdf

MVM: 2-D Partitioning (p = n

Dr. Hanif Durad

cz4102_le11.pdf(3/6)

MVM: 2-D Partitioning (p = n

(4/6)  Three basic communication operations are usedin this algorithm:1. one-to-one communication to align the vectoralong the main diagonal

(O(1))

2.^ one-to-all broadcast of each vector elementamong the n processes of each column

(O(log

n)) , and3. all-to-one reduction in each row

(O(log n)).

Dr. Hanif Durad

cz4102_le11.pdf

MVM: 2-D Partitioning (p = n

Analysis (6/6)  These communications take

Θ(log n)

time.

^ Computation time is

O(1).

^ The parallel time (T

p of this algorithm is)^

=^ Θ(1)+

Θ(log n) =

Θ(log n)

^ The cost (process-time product) is

2 n x^ log n =

Θ(n2 log n) > n

; hence, the algorithm is not

cost-optimal.

Dr. Hanif Durad

8.1.2.2 MVM: 2-D Partitioning( p < n

^ When using fewer than

2 n processors, each

process owns an

block of the matrix.

^ The vector is distributed in portions ofelements in the last process-column only. ^ In this case, the message sizes for the alignment,broadcast, and reduction are all

^ The computation is a product of ansubmatrix with a vector of length

Dr. Hanif Durad