1#ifndef __SIMULATION_EIGEN_KOKKOS_HPP__
2#define __SIMULATION_EIGEN_KOKKOS_HPP__
7#include <Kokkos_Core.hpp>
8#include <common/common.hpp>
51constexpr auto EigenLayoutRight = Eigen::RowMajor;
52constexpr auto EigenLayoutLeft = Eigen::ColMajor;
53constexpr auto CompileMatrixSizeEigen = -1;
57using MatrixType = Eigen::Matrix<double, CompileMatrixSizeEigen, CompileMatrixSizeEigen, Layout>;
59using ColMajorMatrixtype = MatrixType<EigenLayoutLeft>;
61template <
int Layout>
using SparseMatrixType = Eigen::SparseMatrix<double, Layout>;
63using DiagonalType = Eigen::DiagonalMatrix<double, CompileMatrixSizeEigen>;
73 using type = Kokkos::LayoutLeft;
78 using type = Kokkos::LayoutRight;
81template <
typename ExecSpace,
int EigenLayout,
typename... MemoryTrait>
82using KokkosScalarMatrix = Kokkos::
83 View<double**, typename KokkosLayoutMapper<EigenLayout>::type, ExecSpace, MemoryTrait...>;
86using RowMajorKokkosScalarMatrix = KokkosScalarMatrix<ComputeSpace, Eigen::RowMajor>;
87using ColMajorKokkosScalarMatrix = KokkosScalarMatrix<ComputeSpace, Eigen::ColMajor>;
92 using HostView = KokkosScalarMatrix<HostSpace, EigenLayout>;
95 Kokkos::MemoryTraits<Kokkos::RandomAccess>>;
102 :
eigen_data(MatrixType<EigenLayout>(n_row, n_col))
106 compute = Kokkos::create_mirror_view_and_copy(ComputeSpace(),
host);
109 [[nodiscard]] std::span<const double>
get_span()
const
Definition eigen_kokkos.hpp:90
ComputeView compute
Definition eigen_kokkos.hpp:98
EigenMatrix eigen_data
Definition eigen_kokkos.hpp:99
EigenKokkosBase(std::size_t n_row, std::size_t n_col)
Definition eigen_kokkos.hpp:101
void update_host_to_compute() const
Definition eigen_kokkos.hpp:119
KokkosScalarMatrix< ComputeSpace, EigenLayout, Kokkos::MemoryTraits< Kokkos::RandomAccess > > ComputeView
Definition eigen_kokkos.hpp:93
KokkosScalarMatrix< HostSpace, EigenLayout > HostView
Definition eigen_kokkos.hpp:92
std::span< double > get_span()
Definition eigen_kokkos.hpp:114
void update_compute_to_host() const
Definition eigen_kokkos.hpp:124
std::span< const double > get_span() const
Definition eigen_kokkos.hpp:109
MatrixType< EigenLayout > EigenMatrix
Definition eigen_kokkos.hpp:91
HostView host
Definition eigen_kokkos.hpp:97
Kokkos::LayoutLeft type
Definition eigen_kokkos.hpp:73
Kokkos::LayoutRight type
Definition eigen_kokkos.hpp:78
Definition eigen_kokkos.hpp:69