What is point-to-point communication in MPI? (2024)

MPI processes communicate by explicitly sending and receiving messages. In point-to-point, messages are sent between two processes

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.

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 MPIcomm = MPI.COMM_WORLDrank = 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() methodsof a communicator. It works for any Python object that can be serialised intoa byte stream, that is any object that can be pickled.

This includes allstandard 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

.recv(source)

  • 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 exitonly 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() firstthere 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:

© CC-BY-NC-SA 4.0 by CSC - IT Center for Science Ltd.

What is point-to-point communication in MPI? (2024)
Top Articles
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 6862

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.