33#ifndef GKO_PUBLIC_CORE_SOLVER_WORKSPACE_HPP_
34#define GKO_PUBLIC_CORE_SOLVER_WORKSPACE_HPP_
40#include <ginkgo/core/matrix/dense.hpp>
53 template <
typename ValueType>
56 auto container = std::make_unique<concrete_container<ValueType>>(
57 std::move(exec), size);
63 bool empty()
const {
return data_.get() ==
nullptr; }
65 template <
typename ValueType>
71 template <
typename ValueType>
78 template <
typename ValueType>
86 void clear() { data_.reset(); }
89 struct generic_container {
90 virtual ~generic_container() =
default;
93 template <
typename ValueType>
94 struct concrete_container : generic_container {
95 template <
typename...
Args>
102 std::unique_ptr<generic_container> data_;
108 workspace(std::shared_ptr<const Executor> exec) : exec_{std::
move(exec)} {}
110 workspace(
const workspace&
other) : workspace{
other.get_executor()} {}
112 workspace(workspace&&
other) : workspace{
other.get_executor()}
117 workspace& operator=(
const workspace&
other) {
return *
this; }
119 workspace& operator=(workspace&&
other)
125 template <
typename LinOpType,
typename CreateOperation>
130 GKO_ASSERT(
op_id >= 0 &&
op_id < operators_.size());
144 if (
op->get_size() != size ||
op->get_stride() != stride) {
152 const LinOp* get_op(
int op_id)
const
154 GKO_ASSERT(
op_id >= 0 &&
op_id < operators_.size());
155 return operators_[
op_id].get();
158 template <
typename ValueType>
173 template <
typename ValueType>
177 if (
result.get_num_elems() != size) {
178 result.resize_and_reset(size);
183 std::shared_ptr<const Executor> get_executor()
const {
return exec_; }
188 arrays_.resize(num_arrays);
193 for (
auto&
op : operators_) {
196 for (
auto&
array : arrays_) {
202 std::shared_ptr<const Executor> exec_;
203 std::vector<std::unique_ptr<LinOp>> operators_;
204 std::vector<any_array> arrays_;
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:120
@ array
The matrix should be written as dense matrix in column-major order.