|
| 1 | +# Name |
| 2 | + |
| 3 | +`MPI_Graph_create` - Makes a new communicator to which topology |
| 4 | +information has been attached. |
| 5 | + |
| 6 | +# Syntax |
| 7 | + |
| 8 | +## C Syntax |
| 9 | + |
| 10 | +```c |
| 11 | +#include <mpi.h> |
| 12 | + |
| 13 | +int MPI_Graph_create(MPI_Comm comm_old, int nnodes, const int index[], |
| 14 | + const int edges[], int reorder, MPI_Comm *comm_graph) |
| 15 | +``` |
| 16 | +
|
| 17 | +## Fortran Syntax |
| 18 | +
|
| 19 | +```fortran |
| 20 | +USE MPI |
| 21 | +! or the older form: INCLUDE 'mpif.h' |
| 22 | +
|
| 23 | +MPI_GRAPH_CREATE(COMM_OLD, NNODES, INDEX, EDGES, REORDER, |
| 24 | + COMM_GRAPH, IERROR) |
| 25 | + INTEGER COMM_OLD, NNODES, INDEX(*), EDGES(*) |
| 26 | + INTEGER COMM_GRAPH, IERROR |
| 27 | + LOGICAL REORDER |
| 28 | +``` |
| 29 | + |
| 30 | +## Fortran 2008 Syntax |
| 31 | + |
| 32 | +```fortran |
| 33 | +USE mpi_f08 |
| 34 | +
|
| 35 | +MPI_Graph_create(comm_old, nnodes, index, edges, reorder, comm_graph, |
| 36 | + ierror) |
| 37 | + TYPE(MPI_Comm), INTENT(IN) :: comm_old |
| 38 | + INTEGER, INTENT(IN) :: nnodes, index(nnodes), edges(*) |
| 39 | + LOGICAL, INTENT(IN) :: reorder |
| 40 | + TYPE(MPI_Comm), INTENT(OUT) :: comm_graph |
| 41 | + INTEGER, OPTIONAL, INTENT(OUT) :: ierror |
| 42 | +``` |
| 43 | + |
| 44 | + |
| 45 | +# Input Parameters |
| 46 | + |
| 47 | +* `comm_old` : Input communicator without topology (handle). |
| 48 | +* `nnodes` : Number of nodes in graph (integer). |
| 49 | +* `index` : Array of integers describing node degrees (see below). |
| 50 | +* `edges` : Array of integers describing graph edges (see below). |
| 51 | +* `reorder` : Ranking may be reordered (true) or not (false) (logical). |
| 52 | + |
| 53 | +# Output Parameters |
| 54 | + |
| 55 | +* `comm_graph` : Communicator with graph topology added (handle). |
| 56 | +* `IERROR` : Fortran only: Error status (integer). |
| 57 | + |
| 58 | +# Description |
| 59 | + |
| 60 | +`MPI_Graph_create` returns a handle to a new communicator to which the |
| 61 | +graph topology information is attached. If `reorder` = false then the rank |
| 62 | +of each process in the new group is identical to its rank in the old |
| 63 | +group. Otherwise, the function may `reorder` the processes. If the size, |
| 64 | +`nnodes`, of the graph is smaller than the size of the group of `comm_old`, |
| 65 | +then some processes are returned `MPI_COMM_NULL`, in analogy to |
| 66 | +`MPI_Cart_create` and `MPI_Comm_split`. The call is erroneous if it |
| 67 | +specifies a graph that is larger than the group size of the input |
| 68 | +communicator. |
| 69 | + |
| 70 | +The three parameters `nnodes`, `index`, and `edges` define the graph |
| 71 | +structure. `nnodes` is the number of nodes of the graph. The nodes are |
| 72 | +numbered from 0 to `nnodes`-1. The ith entry of array `index` stores the |
| 73 | +total number of neighbors of the first i graph nodes. The lists of |
| 74 | +neighbors of nodes 0, 1, ..., `nnodes`-1 are stored in consecutive |
| 75 | +locations in array `edges`. The array `edges` is a flattened representation |
| 76 | +of the edge lists. The total number of entries in `index` is `nnodes` and |
| 77 | +the total number of entries in `edges` is equal to the number of graph |
| 78 | +`edges`. |
| 79 | + |
| 80 | +The definitions of the arguments `nnodes`, `index`, and `edges` are |
| 81 | +illustrated with the following simple example. |
| 82 | + |
| 83 | +Example: Assume there are four processes 0, 1, 2, 3 with the |
| 84 | +following adjacency matrix: |
| 85 | + |
| 86 | +| Process | Neighbors | |
| 87 | +| ------- | --------- | |
| 88 | +| 0 | 1, 3 | |
| 89 | +| 1 | 0 | |
| 90 | +| 2 | 3 | |
| 91 | +| 3 | 0, 2 | |
| 92 | + |
| 93 | +Then, the input arguments are: |
| 94 | +* `nodes` = 4 |
| 95 | +* `index` = 2, 3, 4, 6 |
| 96 | +* `edges` = 1, 3, 0, 3, 0, 2 |
| 97 | + |
| 98 | +Thus, in C, `index[0]` is the degree of `node` zero, and `index[i]` - |
| 99 | +`index[i-1]` is the degree of `node` i, i=1, . . . , nnodes-1; the list of |
| 100 | +neighbors of node zero is stored in `edges[j]`, for 0 <= j <= |
| 101 | +`index[0] - 1` and the list of neighbors of `node` i, i > 0 , is stored |
| 102 | +in `edges[j]`, `index[i-1]` <= j <= `index[i] - 1`. |
| 103 | + |
| 104 | +In Fortran, `index(1)` is the degree of `node` zero, and `index(i+1)` - |
| 105 | +`index(i)` is the degree of `node` i, i=1, . . . , nnodes-1; the list of |
| 106 | +neighbors of `node` zero is stored in `edges(j)`, for 1 <= j <= `index(1)` |
| 107 | +and the list of neighbors of `node` i, i > 0, is stored in `edges(j)`, |
| 108 | +`index(i) + 1` <= j <= `index(i + 1)`. |
| 109 | + |
| 110 | +# Errors |
| 111 | + |
| 112 | +Almost all MPI routines return an error value; C routines as the value |
| 113 | +of the function and Fortran routines in the last argument. |
| 114 | + |
| 115 | +Before the error value is returned, the current MPI error handler is |
| 116 | +called. By default, this error handler aborts the MPI job, except for |
| 117 | +I/O function errors. The error handler may be changed with |
| 118 | +`MPI_Comm_set_errhandler`; the predefined error handler `MPI_ERRORS_RETURN` |
| 119 | +may be used to cause error values to be returned. Note that MPI does not |
| 120 | +guarantee that an MPI program can continue past an error. |
| 121 | + |
| 122 | +# See Also |
| 123 | + |
| 124 | +[`MPI_Graph_get`(3)](MPI_Graph_get.html) |
| 125 | +[`MPI_Graphdims_get`(3)](MPI_Graphdims_get.html) |
0 commit comments