MPIL_Comm_gps(3)

πŸ’– MPIL_Comm_gps β€” LAM/MPI's little "hey bestie, where are you actually?" function πŸ’–

okay so. this page is from the LAM/MPI manual, section 3, and it's all about a function called MPIL_Comm_gps β€” a LAM/MPI-specific glow-up that hands you the GPS information (node + process, not latitude, sorry πŸ—ΊοΈ) of a given rank inside a communicator. let's get into it, bestie 🫢


✨ NAME ✨

MPIL_Comm_gps β€” the LAM/MPI-specific function that returns the GPS info of a given rank from a communicator. it's giving "who is this person and what machine are they on" πŸ’…


🌸 SYNOPSIS 🌸

#include <mpi.h>
int MPIL_Comm_gps(MPI_Comm comm, int rank, int *pnid,
                 int *ppid)

like, that's the whole vibe. include mpi.h, call it, get your answers πŸ’–


πŸŽ€ INPUT PARAMETERS πŸŽ€

  • comm β€” the communicator (a handle). it's the group chat you're asking about 🫢
  • rank β€” rank of the process you wanna query (an integer). who are we stalking bestie πŸ‘€

πŸ¦‹ OUTPUT PARAMETERS πŸ¦‹

  • pnid β€” the LAM node ID
  • ppid β€” the LAM process ID

these two are where the answer lands. no return-value drama, they just get filled in ✨


πŸ’… NOTES πŸ’…

so here's the tea β˜• in the LAM implementation of MPI, every communicator has an integer context ID attached to it, and that's how it synchronizes across different contexts. this ID is global to all the processes in the communicator's group, and it uniquely identifies that communicator for each process. and because of those properties, processes can safely exchange messages without other communicators' operations barging in and ruining the moment. no interference, periodt πŸ’…

the MPI standard doesn't give you any way to access or view this implementation-dependent synchronization, because communicators are opaque objects. and honestly? for normal MPI operations you don't need that access at all, bestie. BUT β€” and this is the plot twist β€” when you're debugging MPI applications, that whole opaque thing starts hindering your efforts 😭. this hits especially hard on fully observable systems like LAM, where you can monitor the full state of the processes and message queues, which includes the context ID (go look at mpitask (1) and mpimsg (1) πŸ‘‘).

here's the key shift: LAM supplementary functions do not operate with communicators and ranks β€” they work with nodes and process identifiers. MPIL_Comm_gps accepts the MPI values and returns the LAM values. it's basically a translator 🧚 and if you're dealing with an intercommunicator, the values returned are those of the process with the given rank in the remote group. noted πŸ“

this is a LAM/MPI-specific function and it's intended mainly for debugging. if you use it, use it together with the LAM_MPI C preprocessor macro, like this:
#if LAM_MPI
int nid, pid;
MPIL_Comm_gps(MPI_COMM_WORLD, 0, &nid, &pid);
#endif

🌈 NOTES FOR FORTRAN 🌈

all MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) have an additional argument ierr at the end of the argument list. ierr is an integer and it means 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. that's just how Fortran does πŸ’œ

also: all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. iconic, honestly ⭐


😭 ERRORS 😭

if an error occurs in an MPI function, the current MPI error handler gets called to deal with it. by default, that error handler aborts the MPI job β€” like, full dramatic exit πŸ’€. you can change the error handler with MPI_Errhandler_set; the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned (in C and Fortran; this error handler is less useful with the C++ MPI bindings. the predefined error handler MPI::ERRORS_THROW_EXCEPTIONS should be used in C++ if the error value needs to be recovered). and note: MPI does not guarantee that an MPI program can continue past an error. fr fr, that's real πŸ™ˆ

all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value; C routines as the value of the function, and Fortran routines in the 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.

and heads up: if the MPI::ERRORS_RETURN handler is set in C++, while MPI functions will return upon an error, there will be no way to recover what the actual error value was. tragic, lowkey 😭

  • MPI_SUCCESS β€” no error; the MPI routine completed successfully. slay ✨
  • MPI_ERR_COMM β€” invalid communicator. a common error is to use a null communicator in a call (not even allowed in MPI_Comm_rank). we don't do that here πŸ’…
  • MPI_ERR_RANK β€” invalid source or destination rank. ranks must be between zero and the size of the communicator minus one; ranks in a receive (MPI_Recv, MPI_Irecv, MPI_Sendrecv, etc.) may also be MPI_ANY_SOURCE.
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and is not identified by a specific error class. this is typically a NULL pointer or other such error.

πŸ‘‘ SEE ALSO πŸ‘‘

MPIL_Comm_id, MPIL_Type_id β€” go read these too, they're part of the same friend group 🫢


πŸ“ LOCATION πŸ“

mpil_id.c β€” that's where this lives, bestie πŸ“


and that's the whole page!! this was from the LAM/MPI 7.1.4 manual, dated 6/24/2006 β€” yeah she's vintage, but vintage is iconic, and she still knows exactly where every rank is hiding πŸ¦‹πŸ’– stay curious, query your communicators responsibly, and remember: opaque objects are just objects that haven't told you their business yet. mwah πŸ’…βœ¨