


















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!



















Combine Send & Receive Operations
-^
Collective Communication operations
-^
Topologies and Embedding
-^
Groups & Communication domain split
The basic functions for sending and receiving messages inMPI are
the MPI_Send
MPI_Recv
The calling sequences of these routines are as follows
**int MPI_Send (void *buf, int count, MPI_Datatypedatatype, int dest, int tag, MPI_Comm comm)int MPI_Recv (void *buf, int count, MPI_Datatypedatatype, int source, int tag,MPI_Comm comm,MPI_Status *status)**
-^
MPI provides equivalent datatypes for all C datatypes. This is done forportability reasons.The datatype MPI_BYTE corresponds to a byte (8 bits) andMPI_PACKED is collection of non-contiguous data.
-^
The message-tag can take values ranging from zero up to the MPI definedconstant MPI_TAG_UB.
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.
The barrier synchronization operation is performedin MPI using:
int MPI_Barrier(MPI_Comm comm) The one-to-all broadcast operation is:
*int MPI_Bcast(void *buf, int count,MPI_Datatype datatype,int source,MPI_Comm comm)*
The all-to-one reduction operation is:
int MPI_Reduce(void sendbuf,voidrecvbuf, int count, MPI_Datatypedatatype, MPI_Op op, int target,MPI_Comm comm)
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)
-^
The gather operation is performed in MPI using:
int
MPI_Gather(void
_sendbuf,_*
int
sendcount,
MPI_Datatype
senddatatype,
void
_recvbuf,_*
int
recvcount,
MPI_Datatype
recvdatatype,
int
target,
MPI_Comm
comm)
-^
MPI also provides the MPI_Allgather function in which thedata are gathered at all the processes.
int
MPI_Allgather(void
_sendbuf,intsendcount,_*
MPI_Datatype
senddatatype,
void
_recvbuf,_*
int
recvcount,
MPI_Datatype
recvdatatype,MPI_Comm
comm)
-^
The corresponding scatter operation is:
int
MPI_Scatter(void
_sendbuf,_*
int
sendcount,
MPI_Datatype
senddatatype,
void
_recvbuf,_*
int
recvcount,
MPI_Datatype
recvdatatype,
int
source,
MPI_Comm
comm)
MPI allows a programmer to organize processors intological
k
-d meshes
The processor ids
in
can be
mapped to other communicators (corresponding tohigher-dimensional meshes) in many ways.
-^
The goodness of any such mapping is determined bythe interaction pattern of the underlying program andthe topology of the machine.
-^
MPI does not provide the programmer any control overthese mappings.
Different ways to map a set of processes to a two-dimensionalgrid. (a) and (b)show a row- and column-wise mapping of these processes, (c) shows amapping that follows a space-filling curve(dotted line), and (d) shows a mappingin which neighboring processes are directly connected in a hypercube.
-^
Since sending and receiving messages still require (one-dimensional) ranks, MPI provides routines to convert ranks toCartesian coordinates and vice-versa:^ int MPI_Cart_coord(MPI_Comm comm_cart, int
*rank, int maxdims, int *coords) int MPI_Cart_rank(MPI_Comm comm_cart, int*
_coords, int rank)_
-^
The most common operation on Cartesian topologies is a shift.To determine the rank of source and destination of such shifts,MPI provides the following function:^ int MPI_Cart_shift(MPI_Comm comm_cart,
*int dir, int s_step, int *rank_source,*
*int *rank_dest)*
In many parallel algorithms, communication operationsneed to be restricted to certain subsets of processes.
-^
MPI provides mechanisms for partitioning the group ofprocesses that belong to a communicator into subgroupseach corresponding to a different communicator.
-^
The simplest such mechanism is:
This operation groups processors by color and sortsresulting groups on the key.
-^
In many parallel algorithms, processes are arranged in a virtual grid,and in different steps of the algorithm, communication needs to berestricted to a different subset of the grid.
-^
MPI provides a convenient way to partition a Cartesian topology toform lower-dimensional grids:
If
keep_dims[i]
is true (non-zero value in C) then the
i
th
dimension is retained in the new sub-topology.
-^
The coordinate of a process in a sub-topology created by MPI_Cart_sub
can be obtained from its coordinate in the original
topology by disregarding the coordinates that correspond to thedimensions that were not retained.
Splitting a Cartesian topology of size 2 x 4 x 7 into (a) four subgroups ofsize 2 x 1 x 7, and (b) eight subgroups of size 1 x 1 x 7.
All-to-all broadcast and all-to-all reduction.
-^
On a ring, the time is given by:
s^
w