Tpetra parallel linear algebra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
Tpetra_RowGraph_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_ROWGRAPH_DEF_HPP
43
#define TPETRA_ROWGRAPH_DEF_HPP
44
45
namespace
Tpetra
{
46
template
<
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
47
void
48
RowGraph<LocalOrdinal,GlobalOrdinal,Node>::
49
pack
(
const
Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
50
Teuchos::Array<GlobalOrdinal>& exports,
51
const
Teuchos::ArrayView<size_t>& numPacketsPerLID,
52
size_t
& constantNumPackets)
const
53
{
54
using
Teuchos::Array;
55
typedef
LocalOrdinal LO;
56
typedef
GlobalOrdinal GO;
57
typedef
Map<LO, GO, Node>
map_type
;
58
const
char
tfecfFuncName[] =
"packAndPrepare"
;
59
60
TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
61
exportLIDs.size() != numPacketsPerLID.size(), std::runtime_error,
62
": exportLIDs and numPacketsPerLID must have the same size."
);
63
64
const
map_type
& srcMap = * (this->
getRowMap
());
65
constantNumPackets = 0;
66
67
// Set numPacketsPerLID[i] to the number of entries owned by the
68
// calling process in (local) row exportLIDs[i] of the graph, that
69
// the caller wants us to send out. Compute the total number of
70
// packets (that is, entries) owned by this process in all the
71
// rows that the caller wants us to send out.
72
size_t
totalNumPackets = 0;
73
nonconst_global_inds_host_view_type row;
74
for
(LO i = 0; i < exportLIDs.size (); ++i) {
75
const
GO GID = srcMap.getGlobalElement (exportLIDs[i]);
76
size_t
row_length = this->
getNumEntriesInGlobalRow
(GID);
77
numPacketsPerLID[i] = row_length;
78
totalNumPackets += row_length;
79
}
80
81
exports.resize (totalNumPackets);
82
83
// Loop again over the rows to export, and pack rows of indices
84
// into the output buffer.
85
size_t
exportsOffset = 0;
86
for
(LO i = 0; i < exportLIDs.size (); ++i) {
87
const
GO GID = srcMap.getGlobalElement (exportLIDs[i]);
88
size_t
row_length = this->
getNumEntriesInGlobalRow
(GID);
89
Kokkos::resize(row,row_length);
90
size_t
check_row_length = 0;
91
this->
getGlobalRowCopy
(GID, row, check_row_length);
92
93
for
(
size_t
j=0; j<row_length; ++j) {
94
exports[exportsOffset+j] = row[j];
95
}
96
exportsOffset += row.extent(0);
97
}
98
}
99
100
}
// namespace Tpetra
101
102
//
103
// Explicit instantiation macro
104
//
105
// Must be expanded from within the Tpetra namespace!
106
//
107
108
#define TPETRA_ROWGRAPH_INSTANT(LO,GO,NODE) \
109
template class RowGraph< LO , GO , NODE >;
110
111
#endif
// TPETRA_ROWGRAPH_DEF_HPP
Tpetra::map_type
Tpetra::Map
A parallel distribution of indices over processes.
Definition
Tpetra_Map_decl.hpp:228
Tpetra::RowGraph::pack
virtual void pack(const Teuchos::ArrayView< const LocalOrdinal > &exportLIDs, Teuchos::Array< GlobalOrdinal > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets) const
Pack this object's data for Import or Export.
Definition
Tpetra_RowGraph_def.hpp:49
Tpetra::RowGraph::getRowMap
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const =0
The Map that describes this graph's distribution of rows over processes.
Tpetra::RowGraph::getGlobalRowCopy
virtual void getGlobalRowCopy(const GlobalOrdinal gblRow, nonconst_global_inds_host_view_type &gblColInds, size_t &numColInds) const =0
Get a copy of the global column indices in a given row of the graph.
Tpetra::RowGraph::getNumEntriesInGlobalRow
virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const =0
Returns the current number of entries on this node in the specified global row.
Tpetra
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Generated by
1.17.0