MPI_INTERCOMM_CREATE(3)

πŸ’… MPI_INTERCOMM_CREATE(3) β€” the Open MPI glow-up

okay bestie, buckle up πŸ’– this one's from the Open MPI manual, section 3, and it's literally about making two separate friend groups talk to each other. main character energy fr fr.


✨ NAME ✨

MPI_Intercomm_create β€” creates an intercommunicator from two intracommunicators 🫢


✨ 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 that has the process starting the whole inter-communication thing off (it's a handle, not a vibe) πŸ’…
  • local_leader β€” rank of the local group's leader inside local_comm (integer)
  • peer_comm β€” the "peer" communicator, and heads up: it only actually matters at the local_leader (handle). like, everyone else can just chill πŸ™ˆ
  • remote_leader β€” rank of the remote group's leader in peer_comm; again, significant only at the local_leader (integer)
  • tag β€” the message tag that ID's this brand-new intercommunicator (integer) 🏷️

πŸ’– OUTPUT PARAMETERS πŸ’–

  • newintercomm β€” the freshly created intercommunicator (handle) ✨ slay, you made a baby communicator
  • ierror β€” Fortran only: error status (integer)

πŸ¦‹ DESCRIPTION πŸ¦‹

so this call creates an intercommunicator. it's collective over the union of the local and remote groups β€” meaning everybody in both groups is in on it, no lurkers πŸ‘‘

processes are supposed to pass identical local_comm and local_leader arguments within each group. and no, wildcards are not permitted for remote_leader, local_leader, and tag. none. zero. don't even try it πŸ’€

this call uses point-to-point communication over the communicator peer_comm, and with the tag tag between the leaders. so lowkey be careful β€” there must be no pending communication on peer_comm that could interfere with this communication. like, don't leave messages on read while this is running 🫢

if you're making multiple MPI_Intercomm_creates, they should each use different tags (more precisely β€” the local and remote leaders should be sure they're using different tags for each MPI_intercomm_create). one tag per intercomm, no sharing, periodt.


πŸ‘‘ NOTES πŸ‘‘

we recommend using a dedicated peer communicator, like a duplicate of MPI_COMM_WORLD, to avoid trouble with peer communicators. give it its own space, it deserves it πŸ’…

okay so here's the drama 😭 the MPI 1.1 Standard contains two mutually exclusive comments on the input intracommunicators:

  1. one says their respective groups must be disjoint
  2. the other says the leaders can be the same process

after much discussion by the MPI Forum, the verdict is in: the groups must be disjoint. and ngl, the reason given for this in the standard is not the actual reason for this choice β€” the real tea is that the other operations on intercommunicators (like MPI_Intercomm_merge) just don't make sense if the groups aren't 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 stick it in the last argument. iconic behavior fr.

before that error value comes back, the current MPI error handler associated with the communication object (e.g., communicator, window, file) gets called. if there's no communication object 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 isn't 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. and that initial error handler can be changed by:

  • calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model
  • the mpi_initial_errhandler CLI argument to mpiexec
  • the 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. rules are rules πŸ’…

Open MPI includes three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. dramatic? yes. correct? also yes πŸ’€
  • 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. context-aware king πŸ‘‘
  • 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. no cap, that's just how it is 😭

see the MPI man page for a full list of MPI error codes, and see the Error Handling section of the MPI-3.1 standard for more information. go read it, bestie, it's giving homework but it's worth it πŸ“š

πŸ‘€ 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 πŸŽ€βœ¨ this was filed under Open MPI, dated Sep 11, 2026, and the copyright belongs to The Open MPI Community, 2003-2026. you're so welcome, go forth and intercommunicate πŸ’–πŸ¦‹

πŸ“¦ where this page comes from