Ginkgo  Generated from pipelines/1556235455 branch based on develop. Ginkgo version 1.9.0
A numerical linear algebra library targeting many-core architectures
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 
19 namespace gko {
25 namespace reorder {
26 
27 
33 template <typename IndexType = int32>
35  : public EnableAbstractPolymorphicObject<ReorderingBase<IndexType>> {
36 public:
37  using index_type = IndexType;
38 
39  const array<index_type>& get_permutation_array() const
40  {
41  return permutation_array_;
42  }
43 
44 protected:
45  explicit ReorderingBase(std::shared_ptr<const gko::Executor> 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 
55 private:
56  array<index_type> permutation_array_;
57 };
58 
59 
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 
77 template <typename IndexType = int32>
80 
81 
97 template <typename ConcreteFactory, typename ConcreteReorderingBase,
98  typename ParametersType, typename IndexType = int32,
99  typename PolymorphicBase = ReorderingBaseFactory<IndexType>>
101  EnableDefaultFactory<ConcreteFactory, ConcreteReorderingBase,
102  ParametersType, PolymorphicBase>;
103 
104 
123 #define GKO_ENABLE_REORDERING_BASE_FACTORY(_reordering_base, _parameters_name, \
124  _factory_name) \
125 public: \
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  \
154 private: \
155  _parameters_name##_type _parameters_name##_; \
156  \
157 public: \
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:45
gko::EnableAbstractPolymorphicObject
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition: polymorphic_object.hpp:345
gko::EnableDefaultFactory
This mixin provides a default implementation of a concrete factory.
Definition: abstract_factory.hpp:124
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::array< index_type >
gko::reorder::ReorderingBase
The ReorderingBase class is a base class for all the reordering algorithms.
Definition: reordering_base.hpp:34
gko::int32
std::int32_t int32
32-bit signed integral type.
Definition: types.hpp:103
gko::reorder::ReorderingBaseArgs
This struct is used to pass parameters to the EnableDefaultReorderingBaseFactory::generate() method.
Definition: reordering_base.hpp:65