Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splines LAPACK backend #479

Merged
merged 198 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 190 commits
Commits
Show all changes
198 commits
Select commit Hold shift + click to select a range
f60b990
init
blegouix Apr 2, 2024
84a5ca7
missing sed in benchmark
blegouix Apr 3, 2024
5b67b46
Merge branch 'main' into clarify-spline-names
blegouix Apr 3, 2024
1f02beb
Merge branch 'main' into clarify-spline-names
blegouix Apr 15, 2024
96d4fdb
fix
blegouix Apr 15, 2024
b9c4451
Merge branch 'clarify-spline-names' of github.com:Maison-de-la-Simula…
blegouix Apr 15, 2024
077807a
Update include/ddc/kernels/splines/spline_builder.hpp
blegouix Apr 15, 2024
373e034
Merge branch 'main' into clarify-spline-names
blegouix Apr 15, 2024
653bab4
clang-format
blegouix Apr 15, 2024
889b9f9
fix kokkos version change
blegouix Apr 16, 2024
20ca22d
Merge branch 'main' into clarify-spline-names
blegouix Apr 16, 2024
6238ca3
wip
blegouix Apr 16, 2024
6ab4a97
improve consistency
blegouix Apr 16, 2024
64659a7
Merge branch 'main' into clarify-spline-names
blegouix Apr 17, 2024
66ea164
wip
blegouix Apr 17, 2024
2fdb975
wip
blegouix Apr 17, 2024
93ec4a0
spline_builder
blegouix Apr 17, 2024
29367d7
changes from Emiliy's reviw
blegouix Apr 17, 2024
97a042e
format
blegouix Apr 17, 2024
84e76df
minor
blegouix Apr 17, 2024
aa7b594
wip
blegouix Apr 17, 2024
3ea940f
Merge branch 'clarify-spline-names' into splines-doc
blegouix Apr 17, 2024
ffef0b2
wip
blegouix Apr 18, 2024
2a050b0
wip
blegouix Apr 18, 2024
880353b
bsplines
blegouix Apr 18, 2024
39f2d70
init
blegouix Apr 18, 2024
c0ef458
reinit
blegouix Apr 18, 2024
56dbf4e
remove bsplines (not in the scope of this MR anymore)
blegouix Apr 18, 2024
85a2a0f
format
blegouix Apr 18, 2024
17bb0ba
autoreview
blegouix Apr 18, 2024
7e6c05b
wip
blegouix Apr 18, 2024
8c3bb44
Merge branch 'main' into splines-doc2
blegouix Apr 18, 2024
d7472c7
wip
blegouix Apr 19, 2024
d98abe5
Merge branch 'main' into splines-doc2
blegouix Apr 19, 2024
a563f6d
wip
blegouix Apr 19, 2024
7017234
fix for allowing doxygen to keep track of integrals()
blegouix Apr 19, 2024
dcc5c6f
format
blegouix Apr 19, 2024
8f7f760
Revert "fix for allowing doxygen to keep track of integrals()"
blegouix Apr 19, 2024
9d675c9
autoreview
blegouix Apr 19, 2024
51ffa31
Merge branch 'main' into splines-doc2
blegouix Apr 19, 2024
2d0737c
Merge branch 'main' into splines-doc
blegouix Apr 19, 2024
6850ae9
B-splines
blegouix Apr 19, 2024
937d432
Update include/ddc/kernels/splines/bsplines_non_uniform.hpp
blegouix Apr 19, 2024
9ffbe04
emily's review
blegouix Apr 19, 2024
19b1c1e
Merge branch 'splines-doc2' of github.com:Maison-de-la-Simulation/ddc…
blegouix Apr 19, 2024
8c5c579
wip
blegouix Apr 19, 2024
0589694
Update include/ddc/kernels/splines/bsplines_non_uniform.hpp
blegouix Apr 22, 2024
ffe161e
wip
blegouix Apr 22, 2024
1649b9a
Merge branch 'splines-doc2' of github.com:Maison-de-la-Simulation/ddc…
blegouix Apr 22, 2024
f853bca
reviews
blegouix Apr 22, 2024
fb64952
Merge branch 'main' into splines-doc2
blegouix Apr 22, 2024
7a87e97
typo
blegouix Apr 22, 2024
ccc2163
Merge branch 'splines-doc2' of github.com:Maison-de-la-Simulation/ddc…
blegouix Apr 22, 2024
65c221e
fix
blegouix Apr 22, 2024
49b9b01
minor
blegouix Apr 22, 2024
195dc50
more details on uniformity
blegouix Apr 22, 2024
bae41cc
non-uniform constructors
blegouix Apr 22, 2024
e702a5b
minor
blegouix Apr 22, 2024
f31ab4a
non_uniform constructors again
blegouix Apr 22, 2024
f180f4d
wip
blegouix Apr 22, 2024
1484581
wip on CI
blegouix Apr 22, 2024
90ccf09
Merge branch 'main' into splines-doc2
blegouix Apr 22, 2024
792b7f1
wip on CI
blegouix Apr 22, 2024
e516124
CI, integrals doxygen tracking still wrong
blegouix Apr 22, 2024
a0baf93
fix
blegouix Apr 22, 2024
d5f56b5
Update include/ddc/kernels/splines/bsplines_non_uniform.hpp
blegouix Apr 22, 2024
29a9c3c
wip
blegouix Apr 23, 2024
bfa7316
Merge branch 'splines-doc2' of github.com:Maison-de-la-Simulation/ddc…
blegouix Apr 23, 2024
f557230
emily's review
blegouix Apr 23, 2024
e3133e5
Merge branch 'main' into splines-doc2
blegouix Apr 23, 2024
a0dc609
minor
blegouix Apr 23, 2024
403a99a
minor
blegouix Apr 23, 2024
bdd529a
the spline coefficients
blegouix Apr 23, 2024
8068c3b
CI
blegouix Apr 23, 2024
ad55555
emily's review
blegouix Apr 23, 2024
45db898
forgot a files save
blegouix Apr 23, 2024
3e9c720
Merge branch 'main' into splines-doc2
blegouix Apr 23, 2024
5f82177
fix doxygen
blegouix Apr 24, 2024
6f3d65c
Merge branch 'splines-doc2' of github.com:Maison-de-la-Simulation/ddc…
blegouix Apr 24, 2024
7dfbed2
clang-format
blegouix Apr 24, 2024
669719e
wip on CI
blegouix Apr 24, 2024
0e27bfe
null_extrap
blegouix Apr 24, 2024
3982b95
CI
blegouix Apr 24, 2024
9e5c166
Merge branch 'splines-doc2' into splines-doc
blegouix Apr 24, 2024
e302ef9
wip
blegouix Apr 24, 2024
b3f4724
Emily's review
blegouix Apr 24, 2024
d6890d9
Merge branch 'main' into splines-doc2
blegouix Apr 25, 2024
995a5df
Merge branch 'splines-doc2' into splines-doc
blegouix Apr 25, 2024
167a36f
wip
blegouix Apr 25, 2024
19e3cc9
Thomas' review
blegouix Apr 25, 2024
bd7420c
Merge branch 'main' into splines-doc2
blegouix Apr 25, 2024
12d32d8
Merge branch 'splines-doc2' into splines-doc
blegouix Apr 25, 2024
a268a08
autoreview
blegouix Apr 25, 2024
74da282
Merge branch 'main' into splines-doc
blegouix Apr 25, 2024
a972961
remove null_extrapolation
blegouix Apr 25, 2024
c116d00
Emily's minireview
blegouix Apr 25, 2024
b247fbc
shorten doxygen comments
blegouix Apr 25, 2024
185ca11
Emily's review
blegouix Apr 26, 2024
89bff3f
ident
blegouix Apr 26, 2024
bdc3ac8
wip
blegouix Apr 30, 2024
515dc8d
Emily's review
blegouix Apr 30, 2024
0a34fca
minor
blegouix Apr 30, 2024
127a22b
ident
blegouix Apr 30, 2024
948259f
ident
blegouix Apr 30, 2024
d734870
minor
blegouix Apr 30, 2024
68b639e
transform -> approximate
blegouix Apr 30, 2024
095635e
Emily's review
blegouix May 3, 2024
dc4d3f6
Update include/ddc/kernels/splines/spline_builder.hpp
blegouix May 3, 2024
9273432
Emily's review
blegouix May 6, 2024
0ddd898
minor
blegouix May 6, 2024
eef77b9
hyperparameter -> parameter
blegouix May 14, 2024
d61deeb
Merge branch 'main' into splines-doc
blegouix May 21, 2024
932620e
Apply suggestions from code review
blegouix May 27, 2024
b3d9c54
privatize transposed-domain functions
blegouix May 27, 2024
bc8ce54
Update include/ddc/kernels/splines/spline_builder.hpp
blegouix May 27, 2024
2b9071a
wip
blegouix May 29, 2024
af23572
wip
blegouix May 29, 2024
8c53a90
Merge branch 'main' into splines-linear-proble-2x2-blocks
blegouix May 29, 2024
4a714bd
runs but wrong result
blegouix May 29, 2024
17062e1
fix
blegouix May 30, 2024
769da52
rely on Kokkos::View to store nb and k
blegouix May 30, 2024
fdbfecf
renaming
blegouix May 30, 2024
1d4a8ed
misc
blegouix May 30, 2024
68b826f
release candidate
blegouix May 30, 2024
6f1f29f
Merge branch 'main' into splines-linear-proble-2x2-blocks
blegouix May 30, 2024
4cc3a1d
autoreview
blegouix May 30, 2024
ed6115b
autoreview
blegouix May 30, 2024
21155ff
wip
blegouix May 31, 2024
3793667
wip
blegouix May 31, 2024
a158101
thomas' review
blegouix May 31, 2024
7fec07c
improve gemv
blegouix May 31, 2024
4f0422a
minor fix
blegouix May 31, 2024
3b6d736
minor fix
blegouix May 31, 2024
a49541d
renaming
blegouix May 31, 2024
d0bb2de
fix
blegouix Jun 1, 2024
5da5846
Update include/ddc/kernels/splines/splines_linear_problem_2x2_blocks.hpp
blegouix Jun 1, 2024
242ec03
wip
blegouix Jun 1, 2024
435efcd
runs but wrong result
blegouix Jun 3, 2024
ab80779
wip on a fix
blegouix Jun 3, 2024
30b93d4
wip on making it work
blegouix Jun 3, 2024
bc3fc36
init
blegouix Jun 4, 2024
3b0933c
Apply suggestions from code review
blegouix Jun 4, 2024
398f678
Apply suggestions from code review
blegouix Jun 4, 2024
2e8fd7a
split gemv in two
blegouix Jun 4, 2024
d1f8bc5
Merge branch 'splines-linear-proble-2x2-blocks' into splines-linear-p…
blegouix Jun 4, 2024
370d71e
Update include/ddc/kernels/splines/splines_linear_problem_2x2_blocks.hpp
blegouix Jun 4, 2024
59a4229
fixes
blegouix Jun 4, 2024
59e4834
minor
blegouix Jun 4, 2024
4721152
Merge branch 'splines-linear-proble-2x2-blocks' into splines-linear-p…
blegouix Jun 4, 2024
1d669f1
Merge branch 'main' into splines-linear-problem-periodic-band2
blegouix Jun 4, 2024
1c0321b
Merge branch 'main' into splines-linear-problem-3x3-blocks
blegouix Jun 5, 2024
a5b2cc2
init
blegouix Jun 5, 2024
cc69eb2
autoreview + missing files
blegouix Jun 5, 2024
eac561b
autoreview
blegouix Jun 5, 2024
605c662
autoreview
blegouix Jun 5, 2024
633eb60
Merge branch 'splines-doc' into lapack-backend
blegouix Jun 5, 2024
5097b5a
Merge branch 'splines-linear-problem-periodic-band2' into lapack-backend
blegouix Jun 5, 2024
b6cb596
init
blegouix Jun 5, 2024
fdba501
remove non-uniform guinkgo tst
blegouix Jun 5, 2024
6bf1dee
typo
blegouix Jun 5, 2024
c018ad5
typo
blegouix Jun 5, 2024
704f4bd
Update include/ddc/kernels/splines/splines_linear_problem_maker.hpp
blegouix Jun 17, 2024
6d78a09
Update include/ddc/kernels/splines/splines_linear_problem_maker.hpp
blegouix Jun 17, 2024
8f6b79a
Update include/ddc/kernels/splines/splines_linear_problem_maker.hpp
blegouix Jun 17, 2024
29a7bd1
fix
blegouix Jun 17, 2024
b875bee
Merge branch 'splines-linear-problem-periodic-band2' of github.com:Ma…
blegouix Jun 17, 2024
df84faa
Merge branch 'main' into splines-linear-problem-periodic-band2
blegouix Jun 17, 2024
ad6dd2e
static_cast
blegouix Jun 17, 2024
9b5fd29
fix
blegouix Jun 17, 2024
a13d691
Merge branch 'main' into splines-linear-problem-3x3-blocks
blegouix Jun 17, 2024
54b0e42
Merge branch 'main' into splines-linear-problem-3x3-blocks
blegouix Jun 17, 2024
f435791
Merge branch 'splines-linear-problem-3x3-blocks' of github.com:Maison…
blegouix Jun 17, 2024
3c7669c
Merge branch 'main' into lapack-backend
blegouix Jun 17, 2024
ebe3c3b
Merge branch 'splines-linear-problem-3x3-blocks' into lapack-backend
blegouix Jun 17, 2024
cc28f25
Merge branch 'splines-linear-problem-periodic-band' into lapack-backend
blegouix Jun 17, 2024
d35d9c5
Merge branch 'splines-linear-problem-periodic-band2' into lapack-backend
blegouix Jun 17, 2024
4cf205d
fix bad merge
blegouix Jun 17, 2024
b061d93
fix
blegouix Jun 17, 2024
2b752ec
Merge branch 'main' into splines-linear-problem-3x3-blocks
blegouix Jun 21, 2024
6922df5
Merge branch 'main' into splines-linear-problem-3x3-blocks
blegouix Jun 25, 2024
46c6f5e
Apply suggestions from code review
blegouix Jun 26, 2024
fa77eb9
Update include/ddc/kernels/splines/splines_linear_problem_3x3_blocks.hpp
blegouix Jun 26, 2024
3c2da24
Apply suggestions from code review
blegouix Jun 26, 2024
406228f
Update include/ddc/kernels/splines/splines_linear_problem_3x3_blocks.hpp
blegouix Jun 26, 2024
c56c130
asserts to prevent overlapping allocations
blegouix Jun 26, 2024
2b0ee29
Merge branch 'splines-linear-problem-3x3-blocks' into lapack-backend
blegouix Jun 26, 2024
8ab0cb2
Merge branch 'main' into splines-linear-problem-3x3-blocks
blegouix Jun 26, 2024
2597448
Merge branch 'splines-linear-problem-3x3-blocks' into lapack-backend
blegouix Jun 26, 2024
93a2b2d
reset 2x2 file
blegouix Jun 26, 2024
20ea469
Update include/ddc/kernels/splines/splines_linear_problem_2x2_blocks.hpp
blegouix Jun 26, 2024
e3abfe8
Update include/ddc/kernels/splines/splines_linear_problem_2x2_blocks.hpp
blegouix Jun 26, 2024
86484b7
Update tests/splines/CMakeLists.txt
blegouix Jun 26, 2024
0fb5c59
Merge branch 'main' into lapack-backend
blegouix Jun 27, 2024
26225f3
Merge branch 'main' into lapack-backend
blegouix Jun 28, 2024
72fc3d6
restore ginkgo tests
blegouix Jun 28, 2024
5b56d56
Merge branch 'lapack-backend' of github.com:Maison-de-la-Simulation/d…
blegouix Jun 28, 2024
037d163
Merge branch 'main' into lapack-backend
blegouix Jul 1, 2024
bc4e61c
Merge branch 'main' into lapack-backend
blegouix Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/ddc/kernels/splines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "splines/spline_evaluator_2d.hpp"
#include "splines/splines_linear_problem.hpp"
#include "splines/splines_linear_problem_2x2_blocks.hpp"
#include "splines/splines_linear_problem_3x3_blocks.hpp"
#include "splines/splines_linear_problem_band.hpp"
#include "splines/splines_linear_problem_dense.hpp"
#include "splines/splines_linear_problem_maker.hpp"
Expand Down
37 changes: 32 additions & 5 deletions include/ddc/kernels/splines/spline_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ namespace ddc {
* An enum determining the backend solver of a SplineBuilder or SplineBuilder2d.
*/
enum class SplineSolver {
GINKGO ///< Enum member to identify the Ginkgo-based solver (iterative method)
GINKGO, ///< Enum member to identify the Ginkgo-based solver (iterative method)
LAPACK ///< Enum member to identify the LAPACK-based solver (direct method)
};

/**
Expand Down Expand Up @@ -603,10 +604,36 @@ void SplineBuilder<
return;
*/

matrix = ddc::detail::SplinesLinearProblemMaker::make_new_sparse<ExecSpace>(
ddc::discrete_space<BSplines>().nbasis(),
cols_per_chunk,
preconditionner_max_block_size);
if constexpr (Solver == ddc::SplineSolver::LAPACK) {
int upper_band_width;
if (bsplines_type::is_uniform()) {
upper_band_width = bsplines_type::degree() / 2;
} else {
upper_band_width = bsplines_type::degree() - 1;
}
if constexpr (bsplines_type::is_periodic()) {
matrix = ddc::detail::SplinesLinearProblemMaker::make_new_periodic_band_matrix<
ExecSpace>(
ddc::discrete_space<BSplines>().nbasis(),
upper_band_width,
upper_band_width,
bsplines_type::is_uniform());
} else {
matrix = ddc::detail::SplinesLinearProblemMaker::
make_new_block_matrix_with_band_main_block<ExecSpace>(
ddc::discrete_space<BSplines>().nbasis(),
upper_band_width,
upper_band_width,
bsplines_type::is_uniform(),
lower_block_size,
upper_block_size);
tpadioleau marked this conversation as resolved.
Show resolved Hide resolved
}
} else if constexpr (Solver == ddc::SplineSolver::GINKGO) {
matrix = ddc::detail::SplinesLinearProblemMaker::make_new_sparse<ExecSpace>(
ddc::discrete_space<BSplines>().nbasis(),
cols_per_chunk,
preconditionner_max_block_size);
}

build_matrix_system();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SplinesLinearProblem2x2Blocks : public SplinesLinearProblem<ExecSpace>
* @brief SplinesLinearProblem2x2Blocks constructor.
*
* @param mat_size The size of one of the dimensions of the square matrix.
* @param top_left_block A pointer toward the top-left SplinesLinearProblem. `setup_solver` must not have been called on `q`.
* @param top_left_block A pointer toward the top-left SplinesLinearProblem. `setup_solver` must not have been called on `it`.
blegouix marked this conversation as resolved.
Show resolved Hide resolved
*/
explicit SplinesLinearProblem2x2Blocks(
std::size_t const mat_size,
Expand Down
185 changes: 185 additions & 0 deletions include/ddc/kernels/splines/splines_linear_problem_3x3_blocks.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
// Copyright (C) The DDC development team, see COPYRIGHT.md file
//
// SPDX-License-Identifier: MIT

#pragma once

#include <cassert>
#include <memory>
#include <string>

#include "splines_linear_problem.hpp"
#include "splines_linear_problem_2x2_blocks.hpp"

namespace ddc::detail {

/**
* @brief A 3x3-blocks linear problem dedicated to the computation of a spline approximation,
* with all blocks except center one being stored in dense format.
*
* A = | a | b | c |
* | d | Q | e |
* | f | g | h |
*
* The storage format is dense for all blocks except center one, whose storage format is determined by its type.
*
* The matrix itself and blocks a, Q and h are square (which fully determines the dimensions of the others).
*
* This class implements row & columns interchanges of the matrix and of multiple right-hand sides to restructure the
* 3x3-blocks linear problem into a 2x2-blocks linear problem, relying then on the operations implemented in SplinesLinearProblem2x2Blocks.
*
* @tparam ExecSpace The Kokkos::ExecutionSpace on which operations related to the matrix are supposed to be performed.
*/
template <class ExecSpace>
class SplinesLinearProblem3x3Blocks : public SplinesLinearProblem2x2Blocks<ExecSpace>
{
public:
using typename SplinesLinearProblem2x2Blocks<ExecSpace>::MultiRHS;
using SplinesLinearProblem2x2Blocks<ExecSpace>::size;
using SplinesLinearProblem2x2Blocks<ExecSpace>::solve;
using SplinesLinearProblem2x2Blocks<ExecSpace>::m_top_left_block;

protected:
std::size_t m_top_size;

public:
/**
* @brief SplinesLinearProblem3x3Blocks constructor.
*
* @param mat_size The size of one of the dimensions of the square matrix.
* @param top_size The size of one of the dimensions of the top-left square block.
* @param center_block A pointer toward the center SplinesLinearProblem. `setup_solver` must not have been called on it.
*/
explicit SplinesLinearProblem3x3Blocks(
std::size_t const mat_size,
std::size_t const top_size,
std::unique_ptr<SplinesLinearProblem<ExecSpace>> center_block)
: SplinesLinearProblem2x2Blocks<ExecSpace>(mat_size, std::move(center_block))
, m_top_size(top_size)
{
}

private:
/// @brief Adjust indices, governs the row & columns interchanges to restructure the 3x3-blocks matrix into a 2x2-blocks matrix.
void adjust_indices(std::size_t& i, std::size_t& j) const
{
std::size_t const nq = m_top_left_block->size(); // size of the center block

if (i < m_top_size) {
i += nq;
} else if (i < m_top_size + nq) {
i -= m_top_size;
}

if (j < m_top_size) {
j += nq;
} else if (j < m_top_size + nq) {
j -= m_top_size;
}
}

public:
double get_element(std::size_t i, std::size_t j) const override
{
adjust_indices(i, j);
return SplinesLinearProblem2x2Blocks<ExecSpace>::get_element(i, j);
}

void set_element(std::size_t i, std::size_t j, double const aij) override
{
adjust_indices(i, j);
return SplinesLinearProblem2x2Blocks<ExecSpace>::set_element(i, j, aij);
}

private:
/**
* @brief Perform row interchanges on multiple right-hand sides to get a 2-blocks structure (matching the requirements
* of the SplinesLinearProblem2x2Blocks solver).
*
* | b_top | | b_center |
* | b_center | -> | b_top | -- Considered as a
* | b_bottom | | b_bottom | -- single bottom block
*
* @param b The multiple right-hand sides.
*/
void interchange_rows_from_3_to_2_blocks_rhs(MultiRHS const b) const
{
std::size_t const nq = m_top_left_block->size(); // size of the center block

// prevent Kokkos::deep_copy(b_top_dst, b_top) to be a deep_copy between overlapping allocations
assert(nq >= m_top_size);

MultiRHS const b_top = Kokkos::
subview(b, std::pair<std::size_t, std::size_t> {0, m_top_size}, Kokkos::ALL);
MultiRHS const b_center = Kokkos::
subview(b,
std::pair<std::size_t, std::size_t> {m_top_size, m_top_size + nq},
Kokkos::ALL);

MultiRHS const b_center_dst
= Kokkos::subview(b, std::pair<std::size_t, std::size_t> {0, nq}, Kokkos::ALL);
MultiRHS const b_top_dst = Kokkos::
subview(b, std::pair<std::size_t, std::size_t> {nq, nq + m_top_size}, Kokkos::ALL);

MultiRHS const buffer = Kokkos::create_mirror(ExecSpace(), b_center);

Kokkos::deep_copy(buffer, b_center);
Kokkos::deep_copy(b_top_dst, b_top);
Kokkos::deep_copy(b_center_dst, buffer);
}

/**
* @brief Perform row interchanges on multiple right-hand sides to restore its 3-blocks structure.
*
* | b_center | | b_top |
* | b_top | -> | b_center |
* | b_bottom | | b_bottom |
*
* @param b The multiple right-hand sides.
*/
void interchange_rows_from_2_to_3_blocks_rhs(MultiRHS const b) const
{
std::size_t const nq = m_top_left_block->size(); // size of the center block

// prevent Kokkos::deep_copy(b_top, b_top_src) to be a deep_copy between overlapping allocations
assert(nq >= m_top_size);

MultiRHS const b_center_src
= Kokkos::subview(b, std::pair<std::size_t, std::size_t> {0, nq}, Kokkos::ALL);
MultiRHS const b_top_src = Kokkos::
subview(b, std::pair<std::size_t, std::size_t> {nq, nq + m_top_size}, Kokkos::ALL);

MultiRHS const b_top = Kokkos::
subview(b, std::pair<std::size_t, std::size_t> {0, m_top_size}, Kokkos::ALL);
MultiRHS const b_center = Kokkos::
subview(b,
std::pair<std::size_t, std::size_t> {m_top_size, m_top_size + nq},
Kokkos::ALL);

MultiRHS const buffer = Kokkos::create_mirror(ExecSpace(), b_center);

Kokkos::deep_copy(buffer, b_center_src);
Kokkos::deep_copy(b_top, b_top_src);
Kokkos::deep_copy(b_center, buffer);
}

public:
/**
* @brief Solve the multiple right-hand sides linear problem Ax=b or its transposed version A^tx=b inplace.
*
* Perform row interchanges on multiple right-hand sides to obtain a 2x2-blocks linear problem and call the SplinesLinearProblem2x2Blocks solver.
*
* @param[in, out] b A 2D Kokkos::View storing the multiple right-hand sides of the problem and receiving the corresponding solution.
* @param transpose Choose between the direct or transposed version of the linear problem.
*/
void solve(MultiRHS const b, bool const transpose) const override
{
assert(b.extent(0) == size());

interchange_rows_from_3_to_2_blocks_rhs(b);
SplinesLinearProblem2x2Blocks<ExecSpace>::solve(b, transpose);
interchange_rows_from_2_to_3_blocks_rhs(b);
}
};

} // namespace ddc::detail
23 changes: 15 additions & 8 deletions include/ddc/kernels/splines/splines_linear_problem_maker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <optional>

#include "splines_linear_problem_2x2_blocks.hpp"
#include "splines_linear_problem_3x3_blocks.hpp"
#include "splines_linear_problem_band.hpp"
#include "splines_linear_problem_dense.hpp"
#include "splines_linear_problem_pds_band.hpp"
Expand Down Expand Up @@ -65,15 +66,16 @@ class SplinesLinearProblemMaker
}

/**
* @brief Construct a 2x2-blocks linear problem with band "main" block (the one called
* Q in SplinesLinearProblem2x2Blocks).
* @brief Construct a 2x2-blocks or 3x3-blocks linear problem with band "main" block (the one called
* Q in SplinesLinearProblem2x2Blocks and SplinesLinearProblem3x3Blocks).
*
* @tparam the Kokkos::ExecutionSpace on which matrix-related operation will be performed.
* @param n The size of one of the dimensions of the whole square matrix.
* @param kl The number of subdiagonals in the band block.
* @param ku The number of superdiagonals in the band block.
* @param pds A boolean indicating if the band block is positive-definite symetric or not.
* @param bottom_right_size The size of one of the dimensions of the bottom-right block.
* @param bottom_right_size The size of one of the dimensions of the bottom-right square block.
* @param top_left_size The size of one of the dimensions of the top-left square block.
*
* @return The SplinesLinearProblem instance.
*/
Expand All @@ -84,13 +86,18 @@ class SplinesLinearProblemMaker
int const kl,
int const ku,
bool const pds,
int const bottom_size)
int const bottom_right_size,
int const top_left_size = 0)
{
int const top_size = n - bottom_size;
std::unique_ptr<SplinesLinearProblem<ExecSpace>> top_left_block
= make_new_band<ExecSpace>(top_size, kl, ku, pds);
int const main_size = n - top_left_size - bottom_right_size;
std::unique_ptr<SplinesLinearProblem<ExecSpace>> main_block
= make_new_band<ExecSpace>(main_size, kl, ku, pds);
if (top_left_size == 0) {
return std::make_unique<
SplinesLinearProblem2x2Blocks<ExecSpace>>(n, std::move(main_block));
}
return std::make_unique<
SplinesLinearProblem2x2Blocks<ExecSpace>>(n, std::move(top_left_block));
SplinesLinearProblem3x3Blocks<ExecSpace>>(n, top_left_size, std::move(main_block));
}

