MPI_Comm_create_from_group(3)

πŸ’– MPI_Comm_create_from_group(3) πŸ’–

okay so bestie, welcome to the MPI manual page for MPI_Comm_create_from_group β€” yes it's a C function, yes it's section 3, yes we're doing this. grab a lil snack πŸ“ because this one is actually kinda iconic: it creates a communicator from a group. that's the whole vibe. let's get into it ✨


✨ NAME ✨

MPI_Comm_create_from_group β€” create communicator from a group 🫢


🌸 SYNOPSIS 🌸

int MPI_Comm_create_from_group(MPI_Group group, const char *stringtag,
MPI_Info info, MPI_Errhandler errhandler,
MPI_Comm *newcomm)

like. look at her. five arguments. main character energy fr fr πŸ‘‘


πŸŽ€ INPUT PARAMETERS πŸŽ€

  • group β€” the group, she's a handle πŸ’…
  • stringtag β€” a unique identifier for this operation, and it's a string, so yes it's giving "name your child" energy, pick something distinct no cap
  • info β€” an info object, handle, we love her
  • errhandler β€” the error handler that gets attached to the new intra-communicator (handle). not a regular communicator, an intra-communicator. precision bestie 🌈

πŸ’œ OUTPUT PARAMETERS πŸ’œ

  • newcomm β€” the new communicator (handle). there she is!! the moment we've all been waiting for πŸ˜­πŸ’–

⭐ THREAD AND INTERRUPT SAFETY ⭐

okay this part is important so pay attention bestie:

this routine is thread-safe. what that means: multiple threads can safely use it, and nobody needs to bring their own user-provided thread locks. no gatekeeping, no extra work, slay 🧚

however β€” and this is the plot twist πŸ’€ β€” the routine is not interrupt safe. typically that's because it uses memory allocation routines like malloc, or other non-MPICH runtime routines, and those are themselves not interrupt-safe. so like, it's giving "safe with friends, not safe when interrupted". noted. periodt.


🌈 NOTES FOR FORTRAN 🌈

for my Fortran besties, here's the tea πŸ«–:

  • All MPI routines in Fortran have an additional argument ierr at the end of the argument list β€” with two exceptions: MPI_WTIME and MPI_WTICK. those two are just built different, iykyk.
  • ierr is an integer and means exactly the same thing as the return value of the routine in C.
  • In Fortran, MPI routines are subroutines, and you invoke them with the call statement.
  • All MPI objects (e.g. MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. yes literally all of them. that's just the rule πŸ’…

😭 ERRORS 😭

okay so every MPI routine returns an error value β€” with the exception of MPI_Wtime and MPI_Wtick (again!! those two mfs πŸ™ˆ). in C, the error value is the value of the function; in Fortran, it's in the last argument.

before that value comes back, the current MPI error handler gets called. and by default? this error handler aborts the MPI job. like, full stop, done, goodbye πŸ’€ so maybe keep that in mind.

the error handler can be changed with:

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

and the MPI-1 routine MPI_Errhandler_set may still be used, but its use is deprecated β€” so like, technically yes, but girl don't 🚫. the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead.

⚠️ important caveat bestie: MPI does not guarantee that an MPI program can continue past an error. that said, MPI implementations will attempt to continue whenever possible. so it's giving "we try our best, no promises" 🫢

here are the error codes, in all their glory:

  • MPI_SUCCESS β€” no error, the MPI routine completed successfully. the dream. the fantasy. we love to see it ✨
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and it's not identified by a specific error class (e.g. MPI_ERR_RANK). like, one of your args is sus and nobody's saying which πŸ™ˆ
  • MPI_ERR_GROUP β€” null or invalid group passed to the function. check ur group bestie.
  • MPI_ERR_INFO β€” invalid Info. the info object said no 🚫
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. the mysterious one. the enigma. go ask MPI_Error_string for the lore πŸ”

and that's the whole page, babe πŸŽ€ huge slay, you read a whole manpage, I'm so proud πŸ’–

🌟 this has been MPI_Comm_create_from_group(3) from the MPI manual, dated 4/10/2026. love u, go build a communicator, bye bestieee πŸ‘‘πŸ¦‹πŸ’œ
πŸ“¦ where this page comes from