MPI_DIST_GRAPH_CREATE(3)
π MPI_Dist_graph_create π
okay bestie, we're in the Open MPI manual, page MPI_DIST_GRAPH_CREATE(3), and this one is a whole vibe β it's the function that makes you a brand new communicator with topology info attached. yes ma'am, a custom communication graph. let's get into it π¦
β¨ 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
π 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, and it has no topology attached (it's a handle, bestie). πΈnβ the number of source nodes this process is gonna specify edges for. non-negative integer, no negativity allowed πsourcesβ array holding thosensource nodes that this process specifies edges for (array of non-negative integers).degreesβ array telling you how many destinations each source node in the sources array gets (array of non-negative integers). it's giving β¨per-source destination countβ¨destinationsβ the actual destination nodes for the source nodes in that source node array (array of non-negative integers).weightsβ weights for the source-to-destination edges (array of non-negative integers). yes queen, every edge can carry a weight βοΈinfoβ hints about optimization and how to interpret the weights (handle).reorderβ ranking may be reordered (true) or not (false) (logical). the classic "can you shuffle the seats" question πͺ
π OUTPUT PARAMETERS π
comm_dist_graphβ the new communicator, now with distributed graph topology added (handle). iconic, honestly πierrorβ Fortran only: the error status (integer).
heads up bestie: ierror is Fortran-only, don't come looking for it in C π
π¦ DESCRIPTION π¦
so MPI_Dist_graph_create creates a new communicator comm_dist_graph with distributed graph topology 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 β same squad, new fit π
concretely, each process calls the constructor with a set of directed (source,destination) communication edges, as described 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, 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]. the weight of this edge is stored in weights[degrees[0]+β¦+degrees[i-1]+j].
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 signicant. similarly, different processes may specify edges with the same source and destination nodes. source and destination nodes must be process ranks of comm_old. different processes may specify different numbers of source and destination nodes, as well as different source-to-destination edges. this allows a fully distributed specification of the communication graph β everyone brings their own edges to the potluck π
isolated processes are allowed. that means processes with no outgoing or incoming edges, i.e., processes that do not occur as a source or destination node in the graph specification. no edge, no problem, you still get to sit with us π«Ά
the call to MPI_Dist_graph_create is collective. everybody in, or nobody in, periodt.
if reorder = false, all processes will have the same rank in comm_dist_graph as in comm_old. but 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
βοΈ WEIGHTS βοΈ
okay so weights: they're 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. π₯
but ngl, the exact meaning of edge weights is not specified by the MPI standard and is left to the implementation. so it's a hint, not a promise, 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. and it is erroneous to supply MPI_UNWEIGHTED for some but not all processes of comm_old β all or nothing, diva rules π
if the graph is weighted but n = 0, then MPI_WEIGHTS_EMPTY or any arbitrary array may be passed to weights.
note thatMPI_UNWEIGHTEDandMPI_WEIGHTS_EMPTYare not special weight values β rather, they are special values for the total array argument. in Fortran,MPI_UNWEIGHTEDandMPI_WEIGHTS_EMPTYare objects likeMPI_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. 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. dramatic, but make it intentional π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.MPI_ERRORS_RETURNβ returns an error code to the application.
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, no promises, bestie. π
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 πβ¨ this was MPI_DIST_GRAPH_CREATE(3) from the Open MPI crew, dated Sep 10, 2026 β go build yourself a little graph and slay ππ¦πΈ
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms