27 MPI::Cartcomm::Cartcomm(
const MPI_Comm& data) {
29 if (MPI::Is_initialized() && (data != MPI_COMM_NULL)) {
30 (void)MPI_Topo_test(data, &status) ;
31 if (status == MPI_CART)
34 mpi_comm = MPI_COMM_NULL;
46 MPI::Cartcomm::Dup()
const
49 (void)MPI_Comm_dup(mpi_comm, &newcomm);
58 MPI::Cartcomm::Get_dim()
const
61 (void)MPI_Cartdim_get(mpi_comm, &ndims);
66 MPI::Cartcomm::Get_topo(
int maxdims,
int dims[],
bool periods[],
69 int *int_periods =
new int [maxdims];
71 for (i=0; i<maxdims; i++) {
72 int_periods[i] = (int)periods[i];
74 (void)MPI_Cart_get(mpi_comm, maxdims, dims, int_periods, coords);
75 for (i=0; i<maxdims; i++) {
76 periods[i] = OPAL_INT_TO_BOOL(int_periods[i]);
78 delete [] int_periods;
82 MPI::Cartcomm::Get_cart_rank(
const int coords[])
const
85 (void)MPI_Cart_rank(mpi_comm, const_cast<int *>(coords), &rank);
90 MPI::Cartcomm::Get_coords(
int rank,
int maxdims,
int coords[])
const
92 (void)MPI_Cart_coords(mpi_comm, rank, maxdims, coords);
96 MPI::Cartcomm::Shift(
int direction,
int disp,
97 int &rank_source,
int &rank_dest)
const
99 (void)MPI_Cart_shift(mpi_comm, direction, disp, &rank_source, &rank_dest);
103 MPI::Cartcomm::Sub(
const bool remain_dims[])
const
106 MPI_Cartdim_get(mpi_comm, &ndims);
107 int* int_remain_dims =
new int[ndims];
108 for (
int i=0; i<ndims; i++) {
109 int_remain_dims[i] = (int)remain_dims[i];
112 (void)MPI_Cart_sub(mpi_comm, int_remain_dims, &newcomm);
113 delete [] int_remain_dims;
118 MPI::Cartcomm::Map(
int ndims,
const int dims[],
const bool periods[])
const
120 int *int_periods =
new int [ndims];
121 for (
int i=0; i<ndims; i++) {
122 int_periods[i] = (int) periods[i];
125 (void)MPI_Cart_map(mpi_comm, ndims, const_cast<int *>(dims), int_periods, &newrank);
126 delete [] int_periods;
131 inline MPI::Cartcomm&
132 MPI::Cartcomm::Clone()
const
135 (void)MPI_Comm_dup(mpi_comm, &newcomm);
136 MPI::Cartcomm* dup =
new MPI::Cartcomm(newcomm);
145 MPI::Graphcomm::Graphcomm(
const MPI_Comm& data) {
147 if (MPI::Is_initialized() && (data != MPI_COMM_NULL)) {
148 (void)MPI_Topo_test(data, &status) ;
149 if (status == MPI_GRAPH)
152 mpi_comm = MPI_COMM_NULL;
163 inline MPI::Graphcomm
164 MPI::Graphcomm::Dup()
const
167 (void)MPI_Comm_dup(mpi_comm, &newcomm);
176 MPI::Graphcomm::Get_dims(
int nnodes[],
int nedges[])
const
178 (void)MPI_Graphdims_get(mpi_comm, nnodes, nedges);
182 MPI::Graphcomm::Get_topo(
int maxindex,
int maxedges,
int index[],
185 (void)MPI_Graph_get(mpi_comm, maxindex, maxedges, index, edges);
189 MPI::Graphcomm::Get_neighbors_count(
int rank)
const
192 (void)MPI_Graph_neighbors_count(mpi_comm, rank, &nneighbors);
197 MPI::Graphcomm::Get_neighbors(
int rank,
int maxneighbors,
198 int neighbors[])
const
200 (void)MPI_Graph_neighbors(mpi_comm, rank, maxneighbors, neighbors);
204 MPI::Graphcomm::Map(
int nnodes,
const int index[],
205 const int edges[])
const
208 (void)MPI_Graph_map(mpi_comm, nnodes, const_cast<int *>(index),
const_cast<int *
>(edges), &newrank);
212 inline MPI::Graphcomm&
213 MPI::Graphcomm::Clone()
const
216 (void)MPI_Comm_dup(mpi_comm, &newcomm);
217 MPI::Graphcomm* dup =
new MPI::Graphcomm(newcomm);
Definition: communicator.h:118