10 #ifndef MUELU_DROPPINGCOMMON_HPP
11 #define MUELU_DROPPINGCOMMON_HPP
13 #include "Kokkos_Core.hpp"
14 #include "Kokkos_ArithTraits.hpp"
15 #include "Xpetra_Access.hpp"
33 template <
class local_ordinal_type>
38 KOKKOS_FORCEINLINE_FUNCTION
47 template <
class local_matrix_type>
66 KOKKOS_FORCEINLINE_FUNCTION
68 auto row =
A.rowConst(rlid);
69 const size_t offset =
A.graph.row_map(rlid);
73 auto clid = row.colidx(k);
85 template <
class local_matrix_type>
107 KOKKOS_FORCEINLINE_FUNCTION
109 auto row =
A.rowConst(rlid);
110 const size_t offset =
A.graph.row_map(rlid);
114 auto clid = row.colidx(k);
126 template <
class local_matrix_type>
142 KOKKOS_FORCEINLINE_FUNCTION
144 auto row =
A.rowConst(rlid);
145 const size_t offset =
A.graph.row_map(rlid);
147 auto clid = row.colidx(k);
160 template <
class local_matrix_type>
176 KOKKOS_FORCEINLINE_FUNCTION
178 auto row =
A.rowConst(rlid);
179 const size_t offset =
A.graph.row_map(rlid);
181 auto clid = row.colidx(k);
182 if (clid >=
A.numRows()) {
193 template <
class local_matrix_type>
213 KOKKOS_FORCEINLINE_FUNCTION
215 auto row =
A.rowConst(rlid);
216 const size_t offset =
A.graph.row_map(rlid);
218 auto clid = row.colidx(k);
219 if ((
results(offset + k) ==
KEEP) && (rlid != clid))
224 auto clid = row.colidx(k);
237 template <
class local_matrix_type>
260 KOKKOS_FORCEINLINE_FUNCTION
262 auto row =
A.rowConst(rlid);
263 const size_t offset =
A.graph.row_map(rlid);
265 auto clid = row.colidx(k);
266 if ((
results(offset + k) ==
KEEP) && (rlid != clid))
272 auto clid = row.colidx(k);
285 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
306 :
A(A_.getLocalMatrixDevice())
307 ,
point_to_block(point_to_block_.getLocalViewDevice(Xpetra::Access::ReadOnly))
311 if (!importer.is_null()) {
313 ghosted_point_to_blockMV->doImport(point_to_block_, *importer,
Xpetra::INSERT);
319 KOKKOS_FORCEINLINE_FUNCTION
321 auto row =
A.rowConst(rlid);
322 const size_t offset =
A.graph.row_map(rlid);
324 auto clid = row.colidx(k);
338 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
364 :
A(A_.getLocalMatrixDevice())
365 ,
point_to_block(point_to_block_.getLocalViewDevice(Xpetra::Access::ReadOnly))
371 if (!importer.is_null()) {
379 KOKKOS_FORCEINLINE_FUNCTION
381 auto row =
A.rowConst(rlid);
382 const size_t offset =
A.graph.row_map(rlid);
385 auto clid = row.colidx(k);
400 template <
class local_matrix_type>
418 KOKKOS_FORCEINLINE_FUNCTION
420 auto row =
A.rowConst(rlid);
421 const size_t offset =
A.graph.row_map(rlid);
424 Kokkos::printf(
"No dropping decision was taken for entry (%d, %d)\n", rlid, row.colidx(k));
435 template <
class local_matrix_type>
451 KOKKOS_FORCEINLINE_FUNCTION
453 auto row =
A.rowConst(rlid);
454 const size_t offset =
A.graph.row_map(rlid);
457 auto clid = row.colidx(k);
458 if (clid >=
A.numRows())
460 auto row2 =
A.rowConst(clid);
461 const size_t offset2 =
A.graph.row_map(clid);
463 auto clid2 = row2.colidx(k2);
475 template <
class view_type,
class comparator_type>
476 KOKKOS_INLINE_FUNCTION
void serialHeapSort(view_type& v, comparator_type comparator) {
477 auto N = v.extent(0);
478 size_t start = N / 2;
490 while (2 * root + 1 < end) {
491 size_t child = 2 * root + 1;
492 if ((child + 1 < end) and (comparator(v(child), v(child + 1))))
495 if (comparator(v(root), v(child))) {
typename matrix_type::local_matrix_type local_matrix_type
Kokkos::View< local_ordinal_type *, memory_space > block_indices_view_type
typename block_indices_type::dual_view_type_const::t_dev local_block_indices_view_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::value_type scalar_type
DebugFunctor(local_matrix_type &A_, results_view &results_)
block_indices_view_type point_to_block
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::memory_space memory_space
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::value_type scalar_type
Functor that drops boundary nodes for a blockSize > 1 problem.
local_block_indices_view_type point_to_block
boundary_nodes_view boundaryNodes
Kokkos::View< DecisionType *, memory_space > results_view
Functor that marks singletons (all off-diagonal entries in a row are dropped) as boundary.
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::memory_space memory_space
BlockDiagonalizeFunctor(matrix_type &A_, block_indices_type &point_to_block_, results_view &results_)
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::ordinal_type local_ordinal_type
local_block_indices_view_type ghosted_point_to_block
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< DecisionType *, memory_space > results_view
local_block_indices_view_type point_to_block
Functor that checks that all entries have been marked.
typename local_matrix_type::memory_space memory_space
Kokkos::View< bool *, memory_space > boundary_nodes_view
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::memory_space memory_space
Functor that marks singletons (all off-diagonal entries in a row are dropped) as boundary.
typename local_matrix_type::value_type scalar_type
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< DecisionType *, memory_space > results_view
boundary_nodes_view boundaryNodes
typename local_matrix_type::ordinal_type local_ordinal_type
VectorDropBoundaryFunctor(local_matrix_type &A_, block_indices_view_type point_to_block_, boundary_nodes_view boundaryNodes_, results_view &results_)
DropOffRankFunctor(local_matrix_type &A_, results_view &results_)
typename block_indices_type::dual_view_type_const::t_dev local_block_indices_view_type
KOKKOS_INLINE_FUNCTION void serialHeapSort(view_type &v, comparator_type comparator)
typename local_matrix_type::value_type scalar_type
Teuchos::RCP< block_indices_type > ghosted_point_to_blockMV
Functor that symmetrizes the dropping decisions.
Functor that drops boundary nodes for a blockSize == 1 problem.
Functor that drops off-rank entries.
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::memory_space memory_space
id_translation_type row_translation
Kokkos::View< const bool *, memory_space > boundary_nodes_view
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::memory_space memory_space
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::ordinal_type local_ordinal_type
local_block_indices_view_type ghosted_point_to_block
Kokkos::View< bool *, memory_space > boundary_nodes_view
boundary_nodes_view boundaryNodes
typename matrix_type::local_matrix_type local_matrix_type
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Functor that drops all entries that are not on the block diagonal.
Functor that marks diagonal as kept, unless the are already marked as boundary.
Kokkos::View< DecisionType *, memory_space > results_view
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
MarkSingletonFunctor(local_matrix_type &A_, boundary_nodes_view boundaryNodes_, results_view &results_)
typename local_matrix_type::value_type scalar_type
block_indices_view_type point_to_block
virtual RCP< const CrsGraph > getCrsGraph() const =0
BlockDiagonalizeVectorFunctor(matrix_type &A_, block_indices_type &point_to_block_, Teuchos::RCP< const map_type > non_unique_map_, results_view &results_, id_translation_type row_translation_, id_translation_type col_translation_)
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::memory_space memory_space
Kokkos::View< local_ordinal_type *, memory_space > id_translation_type
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::value_type scalar_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Kokkos::View< bool *, memory_space > boundary_nodes_view
SymmetrizeFunctor(local_matrix_type &A_, results_view &results_)
Kokkos::View< DecisionType *, memory_space > results_view
MarkSingletonVectorFunctor(local_matrix_type &A_, block_indices_view_type point_to_block_, boundary_nodes_view boundaryNodes_, results_view &results_)
Kokkos::View< const bool *, memory_space > boundary_nodes_view
PointwiseDropBoundaryFunctor(local_matrix_type &A_, boundary_nodes_view boundaryNodes_, results_view &results_)
Kokkos::View< DecisionType *, memory_space > results_view
Functor that drops all entries that are not on the block diagonal.
Kokkos::View< DecisionType *, memory_space > results_view
id_translation_type col_translation
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< local_ordinal_type *, memory_space > block_indices_view_type
typename local_matrix_type::value_type scalar_type
KeepDiagonalFunctor(local_matrix_type &A_, results_view &results_)
Kokkos::View< DecisionType *, memory_space > results_view
static RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &source, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
typename local_matrix_type::value_type scalar_type
boundary_nodes_view boundaryNodes