MPI_COMM_CREATE_GROUP(3)

πŸ’– MPI_COMM_CREATE_GROUP πŸ’–

okay bestie, welcome to the MPI_Comm_create_group page from Open MPI β€” she's a 3, she's a library call, and she makes brand new communicators out of thin air. let's get into it πŸ¦‹


✨ SYNTAX ✨

🌸 C Syntax

#include <mpi.h>

int MPI_Comm_create_group(MPI_Comm comm, MPI_Group group, int tag, MPI_Comm *newcomm)

🌸 Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'

MPI_COMM_CREATE_GROUP(COMM, GROUP, TAG, NEWCOMM, IERROR)
    INTEGER COMM, GROUP, TAG, NEWCOMM, IERROR

🌸 Fortran 2008 Syntax

USE mpi_f08

MPI_Comm_create_group(comm, group, tag, newcomm, ierror)
    TYPE(MPI_Comm), INTENT(IN) :: comm
    TYPE(MPI_Group), INTENT(IN) :: group
    INTEGER, INTENT(IN) :: tag
    TYPE(MPI_Comm), INTENT(OUT) :: newcomm
    INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸ“₯ INPUT PARAMETERS πŸ“₯

  • comm β€” the communicator, a handle. the whole squad's group chat πŸ’¬
  • group β€” a group, which has to be a subset of the group of comm (handle). like, a smaller group chat carved out of the big one βœ‚οΈ
  • tag β€” a tag (integer). yes it's just a tag, slay πŸ’…

πŸ“€ OUTPUT PARAMETERS πŸ“€

  • newcomm β€” the new communicator (handle). your fresh new squad πŸŽ€
  • ierror β€” Fortran only: error status (integer).

πŸ¦‹ DESCRIPTION πŸ¦‹

so MPI_Comm_create_group is giving very much MPI_Comm_create energy, however β€” and this is the part that matters β€” MPI_Comm_create has to be called by all processes in the group of comm, whereas MPI_Comm_create_group only has to be called by all processes in group, which is a subgroup of the group of comm. lowkey a whole different vibe ✨

also, MPI_Comm_create_group requires that comm is an intracommunicator. no cap.

MPI_Comm_create_group returns a new intracommunicator, newcomm, and the group argument is what defines the communication group for it. nothing cached travels from comm to newcomm β€” zero, nada, no leftover vibes 🚫

every process has to hand over a group argument that is a subgroup of the group associated with comm; and bestie, this could even be MPI_GROUP_EMPTY. if you specify a non-empty group, then all processes in that group must call the function, and each of those processes must pass the same arguments β€” including a group that contains the same members, in the same ordering. otherwise the call is erroneous, and we do not do erroneous πŸ’€

if the calling process is a member of the group given as the group argument, then newcomm is a communicator with group as its associated group. but if the calling process is not a member of group β€” say, group is MPI_GROUP_EMPTY β€” then the call is a local operation and MPI_COMM_NULL gets returned as newcomm. and that's on periodt πŸ™ˆ


πŸ“ NOTES πŸ“

MPI_Comm_create_group is the way to make a subset of processes for the purpose of separate MIMD computation, with its own separate communication space. newcomm β€” which is created by MPI_Comm_create_group β€” can then be used in subsequent calls to MPI_Comm_create_group (or other communicator constructors) to keep subdividing a computation into parallel sub-computations. it's giving nesting dolls but make it HPC πŸ’…

if you want a more general service, that's MPI_Comm_split's moment, go check her out.


🚨 ERRORS 🚨

almost all MPI routines return an error value. C routines return it as the return result of the function, and Fortran routines put it in the last argument.

before the error value comes back, the current MPI error handler associated with the communication object (e.g., communicator, window, file) gets called. if no communication object is associated with the MPI call, then the call is treated as attached to MPI_COMM_SELF and will call the associated MPI error handler. when MPI_COMM_SELF is not initialized β€” that means before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're using the Sessions Model exclusively β€” the error raises the initial error handler. the initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or via the mpi_initial_errhandler CLI argument to mpiexec, or via an info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple.

if no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions, and the MPI_ERRORS_ABORT error handler is called for all other MPI functions. ok so like, heads up 🫢

Open MPI includes three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. dramatic, but on purpose πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler that can be invoked on a communicator, window, file, or session. when called on a communicator, it acts as if MPI_Abort was called on that communicator. if called on a window or file, it acts as if MPI_Abort was called on a communicator containing the group of processes in the corresponding window or file. if called on a session, it aborts only the local process.
  • MPI_ERRORS_RETURN β€” returns an error code to the application.

MPI applications can also implement their own error handlers by calling:

  • MPI_Comm_create_errhandler then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler, or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_Win_set_errhandler
⚠️ note that MPI does not guarantee that an MPI program can continue past an error. like, no promises bestie.

see the MPI man page for a full list of MPI error codes.

see the Error Handling section of the MPI-3.1 standard for more information.

See also:

  • MPI_Comm_create

2003-2026, The Open MPI Community


and that's the whole page, babe πŸŽ€ written by the Open MPI girlies, dated Sep 10, 2026, filed under MPI_COMM_CREATE_GROUP(3) β€” go make some subgroups, iykyk πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from