44 #ifndef TPETRA_DETAILS_DETERMINELOCALTRIANGULARSTRUCTURE_HPP
45 #define TPETRA_DETAILS_DETERMINELOCALTRIANGULARSTRUCTURE_HPP
54 #include "Kokkos_Core.hpp"
89 template<
class LocalGraphType,
class LocalMapType>
107 const LocalMapType& rowMap,
108 const LocalMapType& colMap,
109 const bool ignoreMapsForTriangularStructure) :
113 ignoreMapsForTriangularStructure_ (ignoreMapsForTriangularStructure)
125 KOKKOS_INLINE_FUNCTION
void
126 join (
volatile result_type& dst,
127 const volatile result_type& src)
const
129 dst.diagCount += src.diagCount;
130 dst.maxNumRowEnt = (src.maxNumRowEnt > dst.maxNumRowEnt) ?
131 src.maxNumRowEnt : dst.maxNumRowEnt;
132 dst.couldBeLowerTriangular &= src.couldBeLowerTriangular;
133 dst.couldBeUpperTriangular &= src.couldBeUpperTriangular;
137 KOKKOS_INLINE_FUNCTION
void
138 operator () (
const typename LocalMapType::local_ordinal_type lclRow,
141 using LO =
typename LocalMapType::local_ordinal_type;
142 using GO =
typename LocalMapType::global_ordinal_type;
143 using LOT = typename ::Tpetra::Details::OrdinalTraits<LO>;
145 auto G_row = G_.rowConst (lclRow);
146 const LO numEnt = G_row.length;
153 const GO gblDiagCol = rowMap_.getGlobalElement (lclRow);
154 const LO lclDiagCol = colMap_.getLocalElement (gblDiagCol);
156 if (lclDiagCol != LOT::invalid ()) {
159 bool foundDiag =
false;
161 if (ignoreMapsForTriangularStructure_) {
162 for (LO k = 0; k < numEnt && ! foundDiag; ++k) {
163 const LO lclCol = G_row(k);
164 if (lclCol == lclDiagCol) {
172 if (numEnt > LO (0)) {
173 const LO smallestLclCol = G_row(0);
174 const LO largestLclCol = G_row(numEnt-1);
176 if (smallestLclCol < lclRow) {
179 if (lclRow < largestLclCol) {
185 for (LO k = 0; k < numEnt &&
190 const LO lclCol = G_row(k);
191 if (lclCol == lclDiagCol) {
195 const GO gblCol = colMap_.getGlobalElement (lclCol);
196 if (gblCol < gblDiagCol) {
199 if (gblDiagCol < gblCol) {
215 LocalMapType rowMap_;
216 LocalMapType colMap_;
217 bool ignoreMapsForTriangularStructure_;
239 template<
class LocalGraphType,
class LocalMapType>
240 LocalTriangularStructureResult<typename LocalMapType::local_ordinal_type>
242 const LocalMapType& rowMap,
243 const LocalMapType& colMap,
244 const bool ignoreMapsForTriangularStructure)
246 using LO =
typename LocalMapType::local_ordinal_type;
247 using execution_space =
typename LocalGraphType::device_type::execution_space;
248 using range_type = Kokkos::RangePolicy<execution_space, LO>;
253 Kokkos::parallel_reduce (
"Tpetra::Details::determineLocalTriangularStructure",
254 range_type (0, G.numRows ()),
255 functor_type (G, rowMap, colMap,
256 ignoreMapsForTriangularStructure),
264 #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).