MPI_DIST_GRAPH_NEIGHBORS(3)
π MPI_Dist_graph_neighbors(3) π
okay so this is the Open MPI page for MPI_Dist_graph_neighbors, and bestie, it's literally the "who's my neighbor" call for distributed graph topologies. main character energy fr fr π
It returns the neighbors of the calling process in a distributed graph topology. that's the whole vibe check. β¨
π¦ SYNTAX π¦
πΈ C Syntax πΈ
#include <mpi.h>
int MPI_Dist_graph_neighbors(MPI_Comm comm, int maxindegree, int sources[], int sourceweights[],
int maxoutdegree, int destinations[], int destweights[])
π Fortran Syntax π
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_DIST_GRAPH_NEIGHBORS(COMM, MAXINDEGREE, SOURCES, SOURCEWEIGHTS,
MAXOUTDEGREE, DESTINATIONS, DESTWEIGHTS, IERROR)
INTEGER COMM, MAXINDEGREE, SOURCES(*), SOURCEWEIGHTS(*), MAXOUTDEGREE,
DESTINATIONS(*), DESTWEIGHTS(*), IERROR
π Fortran 2008 Syntax π
USE mpi_f08
MPI_Dist_Graph_neighbors(comm, maxindegree, sources, sourceweights,
maxoutdegree, destinations, destweights, ierror)
TYPE(MPI_Comm), INTENT(IN) :: comm
INTEGER, INTENT(IN) :: maxindegree, maxoutdegree
INTEGER, INTENT(OUT) :: sources(maxindegree), destinations(maxoutdegree)
INTEGER :: sourceweights(*), destweights(*)
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT PARAMETERS π
(the stuff you hand over, no takebacks)
commβ the communicator rockin' the distributed graph topology, it's a handle π«Άmaxindegreeβ the size of thesourcesandsourceweightsarrays, and it's a non-negative integer (yes, non-negative, don't try it π₯)maxoutdegreeβ the size of thedestinationsanddestweightsarrays, also a non-negative integer, also keeping it non-negative π
β¨ OUTPUT PARAMETERS β¨
(the stuff that comes back out, slay)
sourcesβ the processes for which the calling process is a destination, array of non-negative integers πsourceweightsβ the weights of the edges into the calling process, array of non-negative integers βdestinationsβ the processes for which the calling process is a source, array of non-negative integers πdestweightsβ the weights of the edges out of the calling process, array of non-negative integers π¦ierrorβ Fortran only, the error status, it's an integer π
π DESCRIPTION π
okay so MPI_Dist_graph_neighbors returns the source and destination ranks in a distributed graph topology for the calling process. literally just "here's who's connected to me." π
this call will return up to maxindegree source ranks in the sources array, and up to maxoutdegree destination ranks in the destinations array. so like, fill up to that many, no cap.
if weights were specified at the time of the communicator's creation, then the associated weights come back in the sourceweights and destweights arrays. weights said at creation time stay said, periodt. β¨
and here's the iconic detail: if the communicator was created with MPI_Dist_graph_create_adjacent, then the order of the values in sources and destinations is identical to the input that was used by the process with the same rank in comm_old in the creation call. same order, same energy, iykyk π§
π ERRORS π
almost all MPI routines return an error value, bestie. C routines return it as the return result of the function, and Fortran routines put it in the last argument. that's the deal. π
before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. if no communication object is associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. π
when MPI_COMM_SELF is not 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. the initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. if no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions and the MPI_ERRORS_ABORT error handler is called for all other MPI functions. π
Open MPI includes three predefined error handlers that can be used, and they're giving very much a trio:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic but honest πMPI_ERRORS_ABORTβ an error handler that can be invoked on a communicator, window, file, or session. when called on a communicator, it acts as ifMPI_Abortwas called on that communicator. if 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 called on a session, it aborts only the local process. context-dependent icon behavior π₯MPI_ERRORS_RETURNβ returns an error code to the application. the chill one π«Ά
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. like, that's not a vibe, that's a real caveat. β οΈ
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.
π SEE ALSO π
MPI_Dist_graph_neighbors_countβ the count-y sibling, go read it too π
π COPYRIGHT π
the copyright is 2003-2026, The Open MPI Community. icon behavior.
and that's the whole page, bestie π β signed off with love from the Open MPI crew, dated Sep 11, 2026, MPI_DIST_GRAPH_NEIGHBORS(3) era. go be someone's neighbor. ππ¦
π¦ 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