MPI_GROUP_DIFFERENCE(3)
π¦ MPI_Group_difference(3) β an Open MPI glow-up π¦
okay bestie, welcome to the MPI_Group_difference(3) page from Open MPI β this is the group-math one and it's honestly kind of iconic. let's get into it π
πΈ NAME πΈ
MPI_Group_difference β makes a new group out of the difference of two groups. set math but make it parallel π
β¨ SYNTAX β¨
π C Syntax
#include <mpi.h>
int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
MPI_Group *newgroup)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_GROUP_DIFFERENCE(GROUP1, GROUP2, NEWGROUP, IERROR)
INTEGER GROUP1, GROUP2, NEWGROUP, IERROR
π Fortran 2008 Syntax
USE mpi_f08
MPI_Group_difference(group1, group2, newgroup, ierror)
TYPE(MPI_Group), INTENT(IN) :: group1, group2
TYPE(MPI_Group), INTENT(OUT) :: newgroup
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT PARAMETERS π
group1: the first group, a handle. the main character of this operation ngl π«Άgroup2: the second group, also a handle.
π OUTPUT PARAMETERS π
newgroup: the difference group (handle). this is the new baby that gets born β¨ierror: Fortran only β error status (integer). C girlies get their error as the return value instead, iykyk.
π DESCRIPTION π
the set-like operations are defined like this, periodt:
- union β all elements of the first group (
group1), followed by all elements of the second group (group2) that are not in the first group - intersect β all elements of the first group that are also in the second group, ordered as in the first group
- difference β all elements of the first group that are not in the second group, ordered as in the first group
lowkey important: for all these operations, the order of processes in the output group is decided primarily by order in the first group (if that's possible), and then, if it's necessary, by order in the second group. so first group stays winning π
and like, neither union nor intersection is commutative β but both are associative, and that's just the vibe. fr fr.
the new group can totally be empty, i.e. equal to MPI_GROUP_EMPTY. it's giving minimalist π
π 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. classic.
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 counts as being attached to MPI_COMM_SELF and will call the associated MPI error handler. and 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. you can change that initial error handler by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're using the World model, or with the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. and if no other appropriate error handler has been set, then MPI_ERRORS_RETURN gets called for MPI I/O functions, and MPI_ERRORS_ABORT gets called for all the other MPI functions. them's the rules π§
Open MPI ships three predefined error handlers you can use:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic much? πMPI_ERRORS_ABORTβ an error handler that can be invoked on a communicator, window, file, or session. when it's called on a communicator, it acts as ifMPI_Abortwas called on that communicator. if it's called on a window or file, it acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. if it's called on a session, it aborts only the local process. context matters bestie β¨MPI_ERRORS_RETURNβ returns an error code to the application. polite king behavior π
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_Win_set_errhandler
β οΈ note that MPI does not guarantee that an MPI program can continue past an error. so likeβ¦ no cap, don't assume you can just keep going π
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. yes it's a real section, go read it, it's good for you π«Ά
π₯ SEE ALSO π₯
MPI_Group_free
π COPYRIGHT π
copyright 2003-2026, The Open MPI Community β all theirs, not mine π
and that's the page bestie!! written up in the Open MPI docs, dated Sep 11, 2026 (yes, the future, she's ahead of her time β). go forth and difference some groups, you absolute icon ππ
π¦ where this page comes from
- arch rolling: openmpi 5.0.11-1 Β· BSD-3-Clause AND LicenseRef-MPICH
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms