MPI_Comm_ser_errhandler(3)

πŸ’– MPI_Comm_ser_errhandler(3) β€” the LAM/MPI era ✨

okay bestie, so this is a page from the LAM/MPI manual, and it's about setting who handles your communicator's oopsies. yes the title says MPI_Comm_ser_errhandler and the actual function is MPI_Comm_set_errhandler β€” that typo has been living here rent free since forever, we don't fix it, we just love it. πŸ’…


🌸 NAME 🌸

MPI_Comm_ser_errhandler β€” set error handler of communicator

fr fr that's the whole job: pick who deals with the drama when your communicator misbehaves.


✨ SYNOPSIS ✨

#include <mpi.h>
int
MPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhdl)

look at her. so simple. so iconic. πŸ’–


πŸŽ€ INPUT PARAMETER πŸŽ€

  • comm β€” Communicator. the little social circle we're attaching a handler to.

🫢 OUTPUT PARAMETER 🫢

  • errhdl β€” Error Handler. yes bestie, it's listed as an output parameter here, we're just reporting the page exactly as it is. that's the handler in question.

πŸ¦‹ NOTES FOR FORTRAN πŸ¦‹

so here's the tea for the Fortran girlies:

  • every single MPI routine in Fortran has an extra argument called ierr tacked onto the end of the argument list β€” the only exceptions are MPI_WTIME and MPI_WTICK. ierr is an integer and it means exactly the same thing as the return value of the routine in C. no cap.
  • in Fortran, MPI routines are subroutines, and you invoke them with the call statement.
  • all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. periodt.

😭 ERRORS 😭

when an error happens inside an MPI function, the current MPI error handler gets called to deal with it. by default? that handler aborts the whole MPI job. πŸ’€ dramatic but true.

you can swap it out with MPI_Errhandler_set, and you can use the predefined handler MPI_ERRORS_RETURN if you'd rather have error values handed back to you (works in C and Fortran; it's less useful with the C++ MPI bindings β€” for C++, use the predefined MPI::ERRORS_THROW_EXCEPTIONS if you actually need to recover the error value). and ngl, MPI does not guarantee that an MPI program can keep going after an error. that's not a vibe, that's just the rules.

now, error-value housekeeping:

  • all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value. C routines return it as the function's value; Fortran routines put it in that last argument.
  • the C++ bindings for MPI do not return error values. instead, error values are communicated by throwing exceptions of type MPI::Exception β€” but not by default. exceptions are only thrown if the error value is not MPI::SUCCESS.
  • > heads up bestie: if MPI::ERRORS_RETURN is set in C++, MPI functions will return on an error, but there is literally no way to recover what the actual error value was. gone. lost to the void. πŸ™ˆ

and here are the actual error codes:

  • MPI_SUCCESS β€” no error; the MPI routine completed successfully. slay. ✨
  • MPI_ERR_COMM β€” invalid communicator. a common way to land here is using a null communicator in a call β€” which isn't even allowed in MPI_Comm_rank, so don't try it.
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and isn't identified by a specific error class. typically this is a NULL pointer or other such error.

🌈 SEE ALSO 🌈

go read those too, they're the rest of the friend group. 🫢


πŸ’œ MORE INFORMATION πŸ’œ

want the deep lore? the official MPI Forum web site has the full text of both the MPI-1 and MPI-2 standards. those documents contain detailed information about every MPI function β€” most of which is not duplicated in these man pages, so if you're a completionist, that's your stop:

http://www.mpi-forum.org/

πŸ‘‘ LOCATION πŸ‘‘

cseterr.c


and that's the whole page, bestie. this one shipped as part of LAM/MPI 7.1.4, dated 6/24/2006 β€” vintage, honestly. mwah. πŸ’…βœ¨