Tpetra parallel linear algebra  Version of the Day
Tpetra_Import_decl.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_IMPORT_DECL_HPP
43 #define TPETRA_IMPORT_DECL_HPP
44 
45 #include <Tpetra_Details_Transfer.hpp>
46 
47 namespace Tpetra {
48  //
49  // Forward declarations. The "doxygen" bit simply tells Doxygen
50  // (our automatic documentation generation system) to skip forward
51  // declarations.
52  //
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54  template<class LocalOrdinal, class GlobalOrdinal, class Node>
55  class ImportExportData;
56 
57  template<class LocalOrdinal, class GlobalOrdinal, class Node>
58  class Export;
59 #endif // DOXYGEN_SHOULD_SKIP_THIS
60 
121  template<class LocalOrdinal = ::Tpetra::Details::DefaultTypes::local_ordinal_type,
122  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
124  class Import:
125  public ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>
126  {
127  private:
128  friend class Export<LocalOrdinal,GlobalOrdinal,Node>;
129  public:
131  //typedef typename ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>::map_type map_type;
132  typedef ::Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
133 
135 
136 
144  Import (const Teuchos::RCP<const map_type>& source,
145  const Teuchos::RCP<const map_type>& target);
146 
157  Import (const Teuchos::RCP<const map_type>& source,
158  const Teuchos::RCP<const map_type>& target,
159  const Teuchos::RCP<Teuchos::FancyOStream>& out);
160 
173  Import (const Teuchos::RCP<const map_type>& source,
174  const Teuchos::RCP<const map_type>& target,
175  const Teuchos::RCP<Teuchos::ParameterList>& plist);
176 
192  Import (const Teuchos::RCP<const map_type>& source,
193  const Teuchos::RCP<const map_type>& target,
194  const Teuchos::RCP<Teuchos::FancyOStream>& out,
195  const Teuchos::RCP<Teuchos::ParameterList>& plist);
196 
208  Import (const Teuchos::RCP<const map_type>& source,
209  const Teuchos::RCP<const map_type>& target,
210  Teuchos::Array<int> & remotePIDs);
211 
217 
225 
229 
230  Import (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& source,
231  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& target,
232  Teuchos::Array<int> & userRemotePIDs,
233  Teuchos::Array<GlobalOrdinal>& remoteGIDs,
234  const Teuchos::ArrayView<const LocalOrdinal> & userExportLIDs,
235  const Teuchos::ArrayView<const int> & userExportPIDs,
236  const bool useRemotePIDs,
237  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null,
238  const Teuchos::RCP<Teuchos::FancyOStream>& out = Teuchos::null);
239 
240 
242  virtual ~Import ();
243 
248  void setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
249 
251 
253 
258  size_t getNumSameIDs() const;
259 
266  size_t getNumPermuteIDs() const;
267 
269  Teuchos::ArrayView<const LocalOrdinal> getPermuteFromLIDs() const;
270 
272  Teuchos::ArrayView<const LocalOrdinal> getPermuteToLIDs() const;
273 
275  size_t getNumRemoteIDs() const;
276 
278  Teuchos::ArrayView<const LocalOrdinal> getRemoteLIDs() const;
279 
281  size_t getNumExportIDs() const;
282 
284  Teuchos::ArrayView<const LocalOrdinal> getExportLIDs() const;
285 
290  Teuchos::ArrayView<const int> getExportPIDs() const;
291 
293  Teuchos::RCP<const map_type> getSourceMap () const;
294 
296  Teuchos::RCP<const map_type> getTargetMap () const;
297 
299  Distributor & getDistributor() const;
300 
311  bool isLocallyComplete () const;
312 
316 
350  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
352 
369  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
370  setUnion () const;
371 
372 
377  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
378  createRemoteOnlyImport (const Teuchos::RCP<const map_type>& remoteTarget) const;
379 
380 
382 
384 
407  virtual void
408  describe (Teuchos::FancyOStream& out,
409  const Teuchos::EVerbosityLevel verbLevel =
410  Teuchos::Describable::verbLevel_default) const;
411 
427  virtual void print (std::ostream& os) const;
428 
430  private:
432  Teuchos::RCP<ImportExportData<LocalOrdinal,GlobalOrdinal,Node> > ImportData_;
434  Teuchos::RCP<Teuchos::FancyOStream> out_;
436  bool debug_;
437 
439 
440 
457  void
458  init (const Teuchos::RCP<const map_type>& source,
459  const Teuchos::RCP<const map_type>& target,
460  bool useRemotePIDs,
461  Teuchos::Array<int> & remotePIDs,
462  const Teuchos::RCP<Teuchos::ParameterList>& plist);
463 
495  void setupSamePermuteRemote (Teuchos::Array<GlobalOrdinal>& remoteGIDs);
496 
525  void
526  setupExport (Teuchos::Array<GlobalOrdinal>& remoteGIDs, bool useRemotePIDs, Teuchos::Array<int> & remotePIDs);
528 
536  Import (const Teuchos::RCP<const map_type>& source,
537  const Teuchos::RCP<const map_type>& target,
538  const size_t numSameID,
539  Teuchos::Array<LocalOrdinal>& permuteToLIDs,
540  Teuchos::Array<LocalOrdinal>& permuteFromLIDs,
541  Teuchos::Array<LocalOrdinal>& remoteLIDs,
542  Teuchos::Array<LocalOrdinal>& exportLIDs,
543  Teuchos::Array<int>& exportPIDs,
544  Distributor& distributor,
545  const Teuchos::RCP<Teuchos::FancyOStream>& out = Teuchos::null,
546  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null);
547 
548 
549  }; // class Import
550 
561  template<class LocalOrdinal, class GlobalOrdinal, class Node>
562  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
563  createImport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
564  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt)
565  {
566  if (src == tgt) {
567  return Teuchos::null;
568  }
569 #ifdef HAVE_TPETRA_DEBUG
570  TEUCHOS_TEST_FOR_EXCEPTION(
571  src == Teuchos::null || tgt == Teuchos::null, std::runtime_error,
572  "Tpetra::createImport(): neither source nor target map may be null:"
573  << std::endl << "source: " << src << std::endl << "target: " << tgt
574  << std::endl);
575 #endif // HAVE_TPETRA_DEBUG
576  typedef Import<LocalOrdinal, GlobalOrdinal, Node> import_type;
577  return Teuchos::rcp (new import_type (src, tgt));
578  }
579 
591  template<class LocalOrdinal, class GlobalOrdinal, class Node>
592  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
593  createImport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
594  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt,
595  const Teuchos::RCP<Teuchos::ParameterList>& plist)
596  {
597  if (src == tgt) {
598  return Teuchos::null;
599  }
600 #ifdef HAVE_TPETRA_DEBUG
601  TEUCHOS_TEST_FOR_EXCEPTION(
602  src == Teuchos::null || tgt == Teuchos::null, std::runtime_error,
603  "Tpetra::createImport(): neither source nor target map may be null:"
604  << std::endl << "source: " << src << std::endl << "target: " << tgt
605  << std::endl);
606 #endif // HAVE_TPETRA_DEBUG
607  typedef Import<LocalOrdinal, GlobalOrdinal, Node> import_type;
608  return Teuchos::rcp (new import_type (src, tgt, plist));
609  }
610 
611 } // namespace Tpetra
612 
613 #endif // TPETRA_IMPORT_DECL_HPP
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
::Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Teuchos::ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
Teuchos::ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
Common base class of Import and Export.
Teuchos::RCP< const map_type > getSourceMap() const
The Source Map used to construct this Import object.
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
Teuchos::ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
virtual ~Import()
Destructor.
int local_ordinal_type
Default value of LocalOrdinal template parameter.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > setUnion() const
Return the union of this Import this->getSourceMap()
bool isLocallyComplete() const
Do all target Map indices on the calling process exist on at least one process (not necessarily this ...
Import(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct an Import from the source and target Maps.
Teuchos::ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
Teuchos::ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Teuchos::RCP< const map_type > getTargetMap() const
The Target Map used to construct this Import object.
Import< LocalOrdinal, GlobalOrdinal, Node > & operator=(const Import< LocalOrdinal, GlobalOrdinal, Node > &Source)
Assignment operator.
Sets up and executes a communication plan for a Tpetra DistObject.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Set parameters.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createImport(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &src, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &tgt)
Nonmember constructor for Import.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Describe this object in a human-readable way to the given output stream.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
virtual void print(std::ostream &os) const
Print the Import&#39;s data to the given output stream.
Describes a parallel distribution of objects over processes.
size_t getNumSameIDs() const
Number of initial identical IDs.
Distributor & getDistributor() const
The Distributor that this Import object uses to move data.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createRemoteOnlyImport(const Teuchos::RCP< const map_type > &remoteTarget) const
Returns an importer that contains only the remote entries of this.