MPI_DIST_GRAPH_CREATE_ADJACENT(3)

πŸ’« MPI_DIST_GRAPH_CREATE_ADJACENT(3) πŸ’«

okay bestie, gather round, because this is the Open MPI manual page for MPI_Dist_graph_create_adjacent and it is lowkey iconic. it's the move you make when you want a new communicator that already knows the shape of your communication graph. no cap. let's get into it 🫢✨


🌸 NAME 🌸

MPI_Dist_graph_create_adjacent β€” makes a new communicator to which topology information has been attached.


✨ SYNTAX ✨

πŸ“ C Syntax

#include <mpi.h>

int MPI_Dist_graph_create_adjacent(MPI_Comm comm_old, int indegree, const int sources[],
     const int sourceweights[], int outdegree, const int destinations[], const int destweights[],
        MPI_Info info, int reorder, MPI_Comm *comm_dist_graph)

πŸ“ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_DIST_GRAPH_CREATE_ADJACENT(COMM_OLD, INDEGREE, SOURCES, SOURCEWEIGHTS, OUTDEGREE,
                DESTINATIONS, DESTWEIGHTS, INFO, REORDER, COMM_DIST_GRAPH, IERROR)
     INTEGER COMM_OLD, INDEGREE, SOURCES(*), SOURCEWEIGHTS(*), OUTDEGREE, DESTINATIONS(*), DESTWEIGHTS(*), INFO
     INTEGER COMM_DIST_GRAPH, IERROR
     LOGICAL REORDER

πŸ“ Fortran 2008 Syntax

USE mpi_f08
MPI_Dist_Graph_create_adjacent(comm_old, ndegree, sources, sourceweights,
             outdegree, destinations, destweights, info, reorder,
             comm_dist_graph, ierror)
     TYPE(MPI_Comm), INTENT(IN) :: comm_old
     INTEGER, INTENT(IN) :: indegree, sources(indegree), outdegree, destinations(outdegree)
     INTEGER, INTENT(IN) :: sourceweights(*), destweights(*)
     TYPE(MPI_Info), INTENT(IN) :: info
     LOGICAL, INTENT(IN) :: reorder
     TYPE(MPI_Comm), INTENT(OUT) :: comm_dist_graph
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror
bestie i need you to notice that the Fortran 2008 line says ndegree while everything else says indegree. that's not me being chaotic, that's literally what the page says. copy it exactly, okay? πŸ’€

πŸŽ€ INPUT PARAMETERS πŸŽ€

  • comm_old β€” the input communicator, and it has no topology yet (handle).
  • indegree β€” the size of the sources and sourceweights arrays (non-negative integer).
  • sources β€” the ranks of the processes that this calling process is a destination for (array of non-negative integers). like, these are the people sending to you πŸ’Œ
  • sourceweights β€” the weights of the edges coming into the calling process (array of non-negative integers).
  • outdegree β€” the size of the destinations and destweights arrays (non-negative integer).
  • destinations β€” the ranks of the processes that this calling process is a source for (array of non-negative integers). these are the people you're sending to πŸ“€
  • destweights β€” the weights of the edges going out of the calling process (array of non-negative integers).
  • info β€” hints about optimization and about how to interpret the weights (handle).
  • reorder β€” whether the ranking may be reordered: true means yes, false means absolutely not (logical).

πŸ‘‘ OUTPUT PARAMETERS πŸ‘‘

  • comm_dist_graph β€” the new communicator, now with distributed graph topology added (handle). queen πŸ’…
  • ierror β€” Fortran only: error status (integer).

🌈 DESCRIPTION 🌈

So MPI_Dist_graph_create_adjacent makes a fresh communicator, comm_dist_graph, with distributed graph topology on it, and hands you back a handle to that new communicator. the number of processes in comm_dist_graph is identical to the number of processes in comm_old β€” we are not adding or removing anyone, periodt.

here's the vibe: every single process passes in all the info about its own incoming and outgoing edges in the virtual distributed graph topology. the calling processes have to make sure that every edge of the graph is described both in the source process and in the destination process with the same weights. if there happen to be multiple edges for a given (source,dest) pair, then the sequence of the weights of those edges doesn't matter β€” order is not the moment.

the complete communication topology is the combination of all edges shown in the sources arrays of all processes in comm_old, and that combination has to be identical to the combination of all edges shown in the destinations arrays. source and destination ranks must be process ranks of comm_old. this is what lets you do a fully distributed specification of the communication graph β€” everyone brings their own piece, no central authority needed πŸ¦‹

also!! isolated processes are allowed β€” that means processes with no outgoing or incoming edges, i.e. processes that specified both indegree and outdegree as zero and therefore never show up as a source or destination rank in the graph spec. they're just vibing. no edges, no problem.

and the call to MPI_Dist_graph_create_adjacent is collective. everyone's in it together, bestie.


πŸ’– WEIGHTS πŸ’–

Weights are specified as non-negative integers, and you can use them to influence the process remapping strategy and other internal MPI optimizations. for instance, approximate count arguments of later communication calls along specific edges could be used as their edge weights. multiplicity of edges can likewise indicate more intense communication between pairs of processes. highkey useful.

but β€” the exact meaning of edge weights is not specified by the MPI standard. it's left entirely to the implementation. so don't go making assumptions, okay? πŸ™ˆ

An application can supply the special value MPI_UNWEIGHTED for the weight array to indicate that all edges have the same (effectively no) weight.

⚠️ it is erroneous to supply MPI_UNWEIGHTED for some but not all processes of comm_old. all or nothing, bestie, that's the rule.

If the graph is weighted but indegree or outdegree is zero, then MPI_WEIGHTS_EMPTY or any arbitrary array may be passed to sourceweights or destweights respectively.

Note that MPI_UNWEIGHTED and MPI_WEIGHTS_EMPTY are not special weight values β€” rather, they are special values for the total array argument.

In Fortran, MPI_UNWEIGHTED and MPI_WEIGHTS_EMPTY are objects like MPI_BOTTOM (not usable for initialization or assignment).

See MPI-3 section 2.5.4. 🧚


πŸ’€ ERRORS πŸ’€

Almost all MPI routines return an error value β€” C routines as the return result of the function, and Fortran routines in the last argument.

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. That 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
  • an 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.

πŸ”₯ the three predefined error handlers Open MPI ships with

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. dramatic and final, honestly.
  • 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.
  • MPI_ERRORS_RETURN β€” returns an error code to the application.

πŸ› οΈ or roll your own, main character energy

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 soft launch, that's just how it is 😭

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_create
  • MPI_Dist_graph_neighbors
  • MPI_Dist_graph_neighbors_count

2003-2026, The Open MPI Community


okay that's the whole page!! you're gonna go build a distributed graph and it's going to be gorgeous 🌈✨

this lil tour was brought to you by the Open MPI crew, page dated Sep 10, 2026 β€” go slay some topology, bestie πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from