This source file includes following definitions.
- Dup
- Get_dim
- Get_topo
- Get_cart_rank
- Get_coords
- Shift
- Sub
- Map
- Clone
- Dup
- Get_dims
- Get_topo
- Get_neighbors_count
- Get_neighbors
- Map
- Clone
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 
  25 
  26 
  27 inline
  28 MPI::Cartcomm::Cartcomm(const MPI_Comm& data) {
  29   int status = 0;
  30   if (MPI::Is_initialized() && (data != MPI_COMM_NULL)) {
  31     (void)MPI_Topo_test(data, &status) ;
  32     if (status == MPI_CART)
  33       mpi_comm = data;
  34     else
  35       mpi_comm = MPI_COMM_NULL;
  36   }
  37   else {
  38     mpi_comm = data;
  39   }
  40 }
  41 
  42 
  43 
  44 
  45 
  46 inline MPI::Cartcomm
  47 MPI::Cartcomm::Dup() const
  48 {
  49   MPI_Comm newcomm;
  50   (void)MPI_Comm_dup(mpi_comm, &newcomm);
  51   return newcomm;
  52 }
  53 
  54 
  55 
  56 
  57 
  58 inline int
  59 MPI::Cartcomm::Get_dim() const
  60 {
  61   int ndims;
  62   (void)MPI_Cartdim_get(mpi_comm, &ndims);
  63   return ndims;
  64 }
  65 
  66 inline void
  67 MPI::Cartcomm::Get_topo(int maxdims, int dims[], bool periods[],
  68                                int coords[]) const
  69 {
  70   int *int_periods = new int [maxdims];
  71   int i;
  72   for (i=0; i<maxdims; i++) {
  73     int_periods[i] = (int)periods[i];
  74   }
  75   (void)MPI_Cart_get(mpi_comm, maxdims, dims, int_periods, coords);
  76   for (i=0; i<maxdims; i++) {
  77     periods[i] = OPAL_INT_TO_BOOL(int_periods[i]);
  78   }
  79   delete [] int_periods;
  80 }
  81 
  82 inline int
  83 MPI::Cartcomm::Get_cart_rank(const int coords[]) const
  84 {
  85   int myrank;
  86   (void)MPI_Cart_rank(mpi_comm, const_cast<int *>(coords), &myrank);
  87   return myrank;
  88 }
  89 
  90 inline void
  91 MPI::Cartcomm::Get_coords(int rank, int maxdims, int coords[]) const
  92 {
  93   (void)MPI_Cart_coords(mpi_comm, rank, maxdims, coords);
  94 }
  95 
  96 inline void
  97 MPI::Cartcomm::Shift(int direction, int disp,
  98                             int &rank_source, int &rank_dest) const
  99 {
 100   (void)MPI_Cart_shift(mpi_comm, direction, disp, &rank_source, &rank_dest);
 101 }
 102 
 103 inline MPI::Cartcomm
 104 MPI::Cartcomm::Sub(const bool remain_dims[]) const
 105 {
 106   int ndims;
 107   MPI_Cartdim_get(mpi_comm, &ndims);
 108   int* int_remain_dims = new int[ndims];
 109   for (int i=0; i<ndims; i++) {
 110     int_remain_dims[i] = (int)remain_dims[i];
 111   }
 112   MPI_Comm newcomm;
 113   (void)MPI_Cart_sub(mpi_comm, int_remain_dims, &newcomm);
 114   delete [] int_remain_dims;
 115   return newcomm;
 116 }
 117 
 118 inline int
 119 MPI::Cartcomm::Map(int ndims, const int dims[], const bool periods[]) const
 120 {
 121   int *int_periods = new int [ndims];
 122   for (int i=0; i<ndims; i++) {
 123     int_periods[i] = (int) periods[i];
 124   }
 125   int newrank;
 126   (void)MPI_Cart_map(mpi_comm, ndims, const_cast<int *>(dims), int_periods, &newrank);
 127   delete [] int_periods;
 128   return newrank;
 129 }
 130 
 131 
 132 inline MPI::Cartcomm&
 133 MPI::Cartcomm::Clone() const
 134 {
 135   MPI_Comm newcomm;
 136   (void)MPI_Comm_dup(mpi_comm, &newcomm);
 137   MPI::Cartcomm* dup = new MPI::Cartcomm(newcomm);
 138   return *dup;
 139 }
 140 
 141 
 142 
 143 
 144 
 145 inline
 146 MPI::Graphcomm::Graphcomm(const MPI_Comm& data) {
 147   int status = 0;
 148   if (MPI::Is_initialized() && (data != MPI_COMM_NULL)) {
 149     (void)MPI_Topo_test(data, &status) ;
 150     if (status == MPI_GRAPH)
 151       mpi_comm = data;
 152     else
 153       mpi_comm = MPI_COMM_NULL;
 154   }
 155   else {
 156     mpi_comm = data;
 157   }
 158 }
 159 
 160 
 161 
 162 
 163 
 164 inline MPI::Graphcomm
 165 MPI::Graphcomm::Dup() const
 166 {
 167   MPI_Comm newcomm;
 168   (void)MPI_Comm_dup(mpi_comm, &newcomm);
 169   return newcomm;
 170 }
 171 
 172 
 173 
 174 
 175 
 176 inline void
 177 MPI::Graphcomm::Get_dims(int nnodes[], int nedges[]) const
 178 {
 179   (void)MPI_Graphdims_get(mpi_comm, nnodes, nedges);
 180 }
 181 
 182 inline void
 183 MPI::Graphcomm::Get_topo(int maxindex, int maxedges, int index[],
 184          int edges[]) const
 185 {
 186   (void)MPI_Graph_get(mpi_comm, maxindex, maxedges, index, edges);
 187 }
 188 
 189 inline int
 190 MPI::Graphcomm::Get_neighbors_count(int rank) const
 191 {
 192   int nneighbors;
 193   (void)MPI_Graph_neighbors_count(mpi_comm, rank, &nneighbors);
 194   return nneighbors;
 195 }
 196 
 197 inline void
 198 MPI::Graphcomm::Get_neighbors(int rank, int maxneighbors,
 199               int neighbors[]) const
 200 {
 201   (void)MPI_Graph_neighbors(mpi_comm, rank, maxneighbors, neighbors);
 202 }
 203 
 204 inline int
 205 MPI::Graphcomm::Map(int nnodes, const int index[],
 206     const int edges[]) const
 207 {
 208   int newrank;
 209   (void)MPI_Graph_map(mpi_comm, nnodes, const_cast<int *>(index), const_cast<int *>(edges), &newrank);
 210   return newrank;
 211 }
 212 
 213 inline MPI::Graphcomm&
 214 MPI::Graphcomm::Clone() const
 215 {
 216   MPI_Comm newcomm;
 217   (void)MPI_Comm_dup(mpi_comm, &newcomm);
 218   MPI::Graphcomm* dup = new MPI::Graphcomm(newcomm);
 219   return *dup;
 220 }