Ginkgo Generated from branch based on master. Ginkgo version 1.7.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
mc64.hpp
1/*******************************<GINKGO LICENSE>******************************
2Copyright (c) 2017-2023, the Ginkgo authors
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions
7are met:
8
91. Redistributions of source code must retain the above copyright
10notice, this list of conditions and the following disclaimer.
11
122. Redistributions in binary form must reproduce the above copyright
13notice, this list of conditions and the following disclaimer in the
14documentation and/or other materials provided with the distribution.
15
163. Neither the name of the copyright holder nor the names of its
17contributors may be used to endorse or promote products derived from
18this software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31******************************<GINKGO LICENSE>*******************************/
32
33#ifndef GKO_PUBLIC_CORE_REORDER_MC64_HPP_
34#define GKO_PUBLIC_CORE_REORDER_MC64_HPP_
35
36
37#include <memory>
38
39
40#include <ginkgo/core/base/abstract_factory.hpp>
41#include <ginkgo/core/base/composition.hpp>
42#include <ginkgo/core/base/dim.hpp>
43#include <ginkgo/core/base/lin_op.hpp>
44#include <ginkgo/core/base/polymorphic_object.hpp>
45#include <ginkgo/core/base/types.hpp>
46#include <ginkgo/core/base/utils.hpp>
47#include <ginkgo/core/matrix/csr.hpp>
48#include <ginkgo/core/matrix/diagonal.hpp>
49#include <ginkgo/core/matrix/identity.hpp>
50#include <ginkgo/core/matrix/permutation.hpp>
51#include <ginkgo/core/matrix/sparsity_csr.hpp>
52#include <ginkgo/core/reorder/reordering_base.hpp>
53
54
55namespace gko {
56namespace experimental {
62namespace reorder {
63
64
72enum class mc64_strategy { max_diagonal_product, max_diagonal_sum };
73
74
104template <typename ValueType = default_precision, typename IndexType = int32>
106 : public EnablePolymorphicObject<Mc64<ValueType, IndexType>, LinOpFactory>,
107 public EnablePolymorphicAssignment<Mc64<ValueType, IndexType>> {
108public:
109 struct parameters_type;
110 friend class EnablePolymorphicObject<Mc64<ValueType, IndexType>,
113 Mc64<ValueType, IndexType>>;
114
115 using value_type = ValueType;
116 using index_type = IndexType;
119
121 : public enable_parameters_type<parameters_type, Mc64> {
126 strategy, mc64_strategy::max_diagonal_product);
127
133 1e-14);
134 };
135
141 const parameters_type& get_parameters() const { return parameters_; }
142
150 std::unique_ptr<result_type> generate(
151 std::shared_ptr<const LinOp> system_matrix) const;
152
154 static parameters_type build() { return {}; }
155
156private:
157 explicit Mc64(std::shared_ptr<const Executor> exec,
158 const parameters_type& params = {});
159
160 std::unique_ptr<LinOp> generate_impl(
161 std::shared_ptr<const LinOp> system_matrix) const override;
162
163 parameters_type parameters_;
164};
165
166
167} // namespace reorder
168} // namespace experimental
169} // namespace gko
170
171
172#endif // GKO_PUBLIC_CORE_REORDER_MC64_HPP_
The Composition class can be used to compose linear operators op1, op2, ..., opn and obtain the opera...
Definition composition.hpp:69
This mixin is used to enable a default PolymorphicObject::copy_from() implementation for objects that...
Definition polymorphic_object.hpp:752
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:691
A LinOpFactory represents a higher order mapping which transforms one linear operator into another.
Definition lin_op.hpp:414
The enable_parameters_type mixin is used to create a base implementation of the factory parameters st...
Definition abstract_factory.hpp:239
MC64 is an algorithm for permuting large entries to the diagonal of a sparse matrix.
Definition mc64.hpp:107
static parameters_type build()
Creates a new parameter_type to set up the factory.
Definition mc64.hpp:154
std::unique_ptr< result_type > generate(std::shared_ptr< const LinOp > system_matrix) const
const parameters_type & get_parameters() const
Returns the parameters used to construct the factory.
Definition mc64.hpp:141
CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matr...
Definition csr.hpp:146
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition abstract_factory.hpp:473
mc64_strategy
Strategy defining the goal of the MC64 reordering.
Definition mc64.hpp:72
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
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:354
mc64_strategy strategy
This parameter controls the goal of the permutation.
Definition mc64.hpp:126
remove_complex< ValueType > tolerance
This parameter controls the tolerance below which a weight is considered to be zero.
Definition mc64.hpp:133