MPI_COMM_COMPARE(3)
π MPI_COMM_COMPARE(3) β Open MPI, bestie edition π
okay so listen β this is the MPI_COMM_COMPARE(3) page from Open MPI, and it's literally just "are these two communicators the same, kinda the same, or not even close." tiny function, huge glow-up. let's get into it β¨
β¨ NAME β¨
MPI_Comm_compare β compares two communicators. that's it. that's the whole vibe check π¦
πΈ SYNTAX πΈ
C Syntax
#include <mpi.h>
int MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_COMM_COMPARE(COMM1, COMM2, RESULT, IERROR)
INTEGER COMM1, COMM2, RESULT, IERROR
Fortran 2008 Syntax
USE mpi_f08
MPI_Comm_compare(comm1, comm2, result, ierror)
TYPE(MPI_Comm), INTENT(IN) :: comm1, comm2
INTEGER, INTENT(OUT) :: result
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π«Ά INPUT PARAMETERS π«Ά
comm1β comm1, and it's a handle. that's the whole assignment bestie πcomm2β comm2. also a handle. yes we're comparing them, keep up π
β OUTPUT PARAMETERS β
resultβ the result of the comparison, an integer. this is where the drama lands, iykyk π₯ierrorβ Fortran only, the error status (integer). Fortran girlies get their own lil slot for it π
π DESCRIPTION π
okay this is the part where it gets good, so pay attention β¨ here's the ranking, from "literally the same" to "who even are you":
MPI_IDENTβ drops if and only ifcomm1andcomm2are handles for the same object. like, identical groups and the same contexts. same same. no cap πMPI_CONGRUENTβ happens when the underlying groups are identical in constituents and rank order, and the only thing different is the context. so they're twinsies who just got assigned different lockers πMPI_SIMILARβ the group members of both communicators are the same, but the rank order differs. same squad, different seating chart πMPI_UNEQUALβ results otherwise. aka not it. different vibes entirely π
so yeah β groups same + context same =MPI_IDENT, groups same + context different =MPI_CONGRUENT, same members + different ordering =MPI_SIMILAR, anything else =MPI_UNEQUAL. the more you know π
π ERRORS π
okay so errors, strap in, this is the long part but it's all important, don't skip π«Ά
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.
before that error value is even returned, the current MPI error handler associated with the communication object (think: communicator, window, file β the whole little family) gets called. and if there's no communication object associated with the MPI call? then the call gets treated as attached to MPI_COMM_SELF, and it'll call the associated MPI error handler. and when MPI_COMM_SELF is not initialized β like before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're 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_errhandleronMPI_COMM_SELFwhen using the World model, or - via the
mpi_initial_errhandlerCLI argument tompiexec, or - via an info key to
MPI_Comm_spawn/MPI_Comm_spawn_multiple.
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 other MPI functions. yes, ALL the others. choices were made π
π§ the three predefined error handlers Open MPI ships with π§
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic, but make it cluster-wide π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. situational awareness, we love to see it β¨MPI_ERRORS_RETURNβ returns an error code to the application. polite. respectful. hands you the L gently π
πΈ roll your own error handlers πΈ
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... don't bank on it, bestie π
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 π
π COPYRIGHT π
2003-2026, The Open MPI Community β and that's the whole bit, no cap π
aaaand that's the page!! mwah, go compare some communicators π this has been MPI_COMM_COMPARE(3) out of Open MPI, dated Sep 11, 2026 β see you in the next man page, bestie π¦β¨π
π¦ 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