MPI_GRAPH_CREATE(3)
π MPI_Graph_create π
okay bestie, welcome to the Open MPI manual page for MPI_GRAPH_CREATE(3) β the one that makes a new communicator with topology info attached. we're getting graph-y today, and honestly? iconic. π¦β¨
β¨ SYNTAX β¨
π» C Syntax π»
#include <mpi.h>
int MPI_Graph_create(MPI_Comm comm_old, int nnodes, const int index[],
const int edges[], int reorder, MPI_Comm *comm_graph)
π§ Fortran Syntax π§
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_GRAPH_CREATE(COMM_OLD, NNODES, INDEX, EDGES, REORDER,
COMM_GRAPH, IERROR)
INTEGER COMM_OLD, NNODES, INDEX(*), EDGES(*)
INTEGER COMM_GRAPH, IERROR
LOGICAL REORDER
π Fortran 2008 Syntax π
USE mpi_f08
MPI_Graph_create(comm_old, nnodes, index, edges, reorder, comm_graph,
ierror)
TYPE(MPI_Comm), INTENT(IN) :: comm_old
INTEGER, INTENT(IN) :: nnodes, index(nnodes), edges(*)
LOGICAL, INTENT(IN) :: reorder
TYPE(MPI_Comm), INTENT(OUT) :: comm_graph
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
πΈ INPUT PARAMETERS πΈ
comm_oldβ the input communicator, with no topology yet (handle). it's giving blank canvas. πnnodesβ number of nodes in the graph (integer).indexβ array of integers describing node degrees (see below). the degree lore is real. πedgesβ array of integers describing graph edges (see below).reorderβ ranking may be reordered (true) or not (false) (logical). yes bestie, you get to choose.
π OUTPUT PARAMETERS π
comm_graphβ communicator with graph topology added (handle). slay, now it has structure.ierrorβ Fortran only: error status (integer).
π¦ DESCRIPTION π¦
MPI_Graph_create returns a handle to a new communicator to which the graph topology information is attached. if reorder = false then the rank of each process in the new group is identical to its rank in the old group. otherwise, the function may reorder the processes. if the size, nnodes, of the graph is smaller than the size of the group of comm_old, then some processes are returned MPI_COMM_NULL, in analogy to MPI_Cart_create and MPI_Comm_split. the call is erroneous if it specifies a graph that is larger than the group size of the input communicator. no cap, that's a hard no. π
the three parameters nnodes, index, and edges define the graph structure. nnodes is the number of nodes of the graph. the nodes are numbered from 0 to nnodes-1. the ith entry of array index stores the total number of neighbors of the first i graph nodes. the lists of neighbors of nodes 0, 1, β¦, nnodes-1 are stored in consecutive locations in array edges. the array edges is a flattened representation of the edge lists. the total number of entries in index is nnodes and the total number of entries in edges is equal to the number of graph edges. periodt. π
the definitions of the arguments nnodes, index, and edges are illustrated with the following simple example.
Example: assume there are four processes 0, 1, 2, 3 with the following adjacency matrix:
Process Neighbors
------- ---------
0 1, 3
1 0
2 3
3 0, 2
then, the input arguments are:
nodes = 4index = 2, 3, 4, 6edges = 1, 3, 0, 3, 0, 2
thus, in C, index[0] is the degree of node zero, and index[i] - index[i-1] is the degree of node i, i=1, β¦ , nnodes-1; the list of neighbors of node zero is stored in edges[j], for 0 <= j <= index[0] - 1 and the list of neighbors of node i, i > 0 , is stored in edges[j], index[i-1] <= j <= index[i] - 1. the way that indexing lines up? highkey satisfying. π«Ά
in Fortran, index(1) is the degree of node zero, and index(i+1) - index(i) is the degree of node i, i=1, β¦ , nnodes-1; the list of neighbors of node zero is stored in edges(j), for 1 <= j <= index(1) and the list of neighbors of node i, i > 0, is stored in edges(j), index(i) + 1 <= j <= index(i + 1). see, Fortran just starts counting at 1. it's a lifestyle. π
π 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? yes. effective? also yes.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.
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. so likeβ¦ don't count on it, 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_Graph_get
π COPYRIGHT π
2003-2026, The Open MPI Community
source/version + date check, bestie: this was the Open MPI manual page MPI_GRAPH_CREATE(3), dated Sep 11, 2026 β go build an iconic graph and text me later π
ππ
π¦ 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