1 | .\"Copyright 2006-2008 Sun Microsystems, Inc. |
---|
2 | .\" Copyright (c) 1996 Thinking Machines Corporation |
---|
3 | .TH MPI_Graph_neighbors 3 "Dec 08, 2009" "1.4" "Open MPI" |
---|
4 | .SH NAME |
---|
5 | \fBMPI_Graph_neighbors \fP \- Returns the neighbors of a node associated with a graph topology. |
---|
6 | |
---|
7 | .SH SYNTAX |
---|
8 | .ft R |
---|
9 | .SH C Syntax |
---|
10 | .nf |
---|
11 | #include <mpi.h> |
---|
12 | int MPI_Graph_neighbors(MPI_Comm \fIcomm\fP, int\fI rank\fP, int\fI maxneighbors\fP, |
---|
13 | int\fI *neighbors\fP) |
---|
14 | |
---|
15 | .SH Fortran Syntax |
---|
16 | .nf |
---|
17 | INCLUDE 'mpif.h' |
---|
18 | MPI_GRAPH_NEIGHBORS(\fICOMM, RANK, MAXNEIGHBORS, NEIGHBORS, IERROR\fP) |
---|
19 | INTEGER \fICOMM, RANK, MAXNEIGHBORS, NEIGHBORS(*), IERROR\fP |
---|
20 | |
---|
21 | .SH C++ Syntax |
---|
22 | .nf |
---|
23 | #include <mpi.h> |
---|
24 | void Graphcomm::Get_neighbors(int \fIrank\fP, int \fImaxneighbors\fP, |
---|
25 | int \fIneighbors\fP[]) const |
---|
26 | |
---|
27 | .SH INPUT PARAMETERS |
---|
28 | .ft R |
---|
29 | .TP 1i |
---|
30 | comm |
---|
31 | Communicator with graph topology (handle). |
---|
32 | .TP 1i |
---|
33 | rank |
---|
34 | Rank of process in group of comm (integer). |
---|
35 | .TP 1i |
---|
36 | maxneighbors |
---|
37 | Size of array neighbors (integer). |
---|
38 | |
---|
39 | .SH OUTPUT PARAMETERS |
---|
40 | .ft R |
---|
41 | .TP 1i |
---|
42 | neighbors |
---|
43 | Ranks of processes that are neighbors to specified process (array of integers). |
---|
44 | .ft R |
---|
45 | .TP 1i |
---|
46 | IERROR |
---|
47 | Fortran only: Error status (integer). |
---|
48 | |
---|
49 | .SH DESCRIPTION |
---|
50 | .ft R |
---|
51 | \fBExample:\fP Suppose that comm is a communicator with a shuffle-exchange |
---|
52 | topology. The group has 2n members. Each process is labeled by a(1),\ ..., a(n) with a(i) E{0,1}, and has three neighbors: exchange (a(1),\ ..., a(n) = a(1),\ ..., a(n-1), a(n) (a = 1 - a), shuffle (a(1),\ ..., a(n)) = a(2),\ ..., a(n), a(1), and unshuffle (a(1),\ ..., a(n)) = a(n), a(1),\ ..., a(n-1). The graph adjacency list is illustrated below for n=3. |
---|
53 | .sp |
---|
54 | .nf |
---|
55 | exchange shuffle unshuffle |
---|
56 | node neighbors(1) neighbors(2) neighbors(3) |
---|
57 | 0(000) 1 0 0 |
---|
58 | 1(001) 0 2 4 |
---|
59 | 2(010) 3 4 1 |
---|
60 | 3(011) 2 6 5 |
---|
61 | 4(100) 5 1 2 |
---|
62 | 5(101) 4 3 6 |
---|
63 | 6(110) 7 5 3 |
---|
64 | 7(111) 6 7 7 |
---|
65 | .fi |
---|
66 | .sp |
---|
67 | Suppose that the communicator comm has this topology associated with it. The following code fragment cycles through the three types of neighbors and performs an appropriate permutation for each. |
---|
68 | .sp |
---|
69 | .nf |
---|
70 | C assume: each process has stored a real number A. |
---|
71 | C extract neighborhood information |
---|
72 | CALL MPI_COMM_RANK(comm, myrank, ierr) |
---|
73 | CALL MPI_GRAPH_NEIGHBORS(comm, myrank, 3, neighbors, ierr) |
---|
74 | C perform exchange permutation |
---|
75 | CALL MPI_SENDRECV_REPLACE(A, 1, MPI_REAL, neighbors(1), 0, |
---|
76 | + neighbors(1), 0, comm, status, ierr) |
---|
77 | C perform shuffle permutation |
---|
78 | CALL MPI_SENDRECV_REPLACE(A, 1, MPI_REAL, neighbors(2), 0, |
---|
79 | + neighbors(3), 0, comm, status, ierr) |
---|
80 | C perform unshuffle permutation |
---|
81 | CALL MPI_SENDRECV_REPLACE(A, 1, MPI_REAL, neighbors(3), 0, |
---|
82 | + neighbors(2), 0, comm, status, ierr) |
---|
83 | |
---|
84 | .SH ERRORS |
---|
85 | Almost all MPI routines return an error value; C routines as the value of the function and Fortran routines in the last argument. C++ functions do not return errors. If the default error handler is set to MPI::ERRORS_THROW_EXCEPTIONS, then on error the C++ exception mechanism will be used to throw an MPI:Exception object. |
---|
86 | .sp |
---|
87 | Before the error value is returned, the current MPI error handler is |
---|
88 | called. By default, this error handler aborts the MPI job, except for I/O function errors. The error handler may be changed with MPI_Comm_set_errhandler; the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error. |
---|
89 | |
---|
90 | .SH SEE ALSO |
---|
91 | .ft R |
---|
92 | .sp |
---|
93 | MPI_Graph_neighbors_count |
---|
94 | |
---|