MPI_DIST_GRAPH_CREATE_ADJACENT(3)
π« MPI_Dist_graph_create_adjacent(3) β Open MPI edition, bestie π«
okay so this one is from the Open MPI manual, page MPI_DIST_GRAPH_CREATE_ADJACENT(3), and it's literally the glow-up your communicator deserves. Sit down, grab a lil snack π, and let's get into it.
β¨ NAME β¨
MPI_Dist_graph_create_adjacent β makes a brand-new communicator with topology info attached to it, like giving your comm a whole personality π
πΈ 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
π«Ά yes, it's ndegree in that last one, not a typo I made, that's just how it's written. copy it exactly if you're pasting, iykyk.
π¦ INPUT PARAMETERS π¦
comm_oldβ your input communicator, and it has no topology yet (it's a handle). think of it as the pre-glow-up era πindegreeβ the size of thesourcesandsourceweightsarrays. it's a non-negative integer, so no negatives bestie πsourcesβ the ranks of the processes that send to you, i.e. the processes for which the calling process is a destination. it's an array of non-negative integers πsourceweightsβ the weights of the edges coming into the calling process. array of non-negative integers β¨outdegreeβ the size of thedestinationsanddestweightsarrays (non-negative integer again, consistency queen π)destinationsβ the ranks of the processes you send to, i.e. processes for which the calling process is a source. array of non-negative integers π«destweightsβ the weights of the edges going out of the calling process. array of non-negative integers πinfoβ hints about optimization and how to interpret the weights (handle) π§reorderβ whether the ranking may be reordered (true) or not (false). it's a logical, so pick a side π¦
π OUTPUT PARAMETERS π
comm_dist_graphβ the new communicator, now with distributed graph topology added (handle). main character energy, honestly πierrorβ Fortran only: the error status (integer) π
π DESCRIPTION π
okay so MPI_Dist_graph_create_adjacent creates a new communicator called comm_dist_graph, gives it distributed graph topology, and hands you back a handle to it. the number of processes in comm_dist_graph is identical to the number of processes in comm_old β no surprise guests, no one leaving the group chat π«Ά
each process passes all the info about its incoming and outgoing edges in this virtual distributed graph topology. and here's the part where you gotta be careful: the calling processes must ensure that each edge of the graph is described in the source process and in the destination process with the same weights. like, both sides gotta agree, no cap π
if there are multiple edges for a given (source,dest) pair, then the sequence of the weights of those edges doesn't matter β order is not the vibe, the set is. the complete communication topology is the combination of all edges shown in the sources arrays of all processes in comm_old, and that combination must be identical to the combination of all edges shown in the destinations arrays. fr fr, they have to match π₯
source and destination ranks must be process ranks of comm_old. this is what allows a fully distributed specification of the communication graph β everyone brings their own piece, potluck style π
isolated processes are totally allowed! those are processes with no outgoing or incoming edges β meaning processes that specified indegree and outdegree as zero and therefore don't show up as a source or destination rank anywhere in the graph spec. they can just chill πΈ
and the call to MPI_Dist_graph_create_adjacent is collective. everyone's in it together π
βοΈ WEIGHTS βοΈ
weights are specified as non-negative integers, and they can be used to influence the process remapping strategy plus 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 π«
however (and this is the important bit), 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 β it's all or nothing, group decision π«Ά
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. no stress π
note that MPI_UNWEIGHTED and MPI_WEIGHTS_EMPTY are not special weight values β rather they are special values for the total array argument. and 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 for the full tea β
π 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 fatal π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. the chill one π«Ά
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, bestie, it might be over π
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_createMPI_Dist_graph_neighborsMPI_Dist_graph_neighbors_count
the whole friend group, honestly β go read those next π
π COPYRIGHT π
2003-2026, The Open MPI Community
and that's the whole page, bestie! π¦ ngl, this one's a lot, but you ate that. this lil sign-off came to you courtesy of the Open MPI crew, copyright 2003-2026, The Open MPI Community, dated Sep 11, 2026 β slay, periodt π
β¨
π¦ 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