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 IDppidβ 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 inMPI_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 beMPI_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 π β¨
π¦ where this page comes from
- debian bookworm: lam-mpidoc 7.1.4-7
- debian trixie: lam-mpidoc 7.1.4-7.2
- ubuntu jammy: lam-mpidoc 7.1.4-7
- ubuntu noble: lam-mpidoc 7.1.4-7.1build2
- ubuntu questing: lam-mpidoc 7.1.4-8
- ubuntu resolute: lam-mpidoc 7.1.4-8build1
- ubuntu stonking: lam-mpidoc 7.1.4-8build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms