MPI supports messages passing between a source and a destination using two communication primitive: send and receive.
MPI supports the following types of send and receives functions:
- Blocking send & Recieve
- Non-blocking send & Recieve
1) Blocking Communication – In blocking communication the caller will block or wait until the message is not transmitted to the other end i.e., a program that invokes a blocking send primitive will block until the message is received by the destination and a program that invokes a blocking receive primitive will block until a message is received by the caller.
MPI_Send( void* buff, int count, MPI_Datatype datatype, int destination, int tag, MPI_Comm communicator)
MPI_Recv( void* buff, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm communicator, MPI_Status* status)
- Buffer: It represents the memory location where the message is stored.
- Data Count: Count of the number of items of particular MPI datatype(MPI_Datatype).
- Datatype: These are MPI predefined datatypes like MPI_CHAR, MPI_INT, etc. MPI datatypes are architecture Independent and hence are portable. Read more…
- Destination: The process where a message should be delivered. Specified as the rank of the receiving process.
- Source: The rank of originating process of the message or rank of the sending process.
- Tag: A random non-negative integer assigned to uniquely identify a message. The tag value of send and receive operation must be the same. If we want to receive any message we need to assign MPI_ANY_TAG as a tag value.
- Communicator: A set of processes for which the source or destination fields are valid. Most of the time predefined MPI_COMM_WORLD communicator is used.
- Status: Status variable tells the information about the received message e.g.,
- status.MPI_TAG: The tag of the received message.
- status.MPI_SOURCE: The rank of sending process of the message.
2) Non-Blocking Communication – In non-blocking communication, the caller will not block or wait for the entire message to be transmitted to the other end instead it will terminate and the program will continue. The reason for providing Non-blocking send and receive operations is to allow the process to do something else while waiting for the message to be transmitted or for some message to arrive.
MPI_ISend( void* buff, int count, MPI_Datatype datatype, int destination, int tag, MPI_Comm communicator)
MPI_IRecv( void* buff, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm communicator, MPI_Status* status)
MPI also supports some other type of send and receive routines such as Synchronous Send MPI_Ssend (&buf, count, datatype, dest, tag, comm) , Buffered Send MPI_Bsend (&buf, count, datatype, dest, tag, comm) , Combined send/receive MPI_Sendrecv(&send_buf, send_ count, send_datatype, dest, send_tag, &recvbuf, recv_count, recv_datatype, source, recv_tag, comm, &status) .
Did, we miss something or do you want to add some other key points?🤔
Please comment. 😊