Basics of MPI Programming

4.1 Process Groups

In addition to the development of parallel libraries, communicators are also useful in organizing communication within an application. We have been describing communicators that include all processes in the application. But the programmer can also define a subset of processes, called a process group, and attach one or more communicators to the process group. Communication specifying that communicator will now be restricted to those processes.

In the example below, the communication pattern is a 2-D mesh. Each of the six boxes represents a process. Each process must exchange data with its upper and lower, and right and left neighbors. Coding this communication is simpler if the processes are grouped by column (for up/down communication) and row (for right/left communication). So, each process belongs to three communicators, which are indicated by the words in that process's box: one communicator for all processes (the default world communicator), one communicator for its row, and one communicator for its column. The communicators are as follows:


world communicator for all processes uncolored in diagram
comm1 communicator for row 1 yellow in diagram
comm2 communicator for row 2 purple in diagram
comm3 communicator for column 1 pink in diagram
comm4 communicator for column 2 green in diagram
comm5 communicator for column 3 blue in diagram


This also ties directly into use of collective communications (covered in MPI Collective Communication I).

world, rank0
world, rank1
world, rank2
comm1, rank0
comm1, rank1
comm1, rank2
comm3, rank0
comm4, rank0
comm5, rank0

world, rank3
world, rank4
world, rank5
comm2, rank0
comm2, rank1
comm2, rank2
comm3, rank1
comm4, rank1
comm5, rank1

To revisit the bill collection analogy: one person may have an account with the electric and phone companies (2 communicators) but not with the water company. The electric communicator may contain different people than the phone communicator. A person's ID number (rank) may vary with the utility (communicator). So, it is critical to note that the rank given as message source or destination is the rank in the specified communicator.