8#include <ginkgo/ginkgo.hpp>
9#include <ginkgo/extensions/kokkos.hpp>
20std::shared_ptr<gko::Executor> getGkoExecutor(
Executor exec);
26gko::array<T> createGkoArray(std::shared_ptr<const gko::Executor> exec, std::span<T> values)
28 return gko::make_array_view(exec, values.size(), values.data());
38template<
typename ValueType,
typename IndexType>
39std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> createGkoMtx(
40 std::shared_ptr<const gko::Executor> exec,
const LinearSystem<ValueType, IndexType>& sys
43 auto nrows =
static_cast<gko::dim<2>::dimension_type
>(sys.rhs().size());
44 auto mtx = sys.view().matrix;
47 auto vals = gko::array<ValueType>::view(
49 static_cast<gko::size_type
>(mtx.values.size()),
50 const_cast<ValueType*
>(mtx.values.data())
53 auto col = gko::array<IndexType>::view(
55 static_cast<gko::size_type
>(mtx.colIdxs.size()),
56 const_cast<IndexType*
>(mtx.colIdxs.data())
59 auto row = gko::array<IndexType>::view(
61 static_cast<gko::size_type
>(mtx.rowOffs.size()),
62 const_cast<IndexType*
>(mtx.rowOffs.data())
64 return gko::share(gko::matrix::Csr<ValueType, IndexType>::create(
65 exec, gko::dim<2> {nrows, nrows}, vals, col, row
69template<
typename ValueType>
70std::shared_ptr<gko::matrix::Dense<ValueType>>
71createGkoDense(std::shared_ptr<const gko::Executor> exec, ValueType* ptr, localIdx s)
73 auto size =
static_cast<std::size_t
>(s);
74 return gko::share(gko::matrix::Dense<ValueType>::create(
75 exec, gko::dim<2> {size, 1}, createGkoArray(exec, std::span {ptr, size}), 1
79template<
typename ValueType>
80std::shared_ptr<gko::matrix::Dense<ValueType>>
81createGkoDense(std::shared_ptr<const gko::Executor> exec,
const ValueType* ptr, localIdx s)
83 auto size =
static_cast<std::size_t
>(s);
84 auto const_array_view = gko::array<ValueType>::const_view(exec, size, ptr);
85 return gko::share(gko::matrix::Dense<ValueType>::create(
86 exec, gko::dim<2> {size, 1}, const_array_view.copy_to_array(), 1
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor