Tpetra parallel linear algebra  Version of the Day
Tpetra_Details_Transfer_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_DETAILS_TRANSFER_DECL_HPP
43 #define TPETRA_DETAILS_TRANSFER_DECL_HPP
44 
47 #include "Tpetra_Map_decl.hpp"
48 #include "Teuchos_Describable.hpp"
49 
50 namespace Tpetra {
51 
52 // Forward declaration. The macro tells Doxygen (our automatic
53 // documentation generation system) to skip forward declarations.
54 #ifndef DOXYGEN_SHOULD_SKIP_THIS
55 class Distributor;
56 #endif // DOXYGEN_SHOULD_SKIP_THIS
57 
58 namespace Details {
59 
60 #ifndef DOXYGEN_SHOULD_SKIP_THIS
63 template <class LO, class GO, class NT>
64 void
65 expertSetRemoteLIDsContiguous(Transfer<LO, GO, NT> transfer, bool contig);
66 
67 
70 template <class LO, class GO, class NT>
71 void
72 expertSetExportLIDsContiguous(Transfer<LO, GO, NT> transfer, bool contig);
73 #endif // DOXYGEN_SHOULD_SKIP_THIS
74 
79 template<class LO,
80  class GO,
81  class NT>
82 class Transfer : public Teuchos::Describable {
83 public:
89 
90 private:
91  using execution_space = typename NT::device_type::execution_space;
92  using memory_space =
93  ::Tpetra::Details::DefaultTypes::comm_buffer_memory_space<typename NT::device_type>;
94  using device_type = Kokkos::Device<execution_space, memory_space>;
95 
96 public:
97  // Don't be tempted to comment this out if code doesn't build.
98  // The point is to ensure correct initialization of TransferData_.
99  Transfer () = delete;
100 
116  Transfer (const Teuchos::RCP<const map_type>& source,
117  const Teuchos::RCP<const map_type>& target,
118  const Teuchos::RCP<Teuchos::FancyOStream>& out,
119  const Teuchos::RCP<Teuchos::ParameterList>& plist,
120  const std::string& className);
121 
122  Transfer (const Transfer<LO, GO, NT>& rhs) = default;
123 
124  struct reverse_tag {};
129  Transfer (const Transfer<LO, GO, NT>& rhs, reverse_tag tag);
130 
131  Transfer<LO, GO, NT>& operator= (const Transfer<LO, GO, NT>&) = default;
132 
134  virtual ~Transfer () = default;
135 
140  size_t getNumSameIDs() const;
141 
148  size_t getNumPermuteIDs () const;
149 
152  Kokkos::DualView<const LO*, device_type> getPermuteFromLIDs_dv () const;
153 
155  Teuchos::ArrayView<const LO> getPermuteFromLIDs () const;
156 
159  Kokkos::DualView<const LO*, device_type> getPermuteToLIDs_dv () const;
160 
162  Teuchos::ArrayView<const LO> getPermuteToLIDs () const;
163 
165  size_t getNumRemoteIDs () const;
166 
170  Kokkos::DualView<const LO*, device_type> getRemoteLIDs_dv () const;
171 
173  Teuchos::ArrayView<const LO> getRemoteLIDs () const;
174 
176  size_t getNumExportIDs () const;
177 
181  Kokkos::DualView<const LO*, device_type> getExportLIDs_dv () const;
182 
184  Teuchos::ArrayView<const LO> getExportLIDs () const;
185 
190  Teuchos::ArrayView<const int> getExportPIDs () const;
191 
193  Teuchos::RCP<const map_type> getSourceMap () const;
194 
196  Teuchos::RCP<const map_type> getTargetMap () const;
197 
200 
217  bool isLocallyComplete () const;
218 
219 
220  void detectRemoteExportLIDsContiguous() const;
221 
222  bool areRemoteLIDsContiguous() const;
223 
224  bool areExportLIDsContiguous() const;
225 
226 #ifndef DOXYGEN_SHOULD_SKIP_THIS
228  friend
229  void expertSetRemoteLIDsContiguous<LO,GO,NT>(Transfer<LO, GO, NT> transfer, bool contig);
230 
232  friend
233  void expertSetExportLIDsContiguous<LO,GO,NT>(Transfer<LO, GO, NT> transfer, bool contig);
234 #endif // DOXYGEN_SHOULD_SKIP_THIS
235 
242  bool isLocallyFitted () const;
243 
264  virtual void
265  describe (Teuchos::FancyOStream& out,
266  const Teuchos::EVerbosityLevel verbLevel =
267  Teuchos::Describable::verbLevel_default) const;
268 
269 protected:
271  Teuchos::RCP<ImportExportData<LO, GO, NT> > TransferData_;
272 
274  Teuchos::FancyOStream& verboseOutputStream () const;
275 
277  bool verbose () const;
278 
292  void
293  describeImpl (Teuchos::FancyOStream& out,
294  const std::string& className,
295  const Teuchos::EVerbosityLevel verbLevel =
296  Teuchos::Describable::verbLevel_default) const;
297 
298 private:
306  void
307  setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist,
308  const std::string& className);
309 
316  void
317  globalDescribe (Teuchos::FancyOStream& out,
318  const Teuchos::EVerbosityLevel vl) const;
319 
324  std::string
325  localDescribeToString (const Teuchos::EVerbosityLevel vl) const;
326 };
327 
328 } // namespace Details
329 } // namespace Tpetra
330 
331 // Explicit instantiation macro.
332 // Only invoke this when in the Tpetra::Details namespace.
333 // Most users do not need to use this.
334 //
335 // LO: The local ordinal type.
336 // GO: The global ordinal type.
337 // NODE: The Kokkos Node type.
338 #define TPETRA_DETAILS_TRANSFER_INSTANT(LO, GO, NODE) \
339  template class Transfer< LO , GO , NODE >; \
340  template void expertSetRemoteLIDsContiguous< LO , GO , NODE >(Transfer<LO, GO, NODE> transfer, bool contig); \
341  template void expertSetExportLIDsContiguous< LO , GO , NODE >(Transfer<LO, GO, NODE> transfer, bool contig);
342 
343 #endif // TPETRA_DETAILS_TRANSFER_DECL_HPP
Forward declaration of Tpetra::Details::Transfer.
Forward declaration of Tpetra::ImportExportData.
Declaration of the Tpetra::Map class and related nonmember constructors.
Common base class of Import and Export.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
Kokkos::DualView< const LO *, device_type > getPermuteFromLIDs_dv() const
List of local IDs in the source Map that are permuted, as a const DualView (that is sync'd to both ho...
size_t getNumSameIDs() const
Number of initial identical IDs.
Kokkos::DualView< const LO *, device_type > getPermuteToLIDs_dv() const
List of local IDs in the target Map that are permuted, as a const DualView (that is sync'd to both ho...
Teuchos::RCP< const map_type > getTargetMap() const
The target Map used to construct this Export or Import.
Teuchos::ArrayView< const LO > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
virtual ~Transfer()=default
Destructor (declared virtual for memory safety of derived classes).
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
Teuchos::ArrayView< const LO > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
Teuchos::ArrayView< const LO > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
bool verbose() const
Whether to print verbose debugging output.
bool isLocallyComplete() const
Is this Export or Import locally complete?
Teuchos::ArrayView< const LO > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
Teuchos::ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
Teuchos::RCP< ImportExportData< LO, GO, NT > > TransferData_
All the data needed for executing the Export communication plan.
bool isLocallyFitted() const
Are source and target map locally fitted?
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.
Teuchos::FancyOStream & verboseOutputStream() const
Valid (nonnull) output stream for verbose output.
Kokkos::DualView< const LO *, device_type > getRemoteLIDs_dv() const
List of entries in the target Map to receive from other processes, as a const DualView (that is sync'...
::Tpetra::Distributor & getDistributor() const
The Distributor that this Export or Import object uses to move data.
void describeImpl(Teuchos::FancyOStream &out, const std::string &className, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Implementation of describe() for subclasses (Tpetra::Import and Tpetra::Export).
Teuchos::RCP< const map_type > getSourceMap() const
The source Map used to construct this Export or Import.
Kokkos::DualView< const LO *, device_type > getExportLIDs_dv() const
List of entries in the source Map that will be sent to other processes, as a const DualView (that is ...
Sets up and executes a communication plan for a Tpetra DistObject.
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.