Communicators


Up: Selected Subsystems Next: Collective Operations Previous: Groups

The Standard describes two types of communicators, intracommunicators and intercommunicators, which consist of two basic components, namely process groups and communication contexts. MPICH intracommunicators and intercommunicators use this same structure.

The Standard describes how intracommunicators and intercommunicators are related (see Section 5.6 of the Standard). We take advantage of this similarity to reduce the complexity of functions that operate on both intracommunicators and intercommunicators (e.g., communicator accessors, point-to-point operations). Most functions in the portable layer of MPICH do not need to distinguish between an intracommunicator and an intercommunicator. For example, each communicator has a local group (local_group) and a remote group (group) as described in the definition of an intercommunicator. For intracommunicators, these two groups are identical (reference counting is used to reduce the amount of overhead associated with keeping two copies of a group; see Section Groups ); however, for intercommunicators, these two groups are disjoint.

Another similarity between intracommunicators and intercommunicators is the use of contexts. Each communicator has a send context (send_context) and a receive context (recv_context). For intracommunicators, these two contexts are equal; for intercommunicators, these contexts may be different. Regardless of the type of communicator, MPI point-to-point operations attach the send_context to all outgoing messages and use the recv_context when matching contexts upon receipt of a message.

For most MPICH devices, contexts are integers. Contexts for new communicators are allocated through a collective operation over the group of processes involved in the communicator construction. Through this collective operation, all processes involved agree on a context that is currently not in use by any of the processes. One of the algorithms used to allocate contexts involves passing the highest context currently used by a process to an MPI_Allreduce with the MPI_MAX operation to find the smallest context (an integer) unused by any of the participants.

In order to provide safe point-to-point communications within a collective operation, an additional ``collective'' context is allocated for each communicator. This collective context is used during communicator construction to create a ``hidden'' communicator (comm_coll) that cannot be accessed directly by the user. This is necessary so that point-to-point operations used to implement a collective operation do not interfere with user-initiated point-to-point operations.

Other important elements of the communicator data structure include the following:

{ np, local_rank, lrank_to_grank}
Used to provide more convenient access to local group information.
{ collops}
Array of pointers to functions implementing the collective operations for the communicator (see Section Collective Operations ).



Up: Selected Subsystems Next: Collective Operations Previous: Groups