MPI_DIST_GRAPH_CREATE(3)

πŸ’… MPI_Dist_graph_create β€” Open MPI, but make it a group chat πŸ’…

okay bestie, so this is the Open MPI manpage for MPI_Dist_graph_create, except now it's actually fun to read. we're gonna build a brand-new communicator with topology info glued onto it, and you're gonna slay it. periodt. πŸŽ€


✨ SYNTAX ✨

🌸 C Syntax

#include <mpi.h>

int MPI_Dist_graph_create(MPI_Comm comm_old, int n, const int sources[],
     const int degrees[], const int destinations[], const int weights[],
        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(COMM_OLD, N, SOURCES, DEGREES, DESTINATIONS, WEIGHTS,
                INFO, REORDER, COMM_DIST_GRAPH, IERROR)
     INTEGER COMM_OLD, N, SOURCES(*), DEGRES(*), WEIGHTS(*), INFO
     INTEGER COMM_DIST_GRAPH, IERROR
     LOGICAL   REORDER

(yes, DEGRES(*) β€” that's literally what the manpage says, character for character, don't come for me 😭 copy it exactly as-is.)

🧚 Fortran 2008 Syntax

USE mpi_f08
MPI_Dist_Graph_create(comm_old, n, sources, degrees, destinations, weights,
             info, reorder, comm_dist_graph, ierror)
     TYPE(MPI_Comm), INTENT(IN) :: comm_old
     INTEGER, INTENT(IN) :: n, sources(n), degrees(n), destinations(*)
     INTEGER, INTENT(IN) :: weights(*)
     TYPE(MPI_Info), INTENT(IN) :: info
     LOGICAL, INTENT(IN) :: reorder
     TYPE(MPI_Comm), INTENT(OUT) :: comm_dist_graph
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

🌈 INPUT PARAMETERS 🌈

  • comm_old β€” your input communicator, no topology attached yet. it's giving blank canvas (handle). 🎨
  • n β€” how many source nodes this process is out here specifying edges for. non-negative integer, no negativity allowed πŸ’…
  • sources β€” the array holding those n source nodes you're claiming edges for. array of non-negative integers. main character nodes energy πŸ‘‘
  • degrees β€” for each source node in the sources array, how many destinations it's got. array of non-negative integers.
  • destinations β€” the actual destination nodes belonging to those source nodes. array of non-negative integers. the "where we going bestie" list πŸ¦‹
  • weights β€” weights for the source β†’ destination edges. array of non-negative integers.
  • info β€” hints about optimization and how to interpret those weights (handle). iykyk ✨
  • reorder β€” can the ranking get reordered, true or false? (logical). it's literally just yes or no babes.

πŸ’– OUTPUT PARAMETERS πŸ’–

  • comm_dist_graph β€” the fresh new communicator with distributed graph topology added (handle). she's iconic, she's brand new πŸŽ€
  • ierror β€” Fortran only: error status (integer). the classic.

πŸ”₯ DESCRIPTION πŸ”₯

MPI_Dist_graph_create creates a new communicator comm_dist_graph with distributed graph topology and returns a handle to the new communicator. and the number of processes in comm_dist_graph? identical to the number of processes in comm_old. no cap, same headcount 🫢

so here's the vibe: each process calls the constructor with a set of directed (source,destination) communication edges, described down below. every process passes an array of n source nodes in the sources array. for each source node, a non-negative number of destination nodes is specified in the degrees array. the destination nodes are stored in the corresponding consecutive segment of the destinations array.

more precisely (and yes we're being precise, this is the whole point): if the i-th node in sources is s, this specifies degrees[i] edges (s,d) with d of the j-th such edge stored in destinations[degrees[0]+…+degrees[i-1]+j]. and the weight of this edge? stored in weights[degrees[0]+…+degrees[i-1]+j]. indexing math, but make it fashion πŸ’…

both the sources and the destinations arrays may contain the same node more than once, and the order in which nodes are listed as destinations or sources is not significant. similarly, different processes may specify edges with the same source and destination nodes. dupe edges? allowed. nobody's judging.

source and destination nodes must be process ranks of comm_old. that's a hard requirement bestie, not a suggestion ⚠️

different processes may specify different numbers of source and destination nodes, as well as different source to destination edges. this is what lets you do a fully distributed specification of the communication graph β€” everyone chips in their lil piece, collaborative queen behavior 🌸

isolated processes are allowed β€” that's processes with no outgoing or incoming edges, i.e. processes that do not occur as source or destination node in the graph specification. no edges, no problem, they're just vibing 🧘

the call to MPI_Dist_graph_create is collective. everybody in, together, no skipping 🫢

if reorder = false, all processes will have the same rank in comm_dist_graph as in comm_old. if reorder = true then the MPI library is free to remap to other processes (of comm_old) in order to improve communication on the edges of the communication graph.

the weight associated with each edge is a hint to the MPI library about the amount or intensity of communication on that edge, and may be used to compute a

(okay so the manpage literally cuts off right there mid-sentence 😭 that's exactly where the source text ends. i'm not making anything up to fill it in β€” what you see is what you get, fr fr.)


⭐ WEIGHTS ⭐

weights are specified as non-negative integers and can be used 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 β€” and this is important β€” the exact meaning of edge weights is not specified by the MPI standard and is left to the implementation. so don't go assuming, bestie πŸ™ˆ

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 in or all out, no halfway πŸ’€

if the graph is weighted but n = 0, then MPI_WEIGHTS_EMPTY or any arbitrary array may be passed to weights. freedom πŸ’…

note that MPI_UNWEIGHTED and MPI_WEIGHTS_EMPTY are not special weight values; rather they are special values for the total array argument. do not get it twisted.

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. classic.

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 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:

  • MPI_ERRORS_ARE_FATAL β€” Causes the program to abort all connected MPI processes. full shutdown, no survivors πŸ’€
  • 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, 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, aborts only the local process.
  • MPI_ERRORS_RETURN β€” Returns an error code to the application. she hands you the problem and lets you deal with it 🫢

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, at all. don't count on it 😭

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

2003-2026, The Open MPI Community


and that's the whole page bestie, you ate that πŸ“πŸ’œ β€” this lil rewrite was served to you by Open MPI (the MPI_DIST_GRAPH_CREATE(3) page, dated Sep 11, 2026). now go build that topology, you gorgeous distributed icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from