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
reordering_base.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_REORDERING_BASE_HPP_
34#define GKO_PUBLIC_CORE_REORDER_REORDERING_BASE_HPP_
35
36
37#include <memory>
38
39
40#include <ginkgo/core/base/abstract_factory.hpp>
41#include <ginkgo/core/base/array.hpp>
42#include <ginkgo/core/base/executor.hpp>
43#include <ginkgo/core/base/lin_op.hpp>
44#include <ginkgo/core/base/polymorphic_object.hpp>
45#include <ginkgo/core/base/utils.hpp>
46
47
48namespace gko {
54namespace reorder {
55
56
62template <typename IndexType = int32>
64 : public EnableAbstractPolymorphicObject<ReorderingBase<IndexType>> {
65public:
66 using index_type = IndexType;
67
68 const array<index_type>& get_permutation_array() const
69 {
70 return permutation_array_;
71 }
72
73protected:
74 explicit ReorderingBase(std::shared_ptr<const gko::Executor> exec)
76 permutation_array_{exec}
77 {}
78
79 void set_permutation_array(array<index_type>& permutation_array)
80 {
81 permutation_array_ = permutation_array;
82 }
83
84private:
85 array<index_type> permutation_array_;
86};
87
88
95 std::shared_ptr<LinOp> system_matrix;
96
97 ReorderingBaseArgs(std::shared_ptr<LinOp> system_matrix)
98 : system_matrix{system_matrix}
99 {}
100};
101
102
106template <typename IndexType = int32>
109
110
126template <typename ConcreteFactory, typename ConcreteReorderingBase,
127 typename ParametersType, typename IndexType = int32,
128 typename PolymorphicBase = ReorderingBaseFactory<IndexType>>
131 ParametersType, PolymorphicBase>;
132
133
152#define GKO_ENABLE_REORDERING_BASE_FACTORY(_reordering_base, _parameters_name, \
153 _factory_name) \
154public: \
155 const _parameters_name##_type& get_##_parameters_name() const \
156 { \
157 return _parameters_name##_; \
158 } \
159 \
160 class _factory_name \
161 : public ::gko::reorder::EnableDefaultReorderingBaseFactory< \
162 _factory_name, _reordering_base, _parameters_name##_type, \
163 IndexType> { \
164 friend class ::gko::EnablePolymorphicObject< \
165 _factory_name, ::gko::reorder::ReorderingBaseFactory<IndexType>>; \
166 friend class ::gko::enable_parameters_type<_parameters_name##_type, \
167 _factory_name>; \
168 explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec) \
169 : ::gko::reorder::EnableDefaultReorderingBaseFactory< \
170 _factory_name, _reordering_base, _parameters_name##_type, \
171 IndexType>(std::move(exec)) \
172 {} \
173 explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec, \
174 const _parameters_name##_type& parameters) \
175 : ::gko::reorder::EnableDefaultReorderingBaseFactory< \
176 _factory_name, _reordering_base, _parameters_name##_type, \
177 IndexType>(std::move(exec), parameters) \
178 {} \
179 }; \
180 friend ::gko::reorder::EnableDefaultReorderingBaseFactory< \
181 _factory_name, _reordering_base, _parameters_name##_type, IndexType>; \
182 \
183private: \
184 _parameters_name##_type _parameters_name##_; \
185 \
186public: \
187 static_assert(true, \
188 "This assert is used to counter the false positive extra " \
189 "semi-colon warnings")
190
191
192} // namespace reorder
193} // namespace gko
194
195
196#endif // GKO_PUBLIC_CORE_REORDER_REORDERING_BASE_HPP_
The AbstractFactory is a generic interface template that enables easy implementation of the abstract ...
Definition abstract_factory.hpp:75
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:374
This mixin provides a default implementation of a concrete factory.
Definition abstract_factory.hpp:154
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition array.hpp:187
The ReorderingBase class is a base class for all the reordering algorithms.
Definition reordering_base.hpp:64
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
std::int32_t int32
32-bit signed integral type.
Definition types.hpp:137
This struct is used to pass parameters to the EnableDefaultReorderingBaseFactory::generate() method.
Definition reordering_base.hpp:94