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 the sources and sourceweights arrays, and it's a non-negative integer (yes, non-negative, don't try it πŸ”₯)
  • maxoutdegree β€” the size of the destinations and destweights arrays, 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 if MPI_Abort was called on that communicator. if called on a window or file, it acts as if MPI_Abort was 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_errhandler then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_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 πŸ’–

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