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)
91 KOKKOS_INLINE_FUNCTION
void
92 join (result_type& dst,
93 const result_type& src)
const
95 dst.diagCount += src.diagCount;
96 dst.maxNumRowEnt = (src.maxNumRowEnt > dst.maxNumRowEnt) ?
97 src.maxNumRowEnt : dst.maxNumRowEnt;
98 dst.couldBeLowerTriangular &= src.couldBeLowerTriangular;
99 dst.couldBeUpperTriangular &= src.couldBeUpperTriangular;
103 KOKKOS_INLINE_FUNCTION
void
104 operator () (
const typename LocalMapType::local_ordinal_type lclRow,
107 using LO =
typename LocalMapType::local_ordinal_type;
108 using GO =
typename LocalMapType::global_ordinal_type;
109 using LOT = typename ::Tpetra::Details::OrdinalTraits<LO>;
111 auto G_row = G_.rowConst (lclRow);
112 const LO numEnt = G_row.length;
119 const GO gblDiagCol = rowMap_.getGlobalElement (lclRow);
120 const LO lclDiagCol = colMap_.getLocalElement (gblDiagCol);
122 if (lclDiagCol != LOT::invalid ()) {
125 bool foundDiag =
false;
127 if (ignoreMapsForTriangularStructure_) {
128 for (LO k = 0; k < numEnt && ! foundDiag; ++k) {
129 const LO lclCol = G_row(k);
130 if (lclCol == lclDiagCol) {
138 if (numEnt > LO (0)) {
139 const LO smallestLclCol = G_row(0);
140 const LO largestLclCol = G_row(numEnt-1);
142 if (smallestLclCol < lclRow) {
145 if (lclRow < largestLclCol) {
151 for (LO k = 0; k < numEnt &&
156 const LO lclCol = G_row(k);
157 if (lclCol == lclDiagCol) {
161 const GO gblCol = colMap_.getGlobalElement (lclCol);
162 if (gblCol < gblDiagCol) {
165 if (gblDiagCol < gblCol) {
181 LocalMapType rowMap_;
182 LocalMapType colMap_;
183 bool ignoreMapsForTriangularStructure_;
205 template<
class LocalGraphType,
class LocalMapType>
206 LocalTriangularStructureResult<typename LocalMapType::local_ordinal_type>
208 const LocalMapType& rowMap,
209 const LocalMapType& colMap,
210 const bool ignoreMapsForTriangularStructure)
212 using LO =
typename LocalMapType::local_ordinal_type;
213 using execution_space =
typename LocalGraphType::device_type::execution_space;
214 using range_type = Kokkos::RangePolicy<execution_space, LO>;
219 Kokkos::parallel_reduce (
"Tpetra::Details::determineLocalTriangularStructure",
220 range_type (0, G.numRows ()),
221 functor_type (G, rowMap, colMap,
222 ignoreMapsForTriangularStructure),
230 #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).