From d0e74b84a0325892ae57da5aa862034a947bd2e4 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Tue, 28 Nov 2023 08:13:32 +0100 Subject: [PATCH] Fix some warnings, keeping sign-compare warnings (#237) * Fix some warnings, keeping sign-compare warnings * Attribute does not seem to work inside a lambda for clang * Do not show some warnings --- .github/workflows/tests.yml | 2 +- include/ddc/kernels/splines/matrix_sparse.hpp | 6 +++- .../ddc/kernels/splines/spline_builder.hpp | 29 +++++++------------ .../splines/spline_builder_batched.hpp | 2 -- .../splines/spline_evaluator_batched.hpp | 4 +-- tests/splines/batched_spline_builder.cpp | 1 - tests/splines/cosine_evaluator.hpp | 4 +-- 7 files changed, 20 insertions(+), 28 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8bb3f7bbe..d03721891 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -153,7 +153,7 @@ jobs: -DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \ -DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \ -DCMAKE_CXX_FLAGS="\ - -Wall -Wextra -Wpedantic \ + -Wall -Wextra -Wpedantic -Wno-sign-compare \ -Werror=vla \ -Werror=implicit-fallthrough \ ${CMAKE_CXX_FLAGS}" \ diff --git a/include/ddc/kernels/splines/matrix_sparse.hpp b/include/ddc/kernels/splines/matrix_sparse.hpp index 9bb20dd15..d677c689a 100644 --- a/include/ddc/kernels/splines/matrix_sparse.hpp +++ b/include/ddc/kernels/splines/matrix_sparse.hpp @@ -192,7 +192,7 @@ class Matrix_Sparse : public Matrix return M; } - virtual double get_element(int i, int j) const override + virtual double get_element([[maybe_unused]] int i, [[maybe_unused]] int j) const override { throw std::runtime_error("MatrixSparse::get_element() is not implemented because no API is " "provided by Ginkgo"); @@ -240,6 +240,10 @@ class Matrix_Sparse : public Matrix virtual int solve_inplace_method(double* b, char transpose, int n_equations) const override { + if (transpose != 'N') { + throw std::domain_error("transpose"); + } + std::shared_ptr gko_exec = create_gko_exec(); auto data_mat = gko::share(to_gko_mat( m_data.data(), diff --git a/include/ddc/kernels/splines/spline_builder.hpp b/include/ddc/kernels/splines/spline_builder.hpp index f9363196d..18dabd7bb 100644 --- a/include/ddc/kernels/splines/spline_builder.hpp +++ b/include/ddc/kernels/splines/spline_builder.hpp @@ -96,11 +96,11 @@ class SplineBuilder std::optional cols_per_par_chunk = std::nullopt, std::optional par_chunks_per_seq_chunk = std::nullopt, std::optional preconditionner_max_block_size = std::nullopt) - : m_interpolation_domain(interpolation_domain) + : matrix(nullptr) + , m_offset(compute_offset(interpolation_domain)) + , m_interpolation_domain(interpolation_domain) , m_dx((ddc::discrete_space().rmax() - ddc::discrete_space().rmin()) / ddc::discrete_space().ncells()) - , matrix(nullptr) - , m_offset(compute_offset(interpolation_domain)) { // Calculate block sizes int lower_block_size, upper_block_size; @@ -237,7 +237,7 @@ void SplineBuilder< auto const& nbasis_proxy = ddc::discrete_space().nbasis(); Kokkos::parallel_for( Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int unused_index) { + KOKKOS_LAMBDA(int) { for (std::size_t i = 0; i < nbasis_proxy; ++i) { spline(ddc::DiscreteElement(i)) = vals(ddc::DiscreteElement(i)); @@ -246,7 +246,7 @@ void SplineBuilder< if constexpr (bsplines_type::is_periodic()) { Kokkos::parallel_for( Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int unused_index) { + KOKKOS_LAMBDA(int) { spline(ddc::DiscreteElement(nbasis_proxy)) = spline(ddc::DiscreteElement(0)); }); @@ -275,8 +275,8 @@ void SplineBuilder< operator()( ddc::ChunkSpan, Layout, MemorySpace> spline, ddc::ChunkSpan vals, - std::optional const derivs_xmin, - std::optional const derivs_xmax) const + [[maybe_unused]] std::optional const derivs_xmin, + [[maybe_unused]] std::optional const derivs_xmax) const { assert(vals.template extent() == ddc::discrete_space().nbasis() - s_nbe_xmin - s_nbe_xmax); @@ -305,7 +305,7 @@ operator()( auto const& nbasis_proxy = ddc::discrete_space().nbasis(); Kokkos::parallel_for( Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int unused_index) { + KOKKOS_LAMBDA(int) { for (int i = s_nbc_xmin; i < s_nbc_xmin + offset_proxy; ++i) { spline(ddc::DiscreteElement(i)) = 0.0; } @@ -335,7 +335,7 @@ operator()( if constexpr (bsplines_type::is_periodic()) { Kokkos::parallel_for( Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int unused_index) { + KOKKOS_LAMBDA(int) { if (offset_proxy != 0) { for (int i = 0; i < offset_proxy; ++i) { spline(ddc::DiscreteElement(i)) @@ -471,8 +471,8 @@ void SplineBuilder< BcXmax, Solver>:: allocate_matrix( - int lower_block_size, - int upper_block_size, + [[maybe_unused]] int lower_block_size, + [[maybe_unused]] int upper_block_size, std::optional cols_per_par_chunk, std::optional par_chunks_per_seq_chunk, std::optional preconditionner_max_block_size) @@ -482,13 +482,6 @@ void SplineBuilder< if constexpr (bsplines_type::degree() == 1) return; - 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()) { if (Solver == SplineSolver::GINKGO) { matrix = ddc::detail::MatrixMaker::make_new_sparse( diff --git a/include/ddc/kernels/splines/spline_builder_batched.hpp b/include/ddc/kernels/splines/spline_builder_batched.hpp index f581dc80c..65f575b93 100644 --- a/include/ddc/kernels/splines/spline_builder_batched.hpp +++ b/include/ddc/kernels/splines/spline_builder_batched.hpp @@ -136,8 +136,6 @@ void SplineBuilderBatched::operator()( ddc::ChunkSpan vals) const { const std::size_t nbc_xmin = spline_builder.s_nbc_xmin; - const std::size_t nbc_xmax = spline_builder.s_nbc_xmax; - using IMesh = ddc::DiscreteElement; // TODO : Consider optimizing // Fill spline with vals (to work in spline afterward and preserve vals) diff --git a/include/ddc/kernels/splines/spline_evaluator_batched.hpp b/include/ddc/kernels/splines/spline_evaluator_batched.hpp index 83de0afd9..ad2645bf9 100644 --- a/include/ddc/kernels/splines/spline_evaluator_batched.hpp +++ b/include/ddc/kernels/splines/spline_evaluator_batched.hpp @@ -184,9 +184,7 @@ class SplineEvaluatorBatched ddc::ChunkSpan values = values_alloc.span_view(); Kokkos::parallel_for( Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int unused_index) { - ddc::discrete_space().integrals(values); - }); + KOKKOS_LAMBDA(int) { ddc::discrete_space().integrals(values); }); ddc::for_each( ddc::policies::policy(exec_space()), diff --git a/tests/splines/batched_spline_builder.cpp b/tests/splines/batched_spline_builder.cpp index 5ef527baf..ed67bf19d 100644 --- a/tests/splines/batched_spline_builder.cpp +++ b/tests/splines/batched_spline_builder.cpp @@ -180,7 +180,6 @@ static void BatchedPeriodicSplineTest() // Compute usefull domains (dom_interpolation, dom_batch, dom_bsplines and dom_spline) ddc::DiscreteDomain> const dom_interpolation = spline_builder.interpolation_domain(); auto const dom_batch = spline_builder.batch_domain(); - ddc::DiscreteDomain> const dom_bsplines = spline_builder.bsplines_domain(); auto const dom_spline = spline_builder.spline_domain(); // Allocate and fill a chunk containing values to be passed as input to spline_builder. Those are values of cosine along interest dimension duplicated along batch dimensions diff --git a/tests/splines/cosine_evaluator.hpp b/tests/splines/cosine_evaluator.hpp index e00f19d5a..b334dc90f 100644 --- a/tests/splines/cosine_evaluator.hpp +++ b/tests/splines/cosine_evaluator.hpp @@ -23,8 +23,8 @@ struct CosineEvaluator public: template - Evaluator(Domain domain) : m_c0(1.0) - , m_c1(0.0) + Evaluator([[maybe_unused]] Domain domain) : m_c0(1.0) + , m_c1(0.0) { }