/**
Expand Down
24 changes: 22 additions & 2 deletions tests/splines/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,38 @@ foreach(BC "BC_PERIODIC" "BC_GREVILLE")
endforeach()
endforeach()

# LAPACK
foreach(BC "BC_PERIODIC" "BC_GREVILLE" "BC_HERMITE")
foreach(DEGREE_X RANGE "${SPLINES_TEST_DEGREE_MIN}" "${SPLINES_TEST_DEGREE_MAX}")
foreach(BSPLINES_TYPE "BSPLINES_TYPE_UNIFORM" "BSPLINES_TYPE_NON_UNIFORM")
set(test_name "splines_tests_BATCHED_DEGREE_X_${DEGREE_X}_${BSPLINES_TYPE}_${BC}")
set(test_name "splines_tests_BATCHED_DEGREE_X_${DEGREE_X}_${BSPLINES_TYPE}_${BC}_LAPACK")
add_executable("${test_name}" ../main.cpp batched_spline_builder.cpp)
target_compile_features("${test_name}" PUBLIC cxx_std_17)
target_link_libraries("${test_name}"
PUBLIC
GTest::gtest
DDC::DDC
)
target_compile_definitions("${test_name}" PUBLIC -DDEGREE_X=${DEGREE_X} -D${BSPLINES_TYPE} -D${BC})
target_compile_definitions("${test_name}" PUBLIC -DDEGREE_X=${DEGREE_X} -D${BSPLINES_TYPE} -D${BC} -DSOLVER_LAPACK)
blegouix marked this conversation as resolved.
Show resolved Hide resolved
# add_test("${test_name}" "${test_name}")
gtest_discover_tests("${test_name}" DISCOVERY_MODE PRE_TEST)
endforeach()
endforeach()
endforeach()

# GINKGO
foreach(BC "BC_PERIODIC")
foreach(DEGREE_X RANGE "${SPLINES_TEST_DEGREE_MIN}" "${SPLINES_TEST_DEGREE_MAX}")
foreach(BSPLINES_TYPE "BSPLINES_TYPE_UNIFORM")
tpadioleau marked this conversation as resolved.
Show resolved Hide resolved
set(test_name "splines_tests_BATCHED_DEGREE_X_${DEGREE_X}_${BSPLINES_TYPE}_${BC}_GINKGO")
add_executable("${test_name}" ../main.cpp batched_spline_builder.cpp)
target_compile_features("${test_name}" PUBLIC cxx_std_17)
target_link_libraries("${test_name}"
PUBLIC
GTest::gtest
DDC::DDC
)
target_compile_definitions("${test_name}" PUBLIC -DDEGREE_X=${DEGREE_X} -D${BSPLINES_TYPE} -D${BC} -DSOLVER_GINKGO)
# add_test("${test_name}" "${test_name}")
gtest_discover_tests("${test_name}" DISCOVERY_MODE PRE_TEST)
endforeach()
Expand Down
30 changes: 18 additions & 12 deletions tests/splines/batched_spline_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ static void BatchedSplineTest()
IDim<I, I>,
s_bcl,
s_bcr,
#if defined(SOLVER_LAPACK)
ddc::SplineSolver::LAPACK,
#elif defined(SOLVER_GINKGO)
ddc::SplineSolver::GINKGO,
#endif
IDim<X, I>...>
spline_builder(dom_vals);

Expand Down Expand Up @@ -416,18 +420,20 @@ static void BatchedSplineTest()
1.0e-14 * max_norm_int));
}

#if defined(BC_PERIODIC) && defined(BSPLINES_TYPE_UNIFORM)
#define SUFFIX(name) name##Periodic##Uniform
#elif defined(BC_PERIODIC) && defined(BSPLINES_TYPE_NON_UNIFORM)
#define SUFFIX(name) name##Periodic##NonUniform
#elif defined(BC_GREVILLE) && defined(BSPLINES_TYPE_UNIFORM)
#define SUFFIX(name) name##Greville##Uniform
#elif defined(BC_GREVILLE) && defined(BSPLINES_TYPE_NON_UNIFORM)
#define SUFFIX(name) name##Greville##NonUniform
#elif defined(BC_HERMITE) && defined(BSPLINES_TYPE_UNIFORM)
#define SUFFIX(name) name##Hermite##Uniform
#elif defined(BC_HERMITE) && defined(BSPLINES_TYPE_NON_UNIFORM)
#define SUFFIX(name) name##Hermite##NonUniform
#if defined(BC_PERIODIC) && defined(BSPLINES_TYPE_UNIFORM) && defined(SOLVER_LAPACK)
#define SUFFIX(name) name##Lapack##Periodic##Uniform
#elif defined(BC_PERIODIC) && defined(BSPLINES_TYPE_NON_UNIFORM) && defined(SOLVER_LAPACK)
#define SUFFIX(name) name##Lapack##Periodic##NonUniform
#elif defined(BC_GREVILLE) && defined(BSPLINES_TYPE_UNIFORM) && defined(SOLVER_LAPACK)
#define SUFFIX(name) name##Lapack##Greville##Uniform
#elif defined(BC_GREVILLE) && defined(BSPLINES_TYPE_NON_UNIFORM) && defined(SOLVER_LAPACK)
#define SUFFIX(name) name##Lapack##Greville##NonUniform
#elif defined(BC_HERMITE) && defined(BSPLINES_TYPE_UNIFORM) && defined(SOLVER_LAPACK)
#define SUFFIX(name) name##Lapack##Hermite##Uniform
#elif defined(BC_HERMITE) && defined(BSPLINES_TYPE_NON_UNIFORM) && defined(SOLVER_LAPACK)
#define SUFFIX(name) name##Lapack##Hermite##NonUniform
#elif defined(BC_PERIODIC) && defined(BSPLINES_TYPE_UNIFORM) && defined(SOLVER_GINKGO)
#define SUFFIX(name) name##Ginkgo##Periodic##Uniform
#endif

TEST(SUFFIX(BatchedSplineHost), 1DX)
Expand Down
Loading
Loading