MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_VectorDroppingBase.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// MueLu: A package for multigrid based preconditioning
4//
5// Copyright 2012 NTESS and the MueLu contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef MUELU_VECTORDROPPINGBASE_HPP
11#define MUELU_VECTORDROPPINGBASE_HPP
12
13#include "Xpetra_Matrix.hpp"
14
17#include "MueLu_Factory.hpp"
18
19namespace MueLu {
20
21template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
23 public:
24 using matrix_type = Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
25 using crs_matrix_type = Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
26 using GraphType = Xpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node>;
27 using local_matrix_type = typename crs_matrix_type::local_matrix_device_type;
28 using local_graph_type = typename GraphType::local_graph_device_type;
29 using rowptr_type = typename local_graph_type::row_map_type::non_const_type;
30 using device_type = typename Node::device_type;
31 using memory_space = typename device_type::memory_space;
32 using execution_space = typename local_matrix_type::execution_space;
33 using results_view = Kokkos::View<DecisionType*, memory_space>;
35 using range_type = Kokkos::RangePolicy<LocalOrdinal, execution_space>;
36 using LocalOrdinalVector = Xpetra::Vector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node>;
37 using nnz_count_type = Kokkos::pair<LocalOrdinal, LocalOrdinal>;
38 using block_indices_view_type = typename Kokkos::View<LocalOrdinal*, typename Node::device_type>;
39
40 template <class... Functors>
41 static void runDroppingFunctorsImpl(local_matrix_type& lclA, typename matrix_type::local_ordinal_type& blkPartSize, block_indices_view_type& colTranslation, results_view& results, rowptr_type& filtered_rowptr, rowptr_type& graph_rowptr, nnz_count_type& nnz, Functors&... functors) {
42 auto numNodes = graph_rowptr.extent(0) - 1;
43 auto range = range_type(0, numNodes);
44#if !defined(HAVE_MUELU_DEBUG)
45 auto countingFunctor = MatrixConstruction::VectorCountingFunctor(lclA, blkPartSize, colTranslation, results, filtered_rowptr, graph_rowptr, functors...);
46
47#else
48 auto debug = Misc::DebugFunctor(lclA, results);
49 auto countingFunctor = MatrixConstruction::VectorCountingFunctor(lclA, blkPartSize, colTranslation, results, filtered_rowptr, graph_rowptr, functors...);
50#endif
51 Kokkos::parallel_scan("MueLu::CoalesceDrop::CountEntries", range, countingFunctor, nnz);
52 }
53
54 template <class... Functors>
55 static void runDroppingFunctors(matrix_type& A, matrix_type& mergedA, typename matrix_type::local_ordinal_type& blkPartSize, block_indices_view_type& rowTranslation, block_indices_view_type& colTranslation, results_view& results, rowptr_type& filtered_rowptr, rowptr_type& graph_rowptr, nnz_count_type& nnz, const bool useBlocking, Level& level, const Factory& factory, Functors&... functors) {
56 auto lclA = A.getLocalMatrixDevice();
57 if (useBlocking) {
58 auto BlockNumber = level.template Get<Teuchos::RCP<LocalOrdinalVector>>("BlockNumber", factory.GetFactory("BlockNumber").get());
59 auto block_diagonalize = Misc::BlockDiagonalizeVectorFunctor(A, *BlockNumber, mergedA.getCrsGraph()->getImporter(), results, rowTranslation, colTranslation);
60
61 runDroppingFunctorsImpl(lclA, blkPartSize, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, block_diagonalize, functors...);
62 } else
63 runDroppingFunctorsImpl(lclA, blkPartSize, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, functors...);
64 }
65};
66
67} // namespace MueLu
68#endif
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Default implementation of FactoryAcceptor::GetFactory()
Class that holds all level-specific information.
Functor that executes a sequence of sub-functors on each block of rows.
Functor that drops all entries that are not on the block diagonal.
Functor that checks that all entries have been marked.
typename Kokkos::View< LocalOrdinal *, typename Node::device_type > block_indices_view_type
typename Node::device_type device_type
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > GraphType
Kokkos::pair< LocalOrdinal, LocalOrdinal > nnz_count_type
typename crs_matrix_type::local_matrix_device_type local_matrix_type
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > matrix_type
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > crs_matrix_type
static void runDroppingFunctorsImpl(local_matrix_type &lclA, typename matrix_type::local_ordinal_type &blkPartSize, block_indices_view_type &colTranslation, results_view &results, rowptr_type &filtered_rowptr, rowptr_type &graph_rowptr, nnz_count_type &nnz, Functors &... functors)
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::execution_space execution_space
Kokkos::RangePolicy< LocalOrdinal, execution_space > range_type
typename GraphType::local_graph_device_type local_graph_type
typename local_graph_type::row_map_type::non_const_type rowptr_type
Xpetra::Vector< LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node > LocalOrdinalVector
typename device_type::memory_space memory_space
static void runDroppingFunctors(matrix_type &A, matrix_type &mergedA, typename matrix_type::local_ordinal_type &blkPartSize, block_indices_view_type &rowTranslation, block_indices_view_type &colTranslation, results_view &results, rowptr_type &filtered_rowptr, rowptr_type &graph_rowptr, nnz_count_type &nnz, const bool useBlocking, Level &level, const Factory &factory, Functors &... functors)
Namespace for MueLu classes and methods.