14#include <Kokkos_Core.hpp>
16#if __has_include
(<mkl_lapacke.h>)
17# include <mkl_lapacke.h>
22#include <KokkosBatched_Pbtrs.hpp>
23#include <KokkosBatched_Util.hpp>
28namespace ddc::detail {
30template <
class ExecSpace>
31SplinesLinearProblemPDSBand<ExecSpace>::SplinesLinearProblemPDSBand(
32 std::size_t
const mat_size,
34 : SplinesLinearProblem<ExecSpace>(mat_size)
35 , m_q(
"q", kd + 1, mat_size)
37 assert(m_q.extent(0) <= mat_size);
39 Kokkos::deep_copy(m_q.view_host(), 0.);
42template <
class ExecSpace>
43SplinesLinearProblemPDSBand<ExecSpace>::~SplinesLinearProblemPDSBand() =
default;
45template <
class ExecSpace>
46double SplinesLinearProblemPDSBand<ExecSpace>::get_element(std::size_t i, std::size_t j)
const
56 if (j - i < m_q.extent(0)) {
57 return m_q.view_host()(j - i, i);
63template <
class ExecSpace>
64void SplinesLinearProblemPDSBand<ExecSpace>::set_element(
76 if (j - i < m_q.extent(0)) {
77 m_q.view_host()(j - i, i) = aij;
79 assert(std::fabs(aij) < 1e-15);
83template <
class ExecSpace>
84void SplinesLinearProblemPDSBand<ExecSpace>::setup_solver()
86 int const info = LAPACKE_dpbtrf(
91 m_q.view_host().data(),
92 m_q.view_host().stride(
96 throw std::runtime_error(
"LAPACKE_dpbtrf failed with error code " + std::to_string(info));
104template <
class ExecSpace>
105void SplinesLinearProblemPDSBand<ExecSpace>::solve(MultiRHS
const b,
bool const)
const
107 assert(b.extent(0) == size());
109 auto q_device = m_q.view_device();
110 Kokkos::RangePolicy<ExecSpace>
const policy(0, b.extent(1));
111 Kokkos::parallel_for(
114 KOKKOS_LAMBDA(
int const i) {
115 auto sub_b = Kokkos::subview(b, Kokkos::ALL, i);
116 KokkosBatched::SerialPbtrs<
117 KokkosBatched::Uplo::Lower,
118 KokkosBatched::Algo::Pbtrs::Unblocked>::invoke(q_device, sub_b);
122#if defined(KOKKOS_ENABLE_SERIAL
)
123template class SplinesLinearProblemPDSBand<Kokkos::Serial>;
125#if defined(KOKKOS_ENABLE_OPENMP)
126template class SplinesLinearProblemPDSBand<Kokkos::OpenMP>;
128#if defined(KOKKOS_ENABLE_CUDA)
129template class SplinesLinearProblemPDSBand<Kokkos::Cuda>;
131#if defined(KOKKOS_ENABLE_HIP)
132template class SplinesLinearProblemPDSBand<Kokkos::HIP>;
134#if defined(KOKKOS_ENABLE_SYCL)
135template class SplinesLinearProblemPDSBand<Kokkos::SYCL>;
The top-level namespace of DDC.