Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_RowGraph_def.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_ROWGRAPH_DEF_HPP
11#define TPETRA_ROWGRAPH_DEF_HPP
12
13namespace Tpetra {
14template <class LocalOrdinal, class GlobalOrdinal, class Node>
16 pack(const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
17 Teuchos::Array<GlobalOrdinal>& exports,
18 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
19 size_t& constantNumPackets) const {
20 using Teuchos::Array;
21 typedef LocalOrdinal LO;
22 typedef GlobalOrdinal GO;
23 typedef Map<LO, GO, Node> map_type;
24 const char tfecfFuncName[] = "packAndPrepare";
25
27 exportLIDs.size() != numPacketsPerLID.size(), std::runtime_error,
28 ": exportLIDs and numPacketsPerLID must have the same size.");
29
30 const map_type& srcMap = *(this->getRowMap());
32
33 // Set numPacketsPerLID[i] to the number of entries owned by the
34 // calling process in (local) row exportLIDs[i] of the graph, that
35 // the caller wants us to send out. Compute the total number of
36 // packets (that is, entries) owned by this process in all the
37 // rows that the caller wants us to send out.
38 size_t totalNumPackets = 0;
39 nonconst_global_inds_host_view_type row;
40 for (LO i = 0; i < exportLIDs.size(); ++i) {
41 const GO GID = srcMap.getGlobalElement(exportLIDs[i]);
42 size_t row_length = this->getNumEntriesInGlobalRow(GID);
45 }
46
47 exports.resize(totalNumPackets);
48
49 // Loop again over the rows to export, and pack rows of indices
50 // into the output buffer.
51 size_t exportsOffset = 0;
52 for (LO i = 0; i < exportLIDs.size(); ++i) {
53 const GO GID = srcMap.getGlobalElement(exportLIDs[i]);
54 size_t row_length = this->getNumEntriesInGlobalRow(GID);
55 Kokkos::resize(row, row_length);
56 size_t check_row_length = 0;
57 this->getGlobalRowCopy(GID, row, check_row_length);
58
59 for (size_t j = 0; j < row_length; ++j) {
60 exports[exportsOffset + j] = row[j];
61 }
62 exportsOffset += row.extent(0);
63 }
64}
65
66} // namespace Tpetra
67
68//
69// Explicit instantiation macro
70//
71// Must be expanded from within the Tpetra namespace!
72//
73
74#define TPETRA_ROWGRAPH_INSTANT(LO, GO, NODE) \
75 template class RowGraph<LO, GO, NODE>;
76
77#endif // TPETRA_ROWGRAPH_DEF_HPP
Struct that holds views of the contents of a CrsMatrix.
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.
Namespace Tpetra contains the class and methods constituting the Tpetra library.