Docsity

Parallel Matrix-Vector Multiplication using MPI: Communication and Computation Steps, Slides of Parallel Computing and Programming

Partial preview of the text

Download Parallel Matrix-Vector Multiplication using MPI: Communication and Computation Steps and more Slides Parallel Computing and Programming in PDF only on Docsity!

Quiz # 05

Total Marks 10

Time 10 minutes

On a MPI machine, using 1-D row-wise partitioning ,Multiply a m x n matrix with n x 1 vector using pprocessors where m> p and m mod p= 0a) List the main communication and computation

steps in correct order along with time complexityof each step.

b) Hence give the total time complexity of all above

steps.

Parallel Matrix_Vector Multiplication:

Data Decomposition/Partitoning Approaches

•^

Parallel Matrix-Vector Multiplication– 1_D partitioning

-^

p = n

-^

p < n

– 2_D partitioning

-^

p = n

-^

p < n

Matrix-Vector Multiplication:

Rowwise 1-D Partitioning

•^

Since each process starts with only one element of

x

an all-to-all broadcast is required to distribute all theelements to all the processes.

-^

Process

P

i^

now computes

•^

The all-to-all broadcast and the computation of

y [

i ]

both

take time

(n)

. Therefore, the parallel time is

(n)

Columnwise 1-D partition working & its time complexity?2-D partitioned working & its time complexity??Consider both Computation & Communication times.

Advanced MPI-Routines

-^

Send and Receive Operations

-^

Collective Communication operations

-^

Topologies and Embedding

-^

Groups & Communication domain split

Sending and Receiving Messages Simultaneously^ To exchange messages, MPI provides the followingfunction:^ int MPI_Sendrecv(void *sendbuf, intsendcount,MPI_Datatype senddatatype,int dest,int sendtag,void *recvbuf, int recvcount,MPI_Datatype recvdatatype, int source, intrecvtag,

MPI_Comm comm, MPI_Status *status)

The arguments include arguments to the send andreceive functions. If we wish to use the same buffer forboth send and receive, we can use: int MPI_Sendrecv_replace(void *buf,int count,MPI_Datatype datatype, int dest, int sendtag,int source, int recvtag, MPI_Comm comm,

MPI_Status *status)

Collective Communication and

Computation Operations

-^

MPI provides an extensive set of functionsfor performing common collectivecommunication operations.

-^

Each of these operations is defined over agroup corresponding to the communicator.

-^

All processors in a communicator must callthese operations.

Predefined Reduction Operations

Operation

Meaning

Datatypes

MPI_MAX

Maximum

C integers and floating point

MPI_MIN

Minimum

C integers and floating point

MPI_SUM

Sum

C integers and floating point

MPI_PROD

Product

C integers and floating point

MPI_LAND

Logical AND

C integers

MPI_BAND

Bit-wise AND

C integers and byte

MPI_LOR

Logical OR

C integers

MPI_BOR

Bit-wise OR

C integers and byte

MPI_LXOR

Logical XOR

C integers

MPI_BXOR

Bit-wise XOR

C integers and byte

MPI_MAXLOC

max-min value-location

Data-pairs

MPI_MINLOC

min-min value-location

Data-pairs

Collective Communication Operations

-^

If the result of the reduction operation is needed byall processes, MPI provides:

int MPI_Allreduce(void sendbuf, voidrecvbuf, int count, MPI_Datatypedatatype, MPI_Op op, MPI_Comm comm)

•^

To compute prefix-sums, MPI provides:

int MPI_Scan(void sendbuf, voidrecvbuf, int count, MPI_Datatypedatatype, MPI_Op op, MPI_Comm comm)

Collective Communication Operations

-^

The all-to-all personalized communication operationis performed by:

int MPI_Alltoall(void *sendbuf, intsendcount, MPI_Datatype senddatatype,void *recvbuf,int recvcount,MPI_Datatype recvdatatype,MPI_Comm comm)

•^

Using this core set of collective operations, anumber of programs can be greatly simplified.