Tpetra parallel linear algebra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
Tpetra_ImportExportData_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_IMPORTEXPORTDATA_DEF_HPP
43
#define TPETRA_IMPORTEXPORTDATA_DEF_HPP
44
45
#include "Tpetra_Map.hpp"
46
#include "Tpetra_Details_makeValidVerboseStream.hpp"
47
#include "Teuchos_FancyOStream.hpp"
48
#include "Teuchos_ParameterList.hpp"
49
50
namespace
Tpetra
{
51
52
template
<
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
53
ImportExportData<LocalOrdinal, GlobalOrdinal, Node>::
54
ImportExportData (
const
Teuchos::RCP<const map_type>& source,
55
const
Teuchos::RCP<const map_type>& target,
56
const
Teuchos::RCP<Teuchos::FancyOStream>& out,
57
const
Teuchos::RCP<Teuchos::ParameterList>& plist) :
58
source_
(source),
// NOT allowed to be null
59
target_
(target),
// allowed to be null
60
out_
(::
Tpetra
::
Details
::makeValidVerboseStream (out)),
61
numSameIDs_
(0),
// Import/Export constructor may change this
62
distributor_
(source->getComm (),
out_
, plist),
// Im/Ex ctor will init
63
isLocallyComplete_
(true)
// Im/Ex ctor may change this
64
{
65
TEUCHOS_ASSERT( !
out_
.is_null () );
66
}
67
68
template
<
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
69
ImportExportData<LocalOrdinal, GlobalOrdinal, Node>::
70
ImportExportData (
const
Teuchos::RCP<const map_type>& source,
71
const
Teuchos::RCP<const map_type>& target) :
72
ImportExportData (source, target, Teuchos::null, Teuchos::null)
73
{}
74
75
template
<
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
76
ImportExportData<LocalOrdinal, GlobalOrdinal, Node>::
77
ImportExportData (
const
Teuchos::RCP<const map_type>& source,
78
const
Teuchos::RCP<const map_type>& target,
79
const
Teuchos::RCP<Teuchos::FancyOStream>& out) :
80
ImportExportData (source, target, out, Teuchos::null)
81
{}
82
83
template
<
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
84
ImportExportData<LocalOrdinal, GlobalOrdinal, Node>::
85
ImportExportData (
const
Teuchos::RCP<const map_type>& source,
86
const
Teuchos::RCP<const map_type>& target,
87
const
Teuchos::RCP<Teuchos::ParameterList>& plist) :
88
ImportExportData (source, target, Teuchos::null, plist)
89
{}
90
91
template
<
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
92
Teuchos::RCP<ImportExportData<LocalOrdinal, GlobalOrdinal, Node> >
93
ImportExportData<LocalOrdinal, GlobalOrdinal, Node>::
94
reverseClone
()
95
{
96
using
Teuchos::ArrayView;
97
using
data_type = ImportExportData<LocalOrdinal, GlobalOrdinal, Node>;
98
99
auto
tData = Teuchos::rcp (
new
data_type (
target_
,
source_
,
out_
));
100
101
// Things that stay the same
102
tData->numSameIDs_ =
numSameIDs_
;
103
104
// Things that reverse
105
tData->distributor_ = *
distributor_
.getReverse();
106
tData->permuteToLIDs_ =
permuteFromLIDs_
;
107
tData->permuteFromLIDs_ =
permuteToLIDs_
;
108
109
// Remotes / exports (easy part)
110
tData->exportLIDs_ =
remoteLIDs_
;
111
tData->remoteLIDs_ =
exportLIDs_
;
112
tData->exportPIDs_.resize (tData->exportLIDs_.extent (0));
113
114
// Remotes / exports (hard part) - extract the exportPIDs from the remotes of my distributor
115
const
size_t
NumReceives =
distributor_
.getNumReceives();
116
ArrayView<const int> ProcsFrom =
distributor_
.getProcsFrom();
117
ArrayView<const size_t> LengthsFrom =
distributor_
.getLengthsFrom();
118
119
// isLocallyComplete is a local predicate.
120
// It could be true in one direction but false in another.
121
122
bool
isLocallyComplete =
true
;
// by default
123
for
(
size_t
i = 0, j = 0; i < NumReceives; ++i) {
124
const
int
pid = ProcsFrom[i];
125
if
(pid == -1) {
126
isLocallyComplete =
false
;
127
}
128
for
(
size_t
k = 0; k < LengthsFrom[i]; ++k) {
129
tData->exportPIDs_[j] = pid;
130
++j;
131
}
132
}
133
tData->isLocallyComplete_ = isLocallyComplete;
134
135
return
tData;
136
}
137
138
}
// namespace Tpetra
139
140
// Explicit instantiation macro.
141
// Only invoke this when in the Tpetra namespace.
142
// Most users do not need to use this.
143
//
144
// LO: The local ordinal type.
145
// GO: The global ordinal type.
146
// NODE: The Kokkos Node type.
147
#define TPETRA_IMPORTEXPORTDATA_INSTANT(LO, GO, NODE) \
148
template class ImportExportData< LO , GO , NODE >;
149
150
#endif
// TPETRA_IMPORTEXPORTDATA_DEF_HPP
Tpetra::ImportExportData::permuteToLIDs_
Kokkos::DualView< LocalOrdinal *, device_type > permuteToLIDs_
Index of target Map LIDs to which to permute.
Definition
Tpetra_ImportExportData_decl.hpp:165
Tpetra::ImportExportData::reverseClone
Teuchos::RCP< ImportExportData< LocalOrdinal, GlobalOrdinal, Node > > reverseClone()
Copy the data, but reverse the direction of the transfer as well as reversing the Distributor.
Definition
Tpetra_ImportExportData_def.hpp:94
Tpetra::ImportExportData::distributor_
Distributor distributor_
Object that actually distributes (sends and receives) data.
Definition
Tpetra_ImportExportData_decl.hpp:225
Tpetra::ImportExportData::target_
const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > target_
Target Map of the Import or Export.
Definition
Tpetra_ImportExportData_decl.hpp:141
Tpetra::ImportExportData::remoteLIDs_
Kokkos::DualView< LocalOrdinal *, device_type > remoteLIDs_
"Incoming" indices.
Definition
Tpetra_ImportExportData_decl.hpp:186
Tpetra::ImportExportData::exportLIDs_
Kokkos::DualView< LocalOrdinal *, device_type > exportLIDs_
"Outgoing" local indices.
Definition
Tpetra_ImportExportData_decl.hpp:200
Tpetra::ImportExportData::out_
Teuchos::RCP< Teuchos::FancyOStream > out_
Output stream for verbose debugging output.
Definition
Tpetra_ImportExportData_decl.hpp:144
Tpetra::ImportExportData::isLocallyComplete_
bool isLocallyComplete_
Is this Export or Import locally complete?
Definition
Tpetra_ImportExportData_decl.hpp:243
Tpetra::ImportExportData::source_
const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > source_
Source Map of the Import or Export.
Definition
Tpetra_ImportExportData_decl.hpp:138
Tpetra::ImportExportData::numSameIDs_
size_t numSameIDs_
Number of initial identical indices.
Definition
Tpetra_ImportExportData_decl.hpp:217
Tpetra::ImportExportData::permuteFromLIDs_
Kokkos::DualView< LocalOrdinal *, device_type > permuteFromLIDs_
Index of source Map LIDs from which to permute.
Definition
Tpetra_ImportExportData_decl.hpp:178
Details
Implementation details of Tpetra.
Tpetra
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Generated by
1.17.0