14#include <Kokkos_Core.hpp>
15#include <Kokkos_DualView.hpp>
17#if __has_include
(<mkl_lapacke.h>)
18# include <mkl_lapacke.h>
23#include <KokkosBatched_Pbtrs.hpp>
24#include <KokkosBatched_Util.hpp>
29namespace ddc::detail {
31template <
class ExecSpace>
32SplinesLinearProblemPDSBand<ExecSpace>::SplinesLinearProblemPDSBand(
33 std::size_t
const mat_size,
35 : SplinesLinearProblem<ExecSpace>(mat_size)
36 , m_q(
"q", kd + 1, mat_size)
38 assert(m_q.extent(0) <= mat_size);
40 Kokkos::deep_copy(m_q.view_host(), 0.);
43template <
class ExecSpace>
44SplinesLinearProblemPDSBand<ExecSpace>::~SplinesLinearProblemPDSBand() =
default;
46template <
class ExecSpace>
47double SplinesLinearProblemPDSBand<ExecSpace>::get_element(std::size_t i, std::size_t j)
const
57 if (j - i < m_q.extent(0)) {
58 return m_q.view_host()(j - i, i);
64template <
class ExecSpace>
65void SplinesLinearProblemPDSBand<ExecSpace>::set_element(
77 if (j - i < m_q.extent(0)) {
78 m_q.view_host()(j - i, i) = aij;
80 assert(std::fabs(aij) < 1e-15);
84template <
class ExecSpace>
85void SplinesLinearProblemPDSBand<ExecSpace>::setup_solver()
87 int const info = LAPACKE_dpbtrf(
92 m_q.view_host().data(),
93 m_q.view_host().stride(
97 throw std::runtime_error(
"LAPACKE_dpbtrf failed with error code " + std::to_string(info));
105template <
class ExecSpace>
106void SplinesLinearProblemPDSBand<ExecSpace>::solve(MultiRHS
const b,
bool const)
const
108 assert(b.extent(0) == size());
110 auto q_device = m_q.view_device();
111 Kokkos::RangePolicy<ExecSpace>
const policy(0, b.extent(1));
112 Kokkos::parallel_for(
115 KOKKOS_LAMBDA(
int const i) {
116 auto sub_b = Kokkos::subview(b, Kokkos::ALL, i);
117 KokkosBatched::SerialPbtrs<
118 KokkosBatched::Uplo::Lower,
119 KokkosBatched::Algo::Pbtrs::Unblocked>::invoke(q_device, sub_b);
123#if defined(KOKKOS_ENABLE_SERIAL
)
124template class SplinesLinearProblemPDSBand<Kokkos::Serial>;
126#if defined(KOKKOS_ENABLE_OPENMP)
127template class SplinesLinearProblemPDSBand<Kokkos::OpenMP>;
129#if defined(KOKKOS_ENABLE_CUDA)
130template class SplinesLinearProblemPDSBand<Kokkos::Cuda>;
132#if defined(KOKKOS_ENABLE_HIP)
133template class SplinesLinearProblemPDSBand<Kokkos::HIP>;
135#if defined(KOKKOS_ENABLE_SYCL)
136template class SplinesLinearProblemPDSBand<Kokkos::SYCL>;
The top-level namespace of DDC.