MPI_INTERCOMM_CREATE(3)

πŸ’– MPI_INTERCOMM_CREATE πŸ’–

okay bestie, welcome to the Open MPI man pages, section 3, and today's main character is MPI_Intercomm_create 🫢


✨ NAME ✨

MPI_Intercomm_create β€” makes an intercommunicator out of two intracommunicators. yes. that's the whole vibe. two groups, one bridge, no cap πŸ’…


🌸 SYNTAX 🌸

πŸ’œ C Syntax

#include <mpi.h>

int MPI_Intercomm_create(MPI_Comm local_comm, int local_leader,
     MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm *newintercomm)

πŸ’œ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_INTERCOMM_CREATE(LOCAL_COMM, LOCAL_LEADER, PEER_COMM,
             REMOTE_LEADER, TAG, NEWINTERCOMM, IERROR)
     INTEGER LOCAL_COMM, LOCAL_LEADER, PEER_COMM, REMOTE_LEADER
     INTEGER TAG, NEWINTERCOMM, IERROR

πŸ’œ Fortran 2008 Syntax

USE mpi_f08
MPI_Intercomm_create(local_comm, local_leader, peer_comm, remote_leader,
             tag, newintercomm, ierror)
     TYPE(MPI_Comm), INTENT(IN) :: local_comm, peer_comm
     INTEGER, INTENT(IN) :: local_leader, remote_leader, tag
     TYPE(MPI_Comm), INTENT(OUT) :: newintercomm
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸŽ€ INPUT PARAMETERS πŸŽ€

  • local_comm β€” the communicator holding the process that kicks off the inter-communication (a handle, bestie).
  • local_leader β€” rank of the local group's leader inside local_comm (integer).
  • peer_comm β€” the "peer" communicator. it only actually means anything at the local_leader (handle). the way that it's just ignored everywhere else?? iconic.
  • remote_leader β€” rank of the remote group's leader, measured in peer_comm. again, only significant at the local_leader (integer).
  • tag β€” the message tag that identifies this brand-new intercommunicator (integer). it's giving ✨identity✨

πŸ¦‹ OUTPUT PARAMETERS πŸ¦‹

  • newintercomm β€” the freshly created intercommunicator (handle). your baby πŸ₯Ή
  • ierror β€” Fortran only: error status (integer).

🌈 DESCRIPTION 🌈

So this call creates an intercommunicator, and it's collective over the union of the local and remote groups β€” like, everybody's invited to this party. every process should hand in the same local_comm and local_leader arguments within its own group. and listen: wildcards are not permitted for remote_leader, local_leader, and tag. not a single one. periodt.

This call does point-to-point communication using the communicator peer_comm, and it uses tag between the leaders. which means β€” and this is the important part β€” you gotta be careful that there's no pending communication sitting on peer_comm that could interfere with this communication. πŸ™ˆ lowkey a hazard.

If you're making multiple MPI_Intercomm_create calls, they should all use different tags. more precisely: make sure the local and remote leaders are using different tags for each MPI_intercomm_create. don't be out here reusing tags, that's messy.


πŸ’… NOTES πŸ’…

We recommend using a dedicated peer communicator, like a duplicate of MPI_COMM_WORLD, so you don't get into trouble with peer communicators. highly suggest. do it for the plot.

Now here's some lore πŸ«–: the MPI 1.1 Standard contains two mutually exclusive comments about the input intracommunicators. one says their respective groups must be disjoint; the other says the leaders can be the same process. after the MPI Forum had some discussions, it was decided that the groups must be disjoint. and fun fact β€” the reason given for this in the standard is not the reason for this choice. the real reason is that the other operations on intercommunicators (like MPI_Intercomm_merge) do not make sense if the groups are not disjoint. iykyk.


😭 ERRORS 😭

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

Before that error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. If no communication object is associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. When MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when 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 the mpi_initial_errhandler CLI argument to mpiexec or 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.

Open MPI ships with three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yeah. everybody. πŸ’€
  • 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. so like… don't count on it. 🫠

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_Intercomm_merge
  • MPI_Comm_free
  • MPI_Comm_remote_group
  • MPI_Comm_remote_size

2003-2026, The Open MPI Community πŸ’œ


and that's the whole page bestie, no crumbs left 🌸 this was MPI_INTERCOMM_CREATE(3) from the Open MPI crew, dated Sep 10, 2026 β€” go forth and build your intercommunicators, you absolute legend πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from