Summary

These are lecture notes on the Message Passing Interface (MPI). The notes cover various MPI communication functions such as send, receive, broadcast, scatter, gather, and others, focusing on the syntax and how they work. The lecture notes include diagrams and illustrations of how MPI functions work.

Full Transcript

Lecture 3 // Same syntax for Ssend, Bsend, Rsend int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, M...

Lecture 3 // Same syntax for Ssend, Bsend, Rsend int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status) Envelop information about a received message are obtained from the status variable (except for COUNT): status.MPI_SOURCE status.MPI_TAG status.MPI_ERROR For COUNT: int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count) // To check whether a message is ready to be received int MPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status) Lecture 4 Nonblocking communication functions start to _I and have MPI_Request *request as the last argument. For example: int MPI_Issend(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) Wait: int MPI_Wait(MPI_Request *request, MPI_Status *status) // at least 2 complete => unblock all int MPI_Waitany(int count, MPI_Request array_of_requests[], int *index, MPI_Status *status); // at least n complete => unblock all int MPI_Waitsome(int incount, MPI_Request array_of_requests[], int *outcount, int array_of_indices[], MPI_Status array_of_statuses[]); // all complete => unblock all int MPI_Waitall(int count, MPI_Request array_of_requests[], MPI_Status array_of_statuses[]); Test (doesn't block): int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status) int MPI_Testany(int count, MPI_Request array_of_requests[], int *index, int *flag, MPI_Status *status); int MPI_Testsome(int incount, MPI_Request array_of_requests[], int *outcount, int array_of_indices[], MPI_Status array_of_statuses[]); int MPI_Testall(int count, MPI_Request array_of_requests[], int *flag, MPI_Status array_of_statuses[]); Lecture 5 int MPI_Barrier(MPI_Comm comm) double MPI_Wtime() // returns "time in the past" int MPI_Abort(MPI_Comm comm, int errorcode) Bcast visualization int MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm) Scatter visualization int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) Gather visualization int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) Lecture 6 int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status) 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) Allgather visualization int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) All-to-all visualization int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) Reduce visualization int MPI_Reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) int MPI_Op_create(MPI_User_function *func, int commute, MPI_Op *op) int MPI_Allreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) Scan visualization int MPI_Scan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) Lecture 7 Scatterv visualization int MPI_Scatterv(const void *sendbuf, const int sendcounts[], const int displs[], MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) Gatherv visualization int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, int root, MPI_Comm comm) Allgatherv visualization int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, MPI_Comm comm) Alltoallv visualization int MPI_Alltoallv(const void *sendbuf, const int sendcounts[], const int sdispls[], MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int rdispls[], MPI_Datatype recvtype, MPI_Comm comm) Send/receive data can have different types int MPI_Alltoallw(const void *sendbuf, const int sendcounts[], const int sdispls[], const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[], const int rdispls[], const MPI_Datatype recvtypes[], MPI_Comm comm) Reduce scatter visualization int MPI_Reduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[], MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) Lecture 8 Same functions from Lecture 7, with _I prefix and MPI_Request req at the end int MPI_Iscatterv(const void *sendbuf, const int sendcounts[], const int displs[], MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Request req) int MPI_Igatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Request req) int MPI_Iallgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, MPI_Comm comm, MPI_Request req) int MPI_Ialltoallv(const void *sendbuf, const int sendcounts[], const int sdispls[], MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int rdispls[], MPI_Datatype recvtype, MPI_Comm comm, MPI_Request req) int MPI_Ialltoallw(const void *sendbuf, const int sendcounts[], const int sdispls[], const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[], const int rdispls[], const MPI_Datatype recvtypes[], MPI_Comm comm, MPI_Request req) int MPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[], MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request req) Lecture 9 int MPI_Cart_create(MPI_Comm comm_old, int ndims, const int dims[], const int periods[], int reorder, MPI_Comm *comm_cart) int MPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int coords[]) int MPI_Cart_rank(MPI_Comm comm, int coords[], int *rank) // disp < 0: downward/left shift int MPI_Cart_shift(MPI_Comm comm, int direction, int disp, int *rank_source, int *rank_dest) Cart sub visualization 1 Cart sub visualization 2 int MPI_Cart_sub(MPI_Comm comm, const int remain_dims[], MPI_Comm *comm_new) // MPI_CART or MPI_GRAPH int MPI_Topo_test(MPI_Comm comm, int *topo_type) int MPI_Dims_create(int nnodes, int ndims, int dims[]) int MPI_Cart_get(MPI_Comm comm, int maxdims, int dims[], int periods[], int coords[]) int MPI_Cartdim_get(MPI_Comm comm, int *ndims) Lecture 10 int MPI_Graph_create(MPI_Comm comm_old, int nnodes, const int index[], const int edges[], int reorder, MPI_Comm *comm_graph) int MPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int index[], int edges[]) int MPI_Graphdims_get(MPI_Comm comm, int *nnodes, int *nedges) int MPI_Graph_neighbors_count(MPI_Comm comm, int rank, int *nneighbors) int MPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int neighbors[]) Lecture 11 Visualization int MPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype) Visualization int MPI_Type_vector(int count, int blocklength, int stride, MPI_Datatype oldtype, MPI_Datatype *newtype) Visualization int MPI_Type_create_struct(int count, int *array_of_blocklengths, MPI_Aint *array_of_displacements, MPI_Datatype *array_of_types, MPI_Datatype *newtype) Visualization int MPI_Type_create_subarray(int ndims, int array_of_sizes[], int array_of_subsizes[], int array_of_starts[], int order, MPI_Datatype oldtype, MPI_Datatype *newtype) int MPI_Type_commit(MPI_Datatype *datatype) int MPI_Type_free(MPI_Datatype *datatype) // Aint is type to work with addresses int MPI_Get_address(void *location, MPI_Aint *address) int MPI_Type_size(MPI_Datatype datatype, int *size) int MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint *lb, MPI_Aint *extent) int MPI_Type_create_resized(MPI_Datatype oldtype, MPI_Aint lb, MPI_Aint extent, MPI_Datatype* newtype)

Use Quizgecko on...
Browser
Browser