Tpetra Matrix/Vector Services  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Tpetra_DistObject_def.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Tpetra: Templated Linear Algebra Services Package
5 // Copyright (2008) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 
42 #ifndef TPETRA_DISTOBJECT_DEF_HPP
43 #define TPETRA_DISTOBJECT_DEF_HPP
44 
45 #include "Tpetra_ConfigDefs.hpp"
46 #include "Tpetra_Map.hpp"
47 #include "Tpetra_Import.hpp"
48 #include "Tpetra_Export.hpp"
49 #include "Tpetra_Distributor.hpp"
50 
51 #ifdef DOXYGEN_USE_ONLY
52 # include "Tpetra_DistObject_decl.hpp"
53 #endif // DOXYGEN_USE_ONLY
54 
55 
56 namespace Tpetra {
57  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
59  DistObject (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map)
60  : map_ (map)
61  {
62 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
63  using Teuchos::RCP;
64  using Teuchos::Time;
65  using Teuchos::TimeMonitor;
66 
67  RCP<Time> doXferTimer =
68  TimeMonitor::lookupCounter ("Tpetra::DistObject::doTransfer");
69  if (doXferTimer.is_null ()) {
70  doXferTimer =
71  TimeMonitor::getNewCounter ("Tpetra::DistObject::doTransfer");
72  }
73  doXferTimer_ = doXferTimer;
74 
75  RCP<Time> copyAndPermuteTimer =
76  TimeMonitor::lookupCounter ("Tpetra::DistObject::copyAndPermute");
77  if (copyAndPermuteTimer.is_null ()) {
78  copyAndPermuteTimer =
79  TimeMonitor::getNewCounter ("Tpetra::DistObject::copyAndPermute");
80  }
81  copyAndPermuteTimer_ = copyAndPermuteTimer;
82 
83  RCP<Time> packAndPrepareTimer =
84  TimeMonitor::lookupCounter ("Tpetra::DistObject::packAndPrepare");
85  if (packAndPrepareTimer.is_null ()) {
86  packAndPrepareTimer =
87  TimeMonitor::getNewCounter ("Tpetra::DistObject::packAndPrepare");
88  }
89  packAndPrepareTimer_ = packAndPrepareTimer;
90 
91  RCP<Time> doPostsAndWaitsTimer =
92  TimeMonitor::lookupCounter ("Tpetra::DistObject::doPostsAndWaits");
93  if (doPostsAndWaitsTimer.is_null ()) {
94  doPostsAndWaitsTimer =
95  TimeMonitor::getNewCounter ("Tpetra::DistObject::doPostsAndWaits");
96  }
97  doPostsAndWaitsTimer_ = doPostsAndWaitsTimer;
98 
99  RCP<Time> unpackAndCombineTimer =
100  TimeMonitor::lookupCounter ("Tpetra::DistObject::unpackAndCombine");
101  if (unpackAndCombineTimer.is_null ()) {
102  unpackAndCombineTimer =
103  TimeMonitor::getNewCounter ("Tpetra::DistObject::unpackAndCombine");
104  }
105  unpackAndCombineTimer_ = unpackAndCombineTimer;
106 #endif // HAVE_TPETRA_TRANSFER_TIMERS
107  }
108 
109  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
112  : map_ (rhs.map_)
113  {}
114 
115  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
117  {}
118 
119  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
120  std::string
122  {
123  using Teuchos::TypeNameTraits;
124 
125  std::ostringstream os;
126  os << "Tpetra::DistObject<"
127  << TypeNameTraits<Packet>::name ()
128  << ", " << TypeNameTraits<LocalOrdinal>::name ()
129  << ", " << TypeNameTraits<GlobalOrdinal>::name ()
130  << ", " << TypeNameTraits<Node>::name ()
131  << ">";
132  return os.str ();
133  }
134 
135  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
136  void
138  describe (Teuchos::FancyOStream &out,
139  const Teuchos::EVerbosityLevel verbLevel) const
140  {
141  using Teuchos::rcpFromRef;
142  using std::endl;
143 
144  const Teuchos::EVerbosityLevel vl = (verbLevel == Teuchos::VERB_DEFAULT) ?
145  Teuchos::VERB_LOW : verbLevel;
146 
147  if (vl != Teuchos::VERB_NONE) {
148  out << this->description () << endl;
149  Teuchos::OSTab tab (rcpFromRef (out));
150  out << "Export buffer size (in packets): " << exports_.size() << endl
151  << "Import buffer size (in packets): " << imports_.size() << endl
152  << "Map over which this object is distributed:" << endl;
153  map_->describe (out, vl);
154  }
155  }
156 
157  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
158  void
161  {
162  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
163  "Tpetra::DistObject::removeEmptyProcessesInPlace: Not implemented");
164  }
165 
166  template<class DistObjectType>
167  void
168  removeEmptyProcessesInPlace (Teuchos::RCP<DistObjectType>& input,
169  const Teuchos::RCP<const Map<typename DistObjectType::local_ordinal_type,
170  typename DistObjectType::global_ordinal_type,
171  typename DistObjectType::node_type> >& newMap)
172  {
173  input->removeEmptyProcessesInPlace (newMap);
174  if (newMap.is_null ()) { // my process is excluded
175  input = Teuchos::null;
176  }
177  }
178 
179  template<class DistObjectType>
180  void
181  removeEmptyProcessesInPlace (Teuchos::RCP<DistObjectType>& input)
182  {
183  using Teuchos::RCP;
184  typedef typename DistObjectType::local_ordinal_type LO;
185  typedef typename DistObjectType::global_ordinal_type GO;
186  typedef typename DistObjectType::node_type NT;
187  typedef Map<LO, GO, NT> map_type;
188 
189  RCP<const map_type> newMap = input->getMap ()->removeEmptyProcesses ();
190  removeEmptyProcessesInPlace<DistObjectType> (input, newMap);
191  }
192 
193  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
194  void
196  doImport (const SrcDistObject& source,
198  CombineMode CM)
199  {
200  TEUCHOS_TEST_FOR_EXCEPTION(*getMap() != *importer.getTargetMap(),
201  std::invalid_argument, "doImport: The target DistObject's Map is not "
202  "identical to the Import's target Map.");
203 #ifdef HAVE_TPETRA_DEBUG
204  {
206  const this_type* srcDistObj = dynamic_cast<const this_type*> (&source);
207  TEUCHOS_TEST_FOR_EXCEPTION(
208  srcDistObj != NULL && * (srcDistObj->getMap ()) != *importer.getSourceMap(),
209  std::invalid_argument, "doImport: The source is a DistObject, yet its "
210  "Map is not identical to the Import's source Map.");
211  }
212 #endif // HAVE_TPETRA_DEBUG
213  size_t numSameIDs = importer.getNumSameIDs ();
214 
215  typedef Teuchos::ArrayView<const LocalOrdinal> view_type;
216  const view_type exportLIDs = importer.getExportLIDs();
217  const view_type remoteLIDs = importer.getRemoteLIDs();
218  const view_type permuteToLIDs = importer.getPermuteToLIDs();
219  const view_type permuteFromLIDs = importer.getPermuteFromLIDs();
220  this->doTransfer (source, CM, numSameIDs, permuteToLIDs, permuteFromLIDs,
221  remoteLIDs, exportLIDs, importer.getDistributor (),
222  DoForward);
223  }
224 
225  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
226  void
228  doExport (const SrcDistObject& source,
230  CombineMode CM)
231  {
232  TEUCHOS_TEST_FOR_EXCEPTION(
233  *getMap() != *exporter.getTargetMap(), std::invalid_argument,
234  "doExport: The target DistObject's Map is not identical to the Export's "
235  "target Map.");
236 #ifdef HAVE_TPETRA_DEBUG
237  {
239  const this_type* srcDistObj = dynamic_cast<const this_type*> (&source);
240  TEUCHOS_TEST_FOR_EXCEPTION(
241  srcDistObj != NULL && * (srcDistObj->getMap ()) != *exporter.getSourceMap(),
242  std::invalid_argument, "doExport: The source is a DistObject, yet its "
243  "Map is not identical to the Export's source Map.");
244  }
245 #endif // HAVE_TPETRA_DEBUG
246  size_t numSameIDs = exporter.getNumSameIDs();
247 
248  typedef ArrayView<const LocalOrdinal> view_type;
249  view_type exportLIDs = exporter.getExportLIDs();
250  view_type remoteLIDs = exporter.getRemoteLIDs();
251  view_type permuteToLIDs = exporter.getPermuteToLIDs();
252  view_type permuteFromLIDs = exporter.getPermuteFromLIDs();
253  doTransfer (source, CM, numSameIDs, permuteToLIDs, permuteFromLIDs, remoteLIDs,
254  exportLIDs, exporter.getDistributor (), DoForward);
255  }
256 
257  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
258  void
260  doImport (const SrcDistObject& source,
262  CombineMode CM)
263  {
264  TEUCHOS_TEST_FOR_EXCEPTION(
265  *getMap() != *exporter.getSourceMap(), std::invalid_argument,
266  "doImport (reverse mode): The target DistObject's Map is not identical "
267  "to the Export's source Map.");
268 #ifdef HAVE_TPETRA_DEBUG
269  {
271  const this_type* srcDistObj = dynamic_cast<const this_type*> (&source);
272  TEUCHOS_TEST_FOR_EXCEPTION(
273  srcDistObj != NULL && * (srcDistObj->getMap ()) != *exporter.getTargetMap(),
274  std::invalid_argument,
275  "doImport (reverse mode): The source is a DistObject, yet its "
276  "Map is not identical to the Export's target Map.");
277  }
278 #endif // HAVE_TPETRA_DEBUG
279  size_t numSameIDs = exporter.getNumSameIDs();
280 
281  typedef ArrayView<const LocalOrdinal> view_type;
282  view_type exportLIDs = exporter.getRemoteLIDs();
283  view_type remoteLIDs = exporter.getExportLIDs();
284  view_type permuteToLIDs = exporter.getPermuteFromLIDs();
285  view_type permuteFromLIDs = exporter.getPermuteToLIDs();
286  doTransfer (source, CM, numSameIDs, permuteToLIDs, permuteFromLIDs, remoteLIDs,
287  exportLIDs, exporter.getDistributor (), DoReverse);
288  }
289 
290  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
291  void
293  doExport (const SrcDistObject& source,
295  CombineMode CM)
296  {
297  TEUCHOS_TEST_FOR_EXCEPTION(
298  *getMap() != *importer.getSourceMap(), std::invalid_argument,
299  "doExport (reverse mode): The target object's Map "
300  "is not identical to the Import's source Map.");
301 #ifdef HAVE_TPETRA_DEBUG
302  {
304  const this_type* srcDistObj = dynamic_cast<const this_type*> (&source);
305  TEUCHOS_TEST_FOR_EXCEPTION(
306  srcDistObj != NULL && * (srcDistObj->getMap ()) != *importer.getTargetMap(),
307  std::invalid_argument,
308  "doExport (reverse mode): The source is a DistObject, yet its "
309  "Map is not identical to the Import's target Map.");
310  }
311 #endif // HAVE_TPETRA_DEBUG
312  size_t numSameIDs = importer.getNumSameIDs();
313 
314  typedef ArrayView<const LocalOrdinal> view_type;
315  view_type exportLIDs = importer.getRemoteLIDs();
316  view_type remoteLIDs = importer.getExportLIDs();
317  view_type permuteToLIDs = importer.getPermuteFromLIDs();
318  view_type permuteFromLIDs = importer.getPermuteToLIDs();
319  doTransfer (source, CM, numSameIDs, permuteToLIDs, permuteFromLIDs, remoteLIDs,
320  exportLIDs, importer.getDistributor (), DoReverse);
321  }
322 
323  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
324  bool
326  return map_->isDistributed ();
327  }
328 
329  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
330  size_t
333  return 0; // default implementation; subclasses may override
334  }
335 
336  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
337  void
340  CombineMode CM,
341  size_t numSameIDs,
342  const Teuchos::ArrayView<const LocalOrdinal>& permuteToLIDs,
343  const Teuchos::ArrayView<const LocalOrdinal>& permuteFromLIDs,
344  const Teuchos::ArrayView<const LocalOrdinal>& remoteLIDs,
345  const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
346  Distributor &distor,
347  ReverseOption revOp)
348  {
349  using Teuchos::as;
350 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
351  Teuchos::TimeMonitor doXferMon (*doXferTimer_);
352 #endif // HAVE_TPETRA_TRANSFER_TIMERS
353 
354  TEUCHOS_TEST_FOR_EXCEPTION(
355  ! checkSizes (src), std::invalid_argument,
356  "Tpetra::DistObject::doTransfer(): checkSizes() indicates that the "
357  "destination object is not a legal target for redistribution from the "
358  "source object. This probably means that they do not have the same "
359  "dimensions. For example, MultiVectors must have the same number of "
360  "rows and columns.");
361  Kokkos::ReadWriteOption rwo = Kokkos::ReadWrite;
362  if (CM == INSERT || CM == REPLACE) {
363  const size_t numIDsToWrite = numSameIDs +
364  as<size_t> (permuteToLIDs.size ()) +
365  as<size_t> (remoteLIDs.size ());
366  if (numIDsToWrite == this->getMap ()->getNodeNumElements ()) {
367  // We're overwriting all of our local data in the destination
368  // object, so a write-only view suffices.
369  //
370  // FIXME (mfh 10 Apr 2012) This doesn't make sense for a
371  // CrsMatrix with a dynamic graph. INSERT mode could mean
372  // that we're adding new entries to the object, but we don't
373  // want to get rid of the old ones.
374  rwo = Kokkos::WriteOnly;
375  }
376  }
377  // Tell the source to create a read-only view of its data. On a
378  // discrete accelerator such as a GPU, this brings EVERYTHING from
379  // device memory to host memory.
380  //
381  // FIXME (mfh 23 Mar 2012) By passing in the list of GIDs (or
382  // rather, local LIDs to send) and packet counts, createViews()
383  // could create a "sparse view" that only brings in the necessary
384  // data from device to host memory.
386  const this_type* srcDistObj = dynamic_cast<const this_type*> (&src);
387  if (srcDistObj != NULL) {
388  srcDistObj->createViews ();
389  }
390 
391  // Tell the target to create a view of its data. Depending on
392  // rwo, this could be a write-only view or a read-and-write view.
393  // On a discrete accelerator such as a GPU, a write-only view only
394  // requires a transfer from host to device memory. A
395  // read-and-write view requires a two-way transfer. This has the
396  // same problem as createViews(): it transfers EVERYTHING, not
397  // just the necessary data.
398  //
399  // FIXME (mfh 23 Mar 2012) By passing in the list of GIDs (or
400  // rather, local LIDs into which to receive) and packet counts,
401  // createViewsNonConst() could create a "sparse view" that only
402  // transfers the necessary data.
403  this->createViewsNonConst (rwo);
404 
405  if (numSameIDs + permuteToLIDs.size()) {
406 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
407  Teuchos::TimeMonitor copyAndPermuteMon (*copyAndPermuteTimer_);
408 #endif // HAVE_TPETRA_TRANSFER_TIMERS
409  // There is at least one GID to copy or permute.
410  copyAndPermute (src, numSameIDs, permuteToLIDs, permuteFromLIDs);
411  }
412  // The method may return zero even if the implementation actually
413  // does have a constant number of packets per LID. However, if it
414  // returns nonzero, we may use this information to avoid
415  // (re)allocating num{Ex,Im}portPacketsPerLID_. packAndPrepare()
416  // will set this to its final value.
417  size_t constantNumPackets = this->constantNumberOfPackets ();
418 
419  if (constantNumPackets == 0) {
420  numExportPacketsPerLID_.resize (exportLIDs.size ());
421  numImportPacketsPerLID_.resize (remoteLIDs.size ());
422  }
423 
424  {
425 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
426  Teuchos::TimeMonitor packAndPrepareMon (*packAndPrepareTimer_);
427 #endif // HAVE_TPETRA_TRANSFER_TIMERS
428  // Ask the source to pack data. Also ask it whether there are a
429  // constant number of packets per element (constantNumPackets is
430  // an output argument). If there are, constantNumPackets will
431  // come back nonzero. Otherwise, the source will fill the
432  // numExportPacketsPerLID_ array.
433  packAndPrepare (src, exportLIDs, exports_, numExportPacketsPerLID_ (),
434  constantNumPackets, distor);
435  }
436 
437  // We don't need the source's data anymore, so it can let go of
438  // its views. On an accelerator device with a separate memory
439  // space (like a GPU), this frees host memory, since device memory
440  // has the "master" version of the data.
441  if (srcDistObj != NULL) {
442  srcDistObj->releaseViews ();
443  }
444 
445  if (constantNumPackets != 0) {
446  // There are a constant number of packets per element. We
447  // already know (from the number of "remote" (incoming)
448  // elements) how many incoming elements we expect, so we can
449  // resize the buffer accordingly.
450  const size_t rbufLen = remoteLIDs.size() * constantNumPackets;
451  if (as<size_t> (imports_.size()) != rbufLen) {
452  imports_.resize (rbufLen);
453  }
454  }
455 
456  // Do we need to do communication (via doPostsAndWaits)?
457  bool needCommunication = true;
458  if (revOp == DoReverse && ! isDistributed ()) {
459  needCommunication = false;
460  }
461  // FIXME (mfh 30 Jun 2013): Checking whether the source object is
462  // distributed requires a cast to DistObject. If it's not a
463  // DistObject, then I'm not quite sure what to do. Perhaps it
464  // would be more appropriate for SrcDistObject to have an
465  // isDistributed() method. For now, I'll just assume that we need
466  // to do communication unless the cast succeeds and the source is
467  // not distributed.
468  else if (revOp == DoForward && srcDistObj != NULL && ! srcDistObj->isDistributed ()) {
469  needCommunication = false;
470  }
471 
472  if (needCommunication) {
473  if (revOp == DoReverse) {
474 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
475  Teuchos::TimeMonitor doPostsAndWaitsMon (*doPostsAndWaitsTimer_);
476 #endif // HAVE_TPETRA_TRANSFER_TIMERS
477  if (constantNumPackets == 0) { //variable num-packets-per-LID:
478  distor.doReversePostsAndWaits (numExportPacketsPerLID_().getConst(), 1,
479  numImportPacketsPerLID_());
480  size_t totalImportPackets = 0;
481  for (Array_size_type i = 0; i < numImportPacketsPerLID_.size(); ++i) {
482  totalImportPackets += numImportPacketsPerLID_[i];
483  }
484  imports_.resize(totalImportPackets);
485  distor.doReversePostsAndWaits (exports_().getConst(),
486  numExportPacketsPerLID_(),
487  imports_(),
488  numImportPacketsPerLID_());
489  }
490  else {
491  distor.doReversePostsAndWaits (exports_().getConst(),
492  constantNumPackets,
493  imports_());
494  }
495  }
496  else { // revOp == DoForward
497 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
498  Teuchos::TimeMonitor doPostsAndWaitsMon (*doPostsAndWaitsTimer_);
499 #endif // HAVE_TPETRA_TRANSFER_TIMERS
500  if (constantNumPackets == 0) { //variable num-packets-per-LID:
501  distor.doPostsAndWaits (numExportPacketsPerLID_().getConst(), 1,
502  numImportPacketsPerLID_());
503  size_t totalImportPackets = 0;
504  for (Array_size_type i = 0; i < numImportPacketsPerLID_.size(); ++i) {
505  totalImportPackets += numImportPacketsPerLID_[i];
506  }
507  imports_.resize(totalImportPackets);
508  distor.doPostsAndWaits (exports_().getConst(),
509  numExportPacketsPerLID_(),
510  imports_(),
511  numImportPacketsPerLID_());
512  }
513  else {
514  distor.doPostsAndWaits (exports_().getConst(),
515  constantNumPackets,
516  imports_());
517  }
518  }
519  {
520 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
521  Teuchos::TimeMonitor unpackAndCombineMon (*unpackAndCombineTimer_);
522 #endif // HAVE_TPETRA_TRANSFER_TIMERS
523  unpackAndCombine (remoteLIDs, imports_(), numImportPacketsPerLID_(),
524  constantNumPackets, distor, CM);
525  }
526  }
527  this->releaseViews();
528  }
529 
530  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
531  void
533  {
534  using Teuchos::FancyOStream;
535  using Teuchos::getFancyOStream;
536  using Teuchos::RCP;
537  using Teuchos::rcpFromRef;
538  using std::endl;
539 
540  RCP<FancyOStream> out = getFancyOStream (rcpFromRef (os));
541  this->describe (*out, Teuchos::VERB_DEFAULT);
542  }
543 
544  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
545  void
547  {}
548 
549  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
550  void
552  createViewsNonConst (Kokkos::ReadWriteOption /*rwo*/)
553  {}
554 
555  template <class Packet, class LocalOrdinal, class GlobalOrdinal, class Node>
556  void
559  {}
560 
561 #define TPETRA_DISTOBJECT_INSTANT(SCALAR, LO, GO, NODE) \
562  \
563  template class DistObject< SCALAR , LO , GO , NODE >;
564 
565  // The "SLGN" stuff above doesn't work for Packet=char.
566 #define TPETRA_DISTOBJECT_INSTANT_CHAR(LO, GO, NODE) \
567  \
568  template class DistObject< char , LO , GO , NODE >;
569 
570 
571 } // namespace Tpetra
572 
573 #endif /* TPETRA_DISTOBJECT_DEF_HPP */
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
virtual void createViewsNonConst(Kokkos::ReadWriteOption rwo)
Hook for creating a nonconst view.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getTargetMap() const
The Target Map used to construct this Import object.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getSourceMap() const
The source Map used to construct this Export.
virtual void createViews() const
Hook for creating a const view.
size_t getNumSameIDs() const
Number of initial identical IDs.
void print(std::ostream &os) const
Print this object to the given output stream.
bool isDistributed() const
Whether this is a globally distributed object.
void removeEmptyProcessesInPlace(Teuchos::RCP< DistObjectType > &input, const Teuchos::RCP< const Map< typename DistObjectType::local_ordinal_type, typename DistObjectType::global_ordinal_type, typename DistObjectType::node_type > > &newMap)
Remove processes which contain no elements in this object&#39;s Map.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
virtual void releaseViews() const
Hook for releasing views.
Teuchos_Ordinal Array_size_type
Size type for Teuchos Array objects.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
Remove processes which contain no elements in this object&#39;s Map.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
void doPostsAndWaits(const ArrayView< const Packet > &exports, size_t numPackets, const ArrayView< Packet > &imports)
Execute the (forward) communication plan.
DistObject(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Constructor.
virtual ~DistObject()
Destructor (virtual for memory safety of derived classes).
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Sets up and executes a communication plan for a Tpetra DistObject.
CombineMode
Tpetra::Combine Mode enumerable type.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const
Return a new Map with processes with zero elements removed.
Abstract base class for objects that can be the source of an Import or Export operation.
ReverseOption
Whether the data transfer should be performed in forward or reverse mode.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
virtual std::string description() const
One-line descriptiion of this object.
virtual size_t constantNumberOfPackets() const
Whether the implementation&#39;s instance promises always to have a constant number of packets per LID...
void doReversePostsAndWaits(const ArrayView< const Packet > &exports, size_t numPackets, const ArrayView< Packet > &imports)
Execute the reverse communication plan.
Describes a parallel distribution of objects over processes.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getTargetMap() const
The target Map used to construct this Export.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getSourceMap() const
The Source Map used to construct this Import object.
Distributor & getDistributor() const
The Distributor that this Export object uses to move data.
size_t getNumSameIDs() const
Number of initial identical IDs.
Distributor & getDistributor() const
The Distributor that this Import object uses to move data.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print a descriptiion of this object to the given output stream.
void doImport(const SrcDistObject &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import data into this object using an Import object (&quot;forward mode&quot;).
Base class for distributed Tpetra objects that support data redistribution.
void doExport(const SrcDistObject &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export data into this object using an Export object (&quot;forward mode&quot;).
virtual void doTransfer(const SrcDistObject &src, CombineMode CM, size_t numSameIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteToLIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteFromLIDs, const Teuchos::ArrayView< const LocalOrdinal > &remoteLIDs, const Teuchos::ArrayView< const LocalOrdinal > &exportLIDs, Distributor &distor, ReverseOption revOp)
Redistribute data across memory images.