MPI_Intercomm_create_from_groups(3)

πŸ’– MPI_Intercomm_create_from_groups(3) πŸ’–

okay bestie, welcome to the MPI manual, this one is MPI_Intercomm_create_from_groups, and it's literally the function that builds you an intercommuncator (yes that's the page's own spelling, we respect the typo era 🫢) out of a local group and a remote group. no cap.


✨ SYNOPSIS ✨

int MPI_Intercomm_create_from_groups(MPI_Group local_group, int local_leader,
MPI_Group remote_group, int remote_leader,
const char *stringtag, MPI_Info info,
MPI_Errhandler errhandler,
MPI_Comm *newintercomm)

🌸 INPUT PARAMETERS 🌸

  • local_group β€” the local group, as a handle. your side of the story πŸ’…
  • local_leader β€” rank of the local group leader inside local_group (an integer).
  • remote_group β€” the remote group, handle. and listen: this one is significant only at local_leader, so everybody else can just vibe, it's giving "only the leader's opinion matters" energy 😭
  • remote_leader β€” rank of the remote group leader inside remote_group (integer). also significant only at local_leader. same deal, bestie.
  • stringtag β€” a unique identifier for this operation, and it's a string (not an int, we're fancy now ✨).
  • info β€” info object (handle).
  • errhandler β€” the error handler that's gonna be attached to the brand-new inter-communicator (handle).

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

  • newintercomm β€” the new inter-communicator (handle). the glow-up. the main character. πŸ‘‘

πŸ¦‹ THREAD AND INTERRUPT SAFETY πŸ¦‹

good news first: this routine is thread-safe. that means you can absolutely use it from multiple threads at the same time, and you do not need to bring your own thread locks. slay.

bad news, or like, the fine print: it is not interrupt safe. usually that's because of memory allocation routines β€” stuff like malloc, or other non-MPICH runtime routines β€” which are themselves not interrupt-safe. so yeah. not interrupt safe, periodt.


🌈 NOTES FOR FORTRAN 🌈

every MPI routine in Fortran (except our two icons, MPI_WTIME and MPI_WTICK) gets an extra argument called ierr tacked on at the end of the argument list. ierr is an integer and it means exactly the same thing as the return value of the routine in C. also, in Fortran, MPI routines are subroutines and you invoke them with the call statement. iykyk.

and every MPI object (like MPI_Datatype, MPI_Comm) is type INTEGER in Fortran. that's the whole bit.


πŸ’€ ERRORS πŸ’€

so, every MPI routine (again, except the duo MPI_Wtime and MPI_Wtick) returns an error value β€” C routines as the return value of the function, Fortran routines in that last argument. and before that value comes back, the current MPI error handler gets called. by default, that error handler aborts the MPI job. 😭 so like, mind the vibes.

you can swap the error handler with:

  • MPI_Comm_set_errhandler β€” for communicators
  • MPI_File_set_errhandler β€” for files
  • MPI_Win_set_errhandler β€” for RMA windows

there's also the MPI-1 routine MPI_Errhandler_set, which you may use, but its use is deprecated πŸ™ˆ (we don't do that anymore bestie). and if you want error values returned instead of the whole job going poof, there's the predefined error handler MPI_ERRORS_RETURN.

ngl, MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so like, sometimes it works out. sometimes it does not.

the roster of error codes, in order:

  • MPI_SUCCESS β€” no error, the routine completed successfully. we ate. πŸ’…
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and it isn't identified by a specific error class (e.g. MPI_ERR_RANK). mysterious. unlabeled. annoying.
  • MPI_ERR_GROUP β€” a null or invalid group got passed to the function.
  • MPI_ERR_INFO β€” invalid Info.
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. go read the receipts. πŸ”

and that's the whole page babe 🫢 this one came straight out of the MPI manual, MPI version of the page MPI_Intercomm_create_from_groups(3), dated 4/10/2026. go build some inter-communicators, you're doing amazing sweetie. βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’–

πŸ“¦ where this page comes from