Skip main navigation

What is point-to-point communication in MPI?

MPI processes communicate by explicitly sending and receiving messages. In point-to-point, messages are sent between two processes
© CC-BY-NC-SA 4.0 by CSC - IT Center for Science Ltd.

Since MPI processes are independent, in order to coordinate work, they need to communicate by explicitly sending and receiving messages. There are two types of communication in MPI: point-to-point communication and collective communication.

In point-to-point communication messages are sent between two processes, whereas a collective communication involves a number of processes at the same time.

What is point-to-point communication?

In a nutshell, in point-to-point communication one process sends a message (some data) to another process that receives it. The important thing to remember is that the sends and receives in a programme have to match: one receive per one send.

In addition to matching each send call with a corresponding receive call, one needs to pay particular attention to match also the destination and source ranks for the communication. A message is always sent to given process (destination rank) and, similarly, received from a given process (source rank).

One can think of the destination and source ranks as the addresses for the messages, for example: “please send the message to this address” and “is there a message coming from this address?”.

What is an example of sending and receiving a dictionary?

from mpi4py import MPI

rank = comm.Get_rank()

if rank == 0:
 data = {'a': 7, 'b': 3.14}
 comm.send(data, dest=1)
elif rank == 1:
 data = comm.recv(source=0)

How can I send and receive data?

Python objects can be communicated with the send() and recv() methods of a communicator. It works for any Python object that can be serialised into a byte stream, that is any object that can be pickled.

This includes all standard Python objects and most derived ones as well. The basic interfaces (check mpi4py documentation for optional arguments) of the methods are:

.send(data, dest)

  • data: Python object to send
  • dest: destination rank


  • source: source rank
  • note: data is provided as return value

What are typical point-to-point communication patterns?

The normal send and receive routines are blocking, meaning the functions exit only once it is safe to use the data (memory) involved in the communication. This means that the completion depends on the other process and that there is
a risk of a deadlock. For example, if both processes call recv() first there is no-one left to call a corresponding send() and the program is stuck forever.

Typical point-to-point communication patterns are shown below. Incorrect ordering of sends and receives may result in a deadlock:

Communication patterns

© CC-BY-NC-SA 4.0 by CSC - IT Center for Science Ltd.
This article is from the free online

Python in High Performance Computing

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education