10#include <Kokkos_Core.hpp>
16namespace ddc::detail {
18template <
class ExecSpace>
19SplinesLinearProblem3x3Blocks<ExecSpace>::SplinesLinearProblem3x3Blocks(
20 std::size_t
const mat_size,
21 std::size_t
const top_size,
22 std::unique_ptr<SplinesLinearProblem<ExecSpace>> center_block)
23 : SplinesLinearProblem2x2Blocks<ExecSpace>(mat_size, std::move(center_block))
24 , m_top_size(top_size)
28template <
class ExecSpace>
29SplinesLinearProblem3x3Blocks<ExecSpace>::~SplinesLinearProblem3x3Blocks() =
default;
31template <
class ExecSpace>
32void SplinesLinearProblem3x3Blocks<ExecSpace>::adjust_indices(std::size_t& i, std::size_t& j)
const
34 std::size_t
const nq = m_top_left_block->size();
38 }
else if (i < m_top_size + nq) {
44 }
else if (j < m_top_size + nq) {
49template <
class ExecSpace>
50double SplinesLinearProblem3x3Blocks<ExecSpace>::get_element(std::size_t i, std::size_t j)
const
53 return SplinesLinearProblem2x2Blocks<ExecSpace>::get_element(i, j);
56template <
class ExecSpace>
57void SplinesLinearProblem3x3Blocks<ExecSpace>::set_element(
63 SplinesLinearProblem2x2Blocks<ExecSpace>::set_element(i, j, aij);
66template <
class ExecSpace>
67void SplinesLinearProblem3x3Blocks<ExecSpace>::interchange_rows_from_3_to_2_blocks_rhs(
68 MultiRHS
const b)
const
70 std::size_t
const nq = m_top_left_block->size();
73 = Kokkos::subview(b, std::pair<std::size_t, std::size_t> {0, m_top_size}, Kokkos::ALL);
74 MultiRHS
const b_bottom = Kokkos::
75 subview(b, std::pair<std::size_t, std::size_t> {m_top_size + nq, size()}, Kokkos::ALL);
77 MultiRHS
const b_top_dst = Kokkos::
79 std::pair<std::size_t, std::size_t> {m_top_size + nq, 2 * m_top_size + nq},
81 MultiRHS
const b_bottom_dst = Kokkos::
83 std::pair<std::size_t, std::size_t> {2 * m_top_size + nq, m_top_size + size()},
86 if (b_bottom.extent(0) > b_top.extent(0)) {
88 MultiRHS
const buffer = Kokkos::create_mirror(ExecSpace(), b_bottom);
90 Kokkos::deep_copy(buffer, b_bottom);
91 Kokkos::deep_copy(b_bottom_dst, buffer);
93 Kokkos::deep_copy(b_bottom_dst, b_bottom);
95 Kokkos::deep_copy(b_top_dst, b_top);
98template <
class ExecSpace>
99void SplinesLinearProblem3x3Blocks<ExecSpace>::interchange_rows_from_2_to_3_blocks_rhs(
100 MultiRHS
const b)
const
102 std::size_t
const nq = m_top_left_block->size();
105 = Kokkos::subview(b, std::pair<std::size_t, std::size_t> {0, m_top_size}, Kokkos::ALL);
106 MultiRHS
const b_bottom = Kokkos::
107 subview(b, std::pair<std::size_t, std::size_t> {m_top_size + nq, size()}, Kokkos::ALL);
109 MultiRHS
const b_top_src = Kokkos::
111 std::pair<std::size_t, std::size_t> {m_top_size + nq, 2 * m_top_size + nq},
113 MultiRHS
const b_bottom_src = Kokkos::
115 std::pair<std::size_t, std::size_t> {2 * m_top_size + nq, m_top_size + size()},
118 Kokkos::deep_copy(b_top, b_top_src);
119 if (b_bottom.extent(0) > b_top.extent(0)) {
121 MultiRHS
const buffer = Kokkos::create_mirror(ExecSpace(), b_bottom);
123 Kokkos::deep_copy(buffer, b_bottom_src);
124 Kokkos::deep_copy(b_bottom, buffer);
126 Kokkos::deep_copy(b_bottom, b_bottom_src);
130template <
class ExecSpace>
131void SplinesLinearProblem3x3Blocks<ExecSpace>::solve(MultiRHS
const b,
bool const transpose)
const
133 assert(b.extent(0) == size() + m_top_size);
135 interchange_rows_from_3_to_2_blocks_rhs(b);
136 SplinesLinearProblem2x2Blocks<ExecSpace>::
141 std::size_t> {m_top_size, m_top_size + size()},
144 interchange_rows_from_2_to_3_blocks_rhs(b);
147template <
class ExecSpace>
148std::size_t SplinesLinearProblem3x3Blocks<ExecSpace>::impl_required_number_of_rhs_rows()
const
150 return size() + m_top_size;
153#if defined(KOKKOS_ENABLE_SERIAL
)
154template class SplinesLinearProblem3x3Blocks<Kokkos::Serial>;
156#if defined(KOKKOS_ENABLE_OPENMP)
157template class SplinesLinearProblem3x3Blocks<Kokkos::OpenMP>;
159#if defined(KOKKOS_ENABLE_CUDA)
160template class SplinesLinearProblem3x3Blocks<Kokkos::Cuda>;
162#if defined(KOKKOS_ENABLE_HIP)
163template class SplinesLinearProblem3x3Blocks<Kokkos::HIP>;
165#if defined(KOKKOS_ENABLE_SYCL)
166template class SplinesLinearProblem3x3Blocks<Kokkos::SYCL>;
The top-level namespace of DDC.