Ginkgo  Generated from pipelines/1556235455 branch based on develop. Ginkgo version 1.9.0
A numerical linear algebra library targeting many-core architectures
mc64.hpp
1 // SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_REORDER_MC64_HPP_
6 #define GKO_PUBLIC_CORE_REORDER_MC64_HPP_
7 
8 
9 #include <memory>
10 
11 #include <ginkgo/core/base/abstract_factory.hpp>
12 #include <ginkgo/core/base/composition.hpp>
13 #include <ginkgo/core/base/dim.hpp>
14 #include <ginkgo/core/base/lin_op.hpp>
15 #include <ginkgo/core/base/polymorphic_object.hpp>
16 #include <ginkgo/core/base/types.hpp>
17 #include <ginkgo/core/base/utils.hpp>
18 #include <ginkgo/core/matrix/csr.hpp>
19 #include <ginkgo/core/matrix/diagonal.hpp>
20 #include <ginkgo/core/matrix/identity.hpp>
21 #include <ginkgo/core/matrix/permutation.hpp>
22 #include <ginkgo/core/matrix/sparsity_csr.hpp>
23 #include <ginkgo/core/reorder/reordering_base.hpp>
24 
25 
26 namespace gko {
27 namespace experimental {
33 namespace reorder {
34 
35 
43 enum class mc64_strategy { max_diagonal_product, max_diagonal_sum };
44 
45 
75 template <typename ValueType = default_precision, typename IndexType = int32>
76 class Mc64 final
77  : public EnablePolymorphicObject<Mc64<ValueType, IndexType>, LinOpFactory>,
78  public EnablePolymorphicAssignment<Mc64<ValueType, IndexType>> {
79 public:
80  struct parameters_type;
81  friend class EnablePolymorphicObject<Mc64<ValueType, IndexType>,
82  LinOpFactory>;
84  Mc64<ValueType, IndexType>>;
85 
86  using value_type = ValueType;
87  using index_type = IndexType;
90 
92  : public enable_parameters_type<parameters_type, Mc64> {
97  strategy, mc64_strategy::max_diagonal_product);
98 
104  1e-14);
105  };
106 
112  const parameters_type& get_parameters() const { return parameters_; }
113 
121  std::unique_ptr<result_type> generate(
122  std::shared_ptr<const LinOp> system_matrix) const;
123 
125  static parameters_type build() { return {}; }
126 
127 private:
128  explicit Mc64(std::shared_ptr<const Executor> exec,
129  const parameters_type& params = {});
130 
131  std::unique_ptr<LinOp> generate_impl(
132  std::shared_ptr<const LinOp> system_matrix) const override;
133 
134  parameters_type parameters_;
135 };
136 
137 
138 } // namespace reorder
139 } // namespace experimental
140 } // namespace gko
141 
142 
143 #endif // GKO_PUBLIC_CORE_REORDER_MC64_HPP_
gko::experimental::reorder::Mc64
MC64 is an algorithm for permuting large entries to the diagonal of a sparse matrix.
Definition: mc64.hpp:76
gko::matrix::Csr
CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matr...
Definition: matrix.hpp:28
gko::experimental::reorder::Mc64::parameters_type
Definition: mc64.hpp:91
gko::experimental::reorder::Mc64::parameters_type::tolerance
remove_complex< ValueType > tolerance
This parameter controls the tolerance below which a weight is considered to be zero.
Definition: mc64.hpp:104
gko::EnablePolymorphicAssignment
This mixin is used to enable a default PolymorphicObject::copy_from() implementation for objects that...
Definition: polymorphic_object.hpp:723
GKO_FACTORY_PARAMETER_SCALAR
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition: abstract_factory.hpp:445
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::Composition
The Composition class can be used to compose linear operators op1, op2, ..., opn and obtain the opera...
Definition: composition.hpp:39
gko::experimental::reorder::Mc64::parameters_type::strategy
mc64_strategy strategy
This parameter controls the goal of the permutation.
Definition: mc64.hpp:97
gko::experimental::reorder::Mc64::generate
std::unique_ptr< result_type > generate(std::shared_ptr< const LinOp > system_matrix) const
gko::experimental::reorder::Mc64::get_parameters
const parameters_type & get_parameters() const
Returns the parameters used to construct the factory.
Definition: mc64.hpp:112
gko::experimental::reorder::mc64_strategy
mc64_strategy
Strategy defining the goal of the MC64 reordering.
Definition: mc64.hpp:43
gko::LinOpFactory
A LinOpFactory represents a higher order mapping which transforms one linear operator into another.
Definition: lin_op.hpp:384
gko::experimental::reorder::Mc64::build
static parameters_type build()
Creates a new parameter_type to set up the factory.
Definition: mc64.hpp:125
gko::enable_parameters_type
The enable_parameters_type mixin is used to create a base implementation of the factory parameters st...
Definition: abstract_factory.hpp:211
gko::remove_complex
typename detail::remove_complex_s< T >::type remove_complex
Obtain the type which removed the complex of complex/scalar type or the template parameter of class b...
Definition: math.hpp:325
gko::EnablePolymorphicObject
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition: polymorphic_object.hpp:661