1#ifndef __SIMULATION_EIGEN_KOKKOS_HPP__
2#define __SIMULATION_EIGEN_KOKKOS_HPP__
5#pragma GCC diagnostic push
6#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
7#pragma GCC diagnostic ignored "-Wnan-infinity-disabled"
11#include <Eigen/Sparse>
13#pragma GCC diagnostic pop
15#include <Kokkos_Core.hpp>
16#include <common/common.hpp>
59constexpr auto EigenLayoutRight = Eigen::RowMajor;
60constexpr auto EigenLayoutLeft = Eigen::ColMajor;
61constexpr auto CompileMatrixSizeEigen = -1;
65using MatrixType = Eigen::Matrix<double, CompileMatrixSizeEigen, CompileMatrixSizeEigen, Layout>;
67using ColMajorMatrixtype = MatrixType<EigenLayoutLeft>;
69template <
int Layout>
using SparseMatrixType = Eigen::SparseMatrix<double, Layout>;
71using DiagonalType = Eigen::DiagonalMatrix<double, CompileMatrixSizeEigen>;
81 using type = Kokkos::LayoutLeft;
86 using type = Kokkos::LayoutRight;
89template <
typename ExecSpace,
int EigenLayout,
typename... MemoryTrait>
90using KokkosScalarMatrix = Kokkos::
91 View<double**, typename KokkosLayoutMapper<EigenLayout>::type, ExecSpace, MemoryTrait...>;
93using RowMajorKokkosScalarMatrix = KokkosScalarMatrix<ComputeSpace, Eigen::RowMajor>;
94using ColMajorKokkosScalarMatrix = KokkosScalarMatrix<ComputeSpace, Eigen::ColMajor>;
99 using HostView = KokkosScalarMatrix<HostSpace, EigenLayout>;
101 KokkosScalarMatrix<ComputeSpace, EigenLayout, Kokkos::MemoryTraits<Kokkos::RandomAccess>>;
108 :
eigen_data(MatrixType<EigenLayout>(n_row, n_col))
112 compute = Kokkos::create_mirror_view_and_copy(ComputeSpace(),
host);
115 [[nodiscard]] std::span<const double>
get_span()
const
Definition eigen_kokkos.hpp:97
ComputeView compute
Definition eigen_kokkos.hpp:104
EigenMatrix eigen_data
Definition eigen_kokkos.hpp:105
EigenKokkosBase(std::size_t n_row, std::size_t n_col)
Definition eigen_kokkos.hpp:107
void update_host_to_compute() const
Definition eigen_kokkos.hpp:125
KokkosScalarMatrix< HostSpace, EigenLayout > HostView
Definition eigen_kokkos.hpp:99
std::span< double > get_span()
Definition eigen_kokkos.hpp:120
void update_compute_to_host() const
Definition eigen_kokkos.hpp:130
KokkosScalarMatrix< ComputeSpace, EigenLayout, Kokkos::MemoryTraits< Kokkos::RandomAccess > > ComputeView
Definition eigen_kokkos.hpp:100
std::span< const double > get_span() const
Definition eigen_kokkos.hpp:115
MatrixType< EigenLayout > EigenMatrix
Definition eigen_kokkos.hpp:98
HostView host
Definition eigen_kokkos.hpp:103
Kokkos::LayoutLeft type
Definition eigen_kokkos.hpp:81
Kokkos::LayoutRight type
Definition eigen_kokkos.hpp:86
Definition eigen_kokkos.hpp:77