2.2 Point to Point Communication¶
The fundamental basis of coordination between independent processes is point-to-point communication between processes through the communication links in the MPI.COMM_WORLD. The form of communication is called message passing, where one process sends data to another one, who in turn must receive it from the sender. This is illustrated as follows:
Point-to-point communication is a way that pair of processors transmits the data between one another, one processor sending, and the other receiving. MPI provides send()
and receive()
functions that allow point-to-point communication taking place in a communicator.
send(message, destination, tag)
- message: some type of data to be sent
- destination: rank of the receiving process
- tag: message tag is a way to identify the type of a message (optional)
recv(message, source, tag)
- message: some type of data to be received
- source: rank of the sending process
- tag: message tag is a way to identify the type of a message
Send and Receive Hello World¶
Here is a simple example where strings are sent from a conductor to the workers.
This MPI program illustrates the use of send()
and recv()
functions with the conductor-worker pattern from the previous section.