Ginkgo: ginkgo/core/reorder/reordering_base.hpp Source File

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.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#include <ginkgo/core/base/abstract_factory.hpp>
12#include <ginkgo/core/base/array.hpp>
13#include <ginkgo/core/base/executor.hpp>
14#include <ginkgo/core/base/lin_op.hpp>
15#include <ginkgo/core/base/polymorphic_object.hpp>
16#include <ginkgo/core/base/utils.hpp>
17
18
19namespace gko {
25namespace reorder {
26
27
33template <typename IndexType = int32>
34 class ReorderingBase
35 : public EnableAbstractPolymorphicObject<ReorderingBase<IndexType>> {
36public:
37 using index_type = IndexType;
38
39 const array<index_type>& get_permutation_array() const
40 {
41 return permutation_array_;
42 }
43
44protected:
45 explicit ReorderingBase(std::shared_ptr<const gko::Executor> exec)
46 : EnableAbstractPolymorphicObject<ReorderingBase>(exec),
47 permutation_array_{exec}
48 {}
49
50 void set_permutation_array(array<index_type>& permutation_array)
51 {
52 permutation_array_ = permutation_array;
53 }
54
55private:
56 array<index_type> permutation_array_;
57};
58
59
65 struct ReorderingBaseArgs {
66 std::shared_ptr<LinOp> system_matrix;
67
68 ReorderingBaseArgs(std::shared_ptr<LinOp> system_matrix)
69 : system_matrix{system_matrix}
70 {}
71};
72
73
77template <typename IndexType = int32>
78 using ReorderingBaseFactory =
79 AbstractFactory<ReorderingBase<IndexType>, ReorderingBaseArgs>;
80
81
97template <typename ConcreteFactory, typename ConcreteReorderingBase,
98 typename ParametersType, typename IndexType = int32,
99 typename PolymorphicBase = ReorderingBaseFactory<IndexType>>
100 using EnableDefaultReorderingBaseFactory =
101 EnableDefaultFactory<ConcreteFactory, ConcreteReorderingBase,
102 ParametersType, PolymorphicBase>;
103
104
123#define GKO_ENABLE_REORDERING_BASE_FACTORY(_reordering_base, _parameters_name, \
124 _factory_name) \
125public: \
126 const _parameters_name##_type& get_##_parameters_name() const \
127 { \
128 return _parameters_name##_; \
129 } \
130 \
131 class _factory_name \
132 : public ::gko::reorder::EnableDefaultReorderingBaseFactory< \
133 _factory_name, _reordering_base, _parameters_name##_type, \
134 IndexType> { \
135 friend class ::gko::EnablePolymorphicObject< \
136 _factory_name, ::gko::reorder::ReorderingBaseFactory<IndexType>>; \
137 friend class ::gko::enable_parameters_type<_parameters_name##_type, \
138 _factory_name>; \
139 explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec) \
140 : ::gko::reorder::EnableDefaultReorderingBaseFactory< \
141 _factory_name, _reordering_base, _parameters_name##_type, \
142 IndexType>(std::move(exec)) \
143 {} \
144 explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec, \
145 const _parameters_name##_type& parameters) \
146 : ::gko::reorder::EnableDefaultReorderingBaseFactory< \
147 _factory_name, _reordering_base, _parameters_name##_type, \
148 IndexType>(std::move(exec), parameters) \
149 {} \
150 }; \
151 friend ::gko::reorder::EnableDefaultReorderingBaseFactory< \
152 _factory_name, _reordering_base, _parameters_name##_type, IndexType>; \
153 \
154private: \
155 _parameters_name##_type _parameters_name##_; \
156 \
157public: \
158 static_assert(true, \
159 "This assert is used to counter the false positive extra " \
160 "semi-colon warnings")
161
162
163} // namespace reorder
164} // namespace gko
165
166
167#endif // GKO_PUBLIC_CORE_REORDER_REORDERING_BASE_HPP_
gko::AbstractFactory
The AbstractFactory is a generic interface template that enables easy implementation of the abstract ...
Definition abstract_factory.hpp:47
gko::EnableDefaultFactory
This mixin provides a default implementation of a concrete factory.
Definition abstract_factory.hpp:126
gko::array
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition array.hpp:166
gko::reorder
The Reorder namespace.
Definition rcm.hpp:31
gko::reorder::EnableDefaultReorderingBaseFactory
EnableDefaultFactory< ConcreteFactory, ConcreteReorderingBase, ParametersType, PolymorphicBase > EnableDefaultReorderingBaseFactory
This is an alias for the EnableDefaultFactory mixin, which correctly sets the template parameters to ...
Definition reordering_base.hpp:100
gko::reorder::ReorderingBaseFactory
AbstractFactory< ReorderingBase< IndexType >, ReorderingBaseArgs > ReorderingBaseFactory
Declares an Abstract Factory specialized for ReorderingBases.
Definition reordering_base.hpp:78
gko
The Ginkgo namespace.
Definition abstract_factory.hpp:20
gko::int32
std::int32_t int32
32-bit signed integral type.
Definition types.hpp:107
gko::reorder::ReorderingBaseArgs
This struct is used to pass parameters to the EnableDefaultReorderingBaseFactory::generate() method.
Definition reordering_base.hpp:65