1#ifndef __SIMULATION_EIGEN_KOKKOS_HPP__
2#define __SIMULATION_EIGEN_KOKKOS_HPP__
7#include <Kokkos_Core.hpp>
8#include <common/common.hpp>
9#include <common/traits.hpp>
13constexpr auto EigenLayoutRight = Eigen::RowMajor;
14constexpr auto EigenLayoutLeft = Eigen::ColMajor;
15constexpr auto CompileMatrixSizeEigen = -1;
18template <
int Layout, FloatingPo
intType ftype>
19using MatrixType = Eigen::
20 Matrix<ftype, CompileMatrixSizeEigen, CompileMatrixSizeEigen, Layout>;
22template <FloatingPo
intType ftype>
23using ColMajorMatrixtype = MatrixType<EigenLayoutLeft, ftype>;
25template <
int Layout, FloatingPo
intType ftype>
26using SparseMatrixType = Eigen::SparseMatrix<ftype, Layout>;
28using DiagonalType = Eigen::DiagonalMatrix<double, CompileMatrixSizeEigen>;
38 using type = Kokkos::LayoutLeft;
43 using type = Kokkos::LayoutRight;
46template <
typename ExecSpace,
49 typename... MemoryTrait>
50using KokkosScalarMatrix =
56template <FloatingPo
intType ftype>
57using RowMajorKokkosScalarMatrix =
58 KokkosScalarMatrix<ComputeSpace, Eigen::RowMajor, ftype>;
59template <FloatingPo
intType ftype>
60using ColMajorKokkosScalarMatrix =
61 KokkosScalarMatrix<ComputeSpace, Eigen::ColMajor, ftype>;
66 using HostView = KokkosScalarMatrix<HostSpace, EigenLayout, float_type>;
68 KokkosScalarMatrix<ComputeSpace,
71 Kokkos::MemoryTraits<Kokkos::RandomAccess>>;
78 :
eigen_data(MatrixType<EigenLayout, float_type>(n_row, n_col))
82 compute = Kokkos::create_mirror_view_and_copy(ComputeSpace(),
host);
85 [[nodiscard]] std::span<const double>
get_span()
const
107template <FloatingPo
intType
floatype>
111template <FloatingPo
intType
floatype>
Definition eigen_kokkos.hpp:64
void update_host_to_compute() const
Definition eigen_kokkos.hpp:95
KokkosScalarMatrix< HostSpace, EigenLayout, float_type > HostView
Definition eigen_kokkos.hpp:66
std::span< const double > get_span() const
Definition eigen_kokkos.hpp:85
ComputeView compute
Definition eigen_kokkos.hpp:74
std::span< double > get_span()
Definition eigen_kokkos.hpp:90
EigenKokkosBase(std::size_t n_row, std::size_t n_col)
Definition eigen_kokkos.hpp:77
HostView host
Definition eigen_kokkos.hpp:73
KokkosScalarMatrix< ComputeSpace, EigenLayout, float_type, Kokkos::MemoryTraits< Kokkos::RandomAccess > > ComputeView
Definition eigen_kokkos.hpp:67
EigenMatrix eigen_data
Definition eigen_kokkos.hpp:75
void update_compute_to_host() const
Definition eigen_kokkos.hpp:100
MatrixType< EigenLayout, float_type > EigenMatrix
Definition eigen_kokkos.hpp:65
Kokkos::LayoutLeft type
Definition eigen_kokkos.hpp:38
Kokkos::LayoutRight type
Definition eigen_kokkos.hpp:43
Definition eigen_kokkos.hpp:34