omega_h
Reliable mesh adaptation
Omega_h_dist.hpp
1 #ifndef OMEGA_H_DIST_HPP
2 #define OMEGA_H_DIST_HPP
3 
4 #include <Omega_h_comm.hpp>
5 #include <Omega_h_remotes.hpp>
6 #include <Omega_h_graph.hpp>
7 
8 /* \file Omega_h_dist.hpp
9  \brief Header file for Omega_h::Dist
10  */
11 
12 namespace Omega_h {
13 
119 class Dist {
120  CommPtr parent_comm_;
121  LOs roots2items_[2];
122  LOs items2content_[2];
123  LOs msgs2content_[2];
124  CommPtr comm_[2];
125 
126  public:
127  Dist();
128  Dist(Dist const& other);
129  Dist& operator=(Dist const& other);
130  Dist(CommPtr comm_in, Remotes fitems2rroots, LO nrroots);
131  void set_parent_comm(CommPtr parent_comm_in);
132  /* set the destination graph node MPI ranks of the "items"
133  (graph edges sorted by local source node).
134  this call defines the majority of the communication pattern,
135  including neighbors and forwards items2content permutation.
136  this is a collective call.
137  */
138  void set_dest_ranks(Read<I32> items2ranks_in);
139  /* optionally set the destination root (local) indices of
140  each forward item. one also needs to specify the number
141  of destination roots on this MPI rank.
142  this will specify the receiving side of the data
143  structure, including items2content and roots2items.
144  if not specified, then destination content, items,
145  and roots will all be assumed to be the same.
146  */
147  void set_dest_idxs(LOs fitems2rroots, LO nrroots);
148  /* optionally specify the expansion ("fan") from forward
149  roots to items.
150  if not specified, forward roots and items will be assumed
151  to be the same. */
152  void set_roots2items(LOs froots2fitems);
153  /* optionally specify the _global_ numbers of the destination
154  graph nodes of each forward item.
155  this will define the reverse items (items2content) by
156  insisting that these items be sorted in ascending order
157  of their global number.
158  reverse roots are not specified by this function, they
159  are assumed to be the same as reverse items.
160  one may only call this API or set_dest_idxs(), not both */
161  void set_dest_globals(GOs fitems2ritem_globals);
162  Dist invert() const;
163  template <typename T>
164  Read<T> exch(Read<T> data, Int width) const;
165  template <typename T>
166  Future<T> iexch(Read<T> data, Int width) const;
167  template <typename T>
168  Read<T> exch_reduce(Read<T> data, Int width, Omega_h_Op op) const;
169  CommPtr parent_comm() const;
170  CommPtr comm() const;
171  LOs msgs2content() const;
172  LOs content2msgs() const;
173  LOs items2content() const;
174  LOs items2msgs() const;
175  LOs roots2items() const;
176  Read<I32> msgs2ranks() const;
177  Read<I32> items2ranks() const;
178  LOs items2dest_idxs() const;
179  Remotes items2dests() const;
180  LO nitems() const;
181  LO nroots() const;
182  LO ndests() const;
183  LO nsrcs() const;
184  void change_comm(CommPtr new_comm);
185  Remotes exch(Remotes data, Int width) const;
186 
187  private:
188  void copy(Dist const& other);
189  enum { F, R };
190 };
191 
199 Dist create_dist_for_variable_sized(Dist copies2owners, LOs copies2data);
200 
201 #define OMEGA_H_EXPL_INST_DECL(T) \
202  extern template Read<T> Dist::exch(Read<T> data, Int width) const; \
203  extern template Future<T> Dist::iexch(Read<T> data, Int width) const; \
204  extern template Read<T> Dist::exch_reduce<T>( \
205  Read<T> data, Int width, Omega_h_Op op) const;
206 OMEGA_H_EXPL_INST_DECL(I8)
207 OMEGA_H_EXPL_INST_DECL(I32)
208 OMEGA_H_EXPL_INST_DECL(I64)
209 OMEGA_H_EXPL_INST_DECL(Real)
210 #undef OMEGA_H_EXPL_INST_DECL
211 
212 } // namespace Omega_h
213 
214 #endif
an MPI distributor object which encapsulates the idea of a communication pattern between lots of smal...
Definition: Omega_h_dist.hpp:119
Abstraction for asynchronous communication.
Definition: Omega_h_future.hpp:19
Definition: amr_mpi_test.cpp:6
Dist create_dist_for_variable_sized(Dist copies2owners, LOs copies2data)
Creates a Dist object that can be re-used to synchronize variable-sized data per actor.
Definition: Omega_h_dist.cpp:224
Definition: Omega_h_remotes.hpp:9