Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Details_Transfer_decl.hpp
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TPETRA_DETAILS_TRANSFER_DECL_HPP
11#define TPETRA_DETAILS_TRANSFER_DECL_HPP
12
15#include "Tpetra_Map_decl.hpp"
16#include "Teuchos_Describable.hpp"
17
18namespace Tpetra {
19
20// Forward declaration. The macro tells Doxygen (our automatic
21// documentation generation system) to skip forward declarations.
22#ifndef DOXYGEN_SHOULD_SKIP_THIS
23class Distributor;
24#endif // DOXYGEN_SHOULD_SKIP_THIS
25
26namespace Details {
27
28#ifndef DOXYGEN_SHOULD_SKIP_THIS
31template <class LO, class GO, class NT>
32void
33expertSetRemoteLIDsContiguous(Transfer<LO, GO, NT> transfer, bool contig);
34
35
38template <class LO, class GO, class NT>
39void
40expertSetExportLIDsContiguous(Transfer<LO, GO, NT> transfer, bool contig);
41#endif // DOXYGEN_SHOULD_SKIP_THIS
42
47template<class LO,
48 class GO,
49 class NT>
50class Transfer : public Teuchos::Describable {
51public:
57
58private:
59 using execution_space = typename NT::device_type::execution_space;
60 using memory_space =
61 ::Tpetra::Details::DefaultTypes::comm_buffer_memory_space<typename NT::device_type>;
62 using device_type = Kokkos::Device<execution_space, memory_space>;
63
64public:
65 // Don't be tempted to comment this out if code doesn't build.
66 // The point is to ensure correct initialization of TransferData_.
67 Transfer () = delete;
68
84 Transfer (const Teuchos::RCP<const map_type>& source,
85 const Teuchos::RCP<const map_type>& target,
86 const Teuchos::RCP<Teuchos::FancyOStream>& out,
87 const Teuchos::RCP<Teuchos::ParameterList>& plist,
88 const std::string& className);
89
90 Transfer (const Transfer<LO, GO, NT>& rhs) = default;
91
92 struct reverse_tag {};
97 Transfer (const Transfer<LO, GO, NT>& rhs, reverse_tag tag);
98
99 Transfer<LO, GO, NT>& operator= (const Transfer<LO, GO, NT>&) = default;
100
102 virtual ~Transfer () = default;
103
108 size_t getNumSameIDs() const;
109
116 size_t getNumPermuteIDs () const;
117
120 Kokkos::DualView<const LO*, device_type> getPermuteFromLIDs_dv () const;
121
123 Teuchos::ArrayView<const LO> getPermuteFromLIDs () const;
124
127 Kokkos::DualView<const LO*, device_type> getPermuteToLIDs_dv () const;
128
130 Teuchos::ArrayView<const LO> getPermuteToLIDs () const;
131
133 size_t getNumRemoteIDs () const;
134
138 Kokkos::DualView<const LO*, device_type> getRemoteLIDs_dv () const;
139
141 Teuchos::ArrayView<const LO> getRemoteLIDs () const;
142
144 size_t getNumExportIDs () const;
145
149 Kokkos::DualView<const LO*, device_type> getExportLIDs_dv () const;
150
152 Teuchos::ArrayView<const LO> getExportLIDs () const;
153
158 Teuchos::ArrayView<const int> getExportPIDs () const;
159
161 Teuchos::RCP<const map_type> getSourceMap () const;
162
164 Teuchos::RCP<const map_type> getTargetMap () const;
165
168
185 bool isLocallyComplete () const;
186
187
188 void detectRemoteExportLIDsContiguous() const;
189
190 bool areRemoteLIDsContiguous() const;
191
192 bool areExportLIDsContiguous() const;
193
194#ifndef DOXYGEN_SHOULD_SKIP_THIS
196 friend
197 void expertSetRemoteLIDsContiguous<LO,GO,NT>(Transfer<LO, GO, NT> transfer, bool contig);
198
200 friend
201 void expertSetExportLIDsContiguous<LO,GO,NT>(Transfer<LO, GO, NT> transfer, bool contig);
202#endif // DOXYGEN_SHOULD_SKIP_THIS
203
210 bool isLocallyFitted () const;
211
232 virtual void
233 describe (Teuchos::FancyOStream& out,
234 const Teuchos::EVerbosityLevel verbLevel =
235 Teuchos::Describable::verbLevel_default) const;
236
237protected:
239 Teuchos::RCP<ImportExportData<LO, GO, NT> > TransferData_;
240
242 Teuchos::FancyOStream& verboseOutputStream () const;
243
245 bool verbose () const;
246
260 void
261 describeImpl (Teuchos::FancyOStream& out,
262 const std::string& className,
263 const Teuchos::EVerbosityLevel verbLevel =
264 Teuchos::Describable::verbLevel_default) const;
265
266private:
274 void
275 setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist,
276 const std::string& className);
277
284 void
285 globalDescribe (Teuchos::FancyOStream& out,
286 const Teuchos::EVerbosityLevel vl) const;
287
292 std::string
293 localDescribeToString (const Teuchos::EVerbosityLevel vl) const;
294};
295
296} // namespace Details
297} // namespace Tpetra
298
299// Explicit instantiation macro.
300// Only invoke this when in the Tpetra::Details namespace.
301// Most users do not need to use this.
302//
303// LO: The local ordinal type.
304// GO: The global ordinal type.
305// NODE: The Kokkos Node type.
306#define TPETRA_DETAILS_TRANSFER_INSTANT(LO, GO, NODE) \
307 template class Transfer< LO , GO , NODE >; \
308 template void expertSetRemoteLIDsContiguous< LO , GO , NODE >(Transfer<LO, GO, NODE> transfer, bool contig); \
309 template void expertSetExportLIDsContiguous< LO , GO , NODE >(Transfer<LO, GO, NODE> transfer, bool contig);
310
311#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.
Transfer(const Transfer< LO, GO, NT > &rhs, reverse_tag tag)
Reverse-mode "copy" constructor.
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.
::Tpetra::Map< LO, GO, NT > map_type
Map specialization used by this class and subclasses.
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< LocalOrdinal, GlobalOrdinal, Node > > TransferData_
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 ...
Transfer(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::FancyOStream > &out, const Teuchos::RCP< Teuchos::ParameterList > &plist, const std::string &className)
Four-argument constructor (most often used).
Sets up and executes a communication plan for a Tpetra DistObject.
A parallel distribution of indices over processes.
Nonmember function that computes a residual Computes R = B - A * X.
Namespace Tpetra contains the class and methods constituting the Tpetra library.