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 thosensource 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 π«Ά
ifreorder = false, all processes will have the same rank incomm_dist_graphas incomm_old. ifreorder = truethen the MPI library is free to remap to other processes (ofcomm_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 thatMPI_UNWEIGHTEDandMPI_WEIGHTS_EMPTYare 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 ifMPI_Abortwas called on that communicator. If called on a window or file, acts as ifMPI_Abortwas 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_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, 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_adjacentMPI_Dist_graph_neighborsMPI_Dist_graph_neighbors_count
π COPYRIGHT π
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
- 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