This section presents several examples of how to use MPI Sessions to create MPI Groups and MPI Communicators.
Example
Simple example illustrating creation of an MPI communicator using the Sessions Model.
Example Sessions Model Examples shows how the predefined "mpi://WORLD" process set can be used to first create a local MPI group and then subsequently to create an MPI communicator from this group.
Example
This example illustrates the use of Process Set query functions
to select a Process Set to use for MPI Group creation.
Example Sessions Model Examples illustrates several aspects of the Sessions Model. First, the default error handler can be specified when instantiating a Session instance. Second, there must be at least two process sets associated with a Session. Third, the example illustrates use of the Sessions info object and the one required key: mpi_size.
Example
A Fortran 2008 example illustrating how to obtain information about available process sets, create an MPI Group
from a process set, and subsequently create an MPI Communicator.
Note in this example that the call to MPI_SESSION_FINALIZE may block in order to ensure that the calling MPI process has completed its involvement in the preceding MPI_BARRIER operation. If MPI_COMM_DISCONNECT had been used instead of MPI_COMM_FREE, the example would have blocked in MPI_COMM_DISCONNECT rather than MPI_SESSION_FINALIZE.