10 #ifndef TPETRA_DETAILS_DETERMINELOCALTRIANGULARSTRUCTURE_HPP
11 #define TPETRA_DETAILS_DETERMINELOCALTRIANGULARSTRUCTURE_HPP
20 #include "Kokkos_Core.hpp"
55 template <
class LocalGraphType,
class LocalMapType>
73 const LocalMapType& rowMap,
74 const LocalMapType& colMap,
75 const bool ignoreMapsForTriangularStructure)
79 , ignoreMapsForTriangularStructure_(ignoreMapsForTriangularStructure) {}
89 KOKKOS_INLINE_FUNCTION
void
90 join(result_type& dst,
91 const result_type& src)
const {
92 dst.diagCount += src.diagCount;
93 dst.maxNumRowEnt = (src.maxNumRowEnt > dst.maxNumRowEnt) ? src.maxNumRowEnt : dst.maxNumRowEnt;
94 dst.couldBeLowerTriangular &= src.couldBeLowerTriangular;
95 dst.couldBeUpperTriangular &= src.couldBeUpperTriangular;
99 KOKKOS_INLINE_FUNCTION
void
100 operator()(
const typename LocalMapType::local_ordinal_type lclRow,
102 using LO =
typename LocalMapType::local_ordinal_type;
103 using GO =
typename LocalMapType::global_ordinal_type;
104 using LOT = typename ::Tpetra::Details::OrdinalTraits<LO>;
106 auto G_row = G_.rowConst(lclRow);
107 const LO numEnt = G_row.length;
113 const GO gblDiagCol = rowMap_.getGlobalElement(lclRow);
114 const LO lclDiagCol = colMap_.getLocalElement(gblDiagCol);
116 if (lclDiagCol != LOT::invalid()) {
119 bool foundDiag =
false;
121 if (ignoreMapsForTriangularStructure_) {
122 for (LO k = 0; k < numEnt && !foundDiag; ++k) {
123 const LO lclCol = G_row(k);
124 if (lclCol == lclDiagCol) {
132 if (numEnt > LO(0)) {
133 const LO smallestLclCol = G_row(0);
134 const LO largestLclCol = G_row(numEnt - 1);
136 if (smallestLclCol < lclRow) {
139 if (lclRow < largestLclCol) {
144 for (LO k = 0; k < numEnt &&
149 const LO lclCol = G_row(k);
150 if (lclCol == lclDiagCol) {
153 const GO gblCol = colMap_.getGlobalElement(lclCol);
154 if (gblCol < gblDiagCol) {
157 if (gblDiagCol < gblCol) {
173 LocalMapType rowMap_;
174 LocalMapType colMap_;
175 bool ignoreMapsForTriangularStructure_;
197 template <
class LocalGraphType,
class LocalMapType>
198 LocalTriangularStructureResult<typename LocalMapType::local_ordinal_type>
200 const LocalMapType& rowMap,
201 const LocalMapType& colMap,
202 const bool ignoreMapsForTriangularStructure) {
203 using LO =
typename LocalMapType::local_ordinal_type;
204 using execution_space =
typename LocalGraphType::device_type::execution_space;
205 using range_type = Kokkos::RangePolicy<execution_space, LO>;
210 Kokkos::parallel_reduce(
"Tpetra::Details::determineLocalTriangularStructure",
211 range_type(0, G.numRows()),
212 functor_type(G, rowMap, colMap,
213 ignoreMapsForTriangularStructure),
221 #endif // TPETRA_DETAILS_DETERMINELOCALTRIANGULARSTRUCTURE_HPP
Import KokkosSparse::OrdinalTraits, a traits class for "invalid" (flag) values of integer types...
bool couldBeLowerTriangular
Whether the graph is locally structurally lower triangular.
LO maxNumRowEnt
Maximum number of entries over all local rows.
KOKKOS_INLINE_FUNCTION void init(result_type &dst) const
Set the initial value of the reduction result.
KOKKOS_INLINE_FUNCTION void operator()(const typename LocalMapType::local_ordinal_type lclRow, result_type &result) const
Reduction operator: result is (diagonal count, error count).
DetermineLocalTriangularStructure(const LocalGraphType &G, const LocalMapType &rowMap, const LocalMapType &colMap, const bool ignoreMapsForTriangularStructure)
Constructor.
Return value of determineLocalTriangularStructure.
LocalTriangularStructureResult< typename LocalMapType::local_ordinal_type > determineLocalTriangularStructure(const LocalGraphType &G, const LocalMapType &rowMap, const LocalMapType &colMap, const bool ignoreMapsForTriangularStructure)
Count the local number of diagonal entries in a local sparse graph, and determine whether the local p...
bool couldBeUpperTriangular
Whether the graph is locally structurally upper triangular.
LO diagCount
(Local) number of populated diagonal entries.
Implementation of Tpetra::Details::determineLocalTriangularStructure (which see below).