Ginkgo Generated from branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
reordering_base.hpp
1// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_REORDER_REORDERING_BASE_HPP_
6#define GKO_PUBLIC_CORE_REORDER_REORDERING_BASE_HPP_
7
8
9#include <memory>
10
11
12#include <ginkgo/core/base/abstract_factory.hpp>
13#include <ginkgo/core/base/array.hpp>
14#include <ginkgo/core/base/executor.hpp>
15#include <ginkgo/core/base/lin_op.hpp>
16#include <ginkgo/core/base/polymorphic_object.hpp>
17#include <ginkgo/core/base/utils.hpp>
18
19
20namespace gko {
26namespace reorder {
27
28
34template <typename IndexType = int32>
36 : public EnableAbstractPolymorphicObject<ReorderingBase<IndexType>> {
37public:
38 using index_type = IndexType;
39
40 const array<index_type>& get_permutation_array() const
41 {
42 return permutation_array_;
43 }
44
45protected:
46 explicit ReorderingBase(std::shared_ptr<const gko::Executor> exec)
48 permutation_array_{exec}
49 {}
50
51 void set_permutation_array(array<index_type>& permutation_array)
52 {
53 permutation_array_ = permutation_array;
54 }
55
56private:
57 array<index_type> permutation_array_;
58};
59
60
67 std::shared_ptr<LinOp> system_matrix;
68
69 ReorderingBaseArgs(std::shared_ptr<LinOp> system_matrix)
70 : system_matrix{system_matrix}
71 {}
72};
73
74
78template <typename IndexType = int32>
81
82
98template <typename ConcreteFactory, typename ConcreteReorderingBase,
99 typename ParametersType, typename IndexType = int32,
100 typename PolymorphicBase = ReorderingBaseFactory<IndexType>>
102 EnableDefaultFactory<ConcreteFactory, ConcreteReorderingBase,
103 ParametersType, PolymorphicBase>;
104
105
124#define GKO_ENABLE_REORDERING_BASE_FACTORY(_reordering_base, _parameters_name, \
125 _factory_name) \
126public: \
127 const _parameters_name##_type& get_##_parameters_name() const \
128 { \
129 return _parameters_name##_; \
130 } \
131 \
132 class _factory_name \
133 : public ::gko::reorder::EnableDefaultReorderingBaseFactory< \
134 _factory_name, _reordering_base, _parameters_name##_type, \
135 IndexType> { \
136 friend class ::gko::EnablePolymorphicObject< \
137 _factory_name, ::gko::reorder::ReorderingBaseFactory<IndexType>>; \
138 friend class ::gko::enable_parameters_type<_parameters_name##_type, \
139 _factory_name>; \
140 explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec) \
141 : ::gko::reorder::EnableDefaultReorderingBaseFactory< \
142 _factory_name, _reordering_base, _parameters_name##_type, \
143 IndexType>(std::move(exec)) \
144 {} \
145 explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec, \
146 const _parameters_name##_type& parameters) \
147 : ::gko::reorder::EnableDefaultReorderingBaseFactory< \
148 _factory_name, _reordering_base, _parameters_name##_type, \
149 IndexType>(std::move(exec), parameters) \
150 {} \
151 }; \
152 friend ::gko::reorder::EnableDefaultReorderingBaseFactory< \
153 _factory_name, _reordering_base, _parameters_name##_type, IndexType>; \
154 \
155private: \
156 _parameters_name##_type _parameters_name##_; \
157 \
158public: \
159 static_assert(true, \
160 "This assert is used to counter the false positive extra " \
161 "semi-colon warnings")
162
163
164} // namespace reorder
165} // namespace gko
166
167
168#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:47
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:346
This mixin provides a default implementation of a concrete factory.
Definition abstract_factory.hpp:126
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition logger.hpp:25
The ReorderingBase class is a base class for all the reordering algorithms.
Definition reordering_base.hpp:36
The Ginkgo namespace.
Definition abstract_factory.hpp:20
std::int32_t int32
32-bit signed integral type.
Definition types.hpp:103
This struct is used to pass parameters to the EnableDefaultReorderingBaseFactory::generate() method.
Definition reordering_base.hpp:66