This is a general overview of MPI communicators. This topic will be covered in much greater depth in MPI Advanced Topics.

As we have seen, a message's eligibility to be picked up by a specific receive call depends on its tag, source, and communicator. The tag is what allows a receiving process to distinguish among messages from the same sending process. The source is provided as a separate identifier because it simplifies programming: when similar information is sent from multiple sources, each source (i.e., sending process) can assign an identical tag to its message, instead of having to assign a globally unique tag to its message.

Why is a communicator needed?

Suppose you are sending messages between your processes, but in addition, you are calling a set of libraries you obtained elsewhere, which also uses MPI in order to communicate between processes during library calls. In this case, you want to be sure your messages are going where you intend them to go, and are not getting confused with messages being sent in conjunction with the library routines. This is when having communicators becomes important; they allow you to distinguish between your program's MPI calls and the library's MPI calls.

Can't tags be used to distinguish message spaces?

The problem with tags is that they are given values by the programmer, and they might use the same tag used by a parallel library using MPI. With communicators, the system, not the programmer, assigns identification — the system assigns a communicator to the user, and it assigns a different communicator to the library — so there is no possibility of overlap.

Communicators have other important uses as well. Since all communicators are subsets of MPI_COMM_WORLD, you can, for instance, make a communicator for each row and column in a grid of processors. This illustrates how a process can be part of several communicators: the "world", one row, and one column.

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Inclusivity Statement