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

Fix some warnings, keeping sign-compare warnings #237

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down
6 changes: 5 additions & 1 deletion include/ddc/kernels/splines/matrix_sparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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::Executor> gko_exec = create_gko_exec<ExecSpace>();
auto data_mat = gko::share(to_gko_mat(
m_data.data(),
Expand Down
29 changes: 11 additions & 18 deletions include/ddc/kernels/splines/spline_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ class SplineBuilder
std::optional<int> cols_per_par_chunk = std::nullopt,
std::optional<int> par_chunks_per_seq_chunk = std::nullopt,
std::optional<unsigned int> 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<BSplines>().rmax() - ddc::discrete_space<BSplines>().rmin())
/ ddc::discrete_space<BSplines>().ncells())
, matrix(nullptr)
, m_offset(compute_offset(interpolation_domain))
{
// Calculate block sizes
int lower_block_size, upper_block_size;
Expand Down Expand Up @@ -237,7 +237,7 @@ void SplineBuilder<
auto const& nbasis_proxy = ddc::discrete_space<bsplines_type>().nbasis();
Kokkos::parallel_for(
Kokkos::RangePolicy<exec_space>(0, 1),
KOKKOS_LAMBDA(const int unused_index) {
KOKKOS_LAMBDA(int) {
for (std::size_t i = 0; i < nbasis_proxy; ++i) {
spline(ddc::DiscreteElement<bsplines_type>(i))
= vals(ddc::DiscreteElement<interpolation_mesh_type>(i));
Expand All @@ -246,7 +246,7 @@ void SplineBuilder<
if constexpr (bsplines_type::is_periodic()) {
Kokkos::parallel_for(
Kokkos::RangePolicy<exec_space>(0, 1),
KOKKOS_LAMBDA(const int unused_index) {
KOKKOS_LAMBDA(int) {
spline(ddc::DiscreteElement<bsplines_type>(nbasis_proxy))
= spline(ddc::DiscreteElement<bsplines_type>(0));
});
Expand Down Expand Up @@ -275,8 +275,8 @@ void SplineBuilder<
operator()(
ddc::ChunkSpan<double, ddc::DiscreteDomain<bsplines_type>, Layout, MemorySpace> spline,
ddc::ChunkSpan<double, interpolation_domain_type, Layout, MemorySpace> vals,
std::optional<ddc::CDSpan1D> const derivs_xmin,
std::optional<ddc::CDSpan1D> const derivs_xmax) const
[[maybe_unused]] std::optional<ddc::CDSpan1D> const derivs_xmin,
[[maybe_unused]] std::optional<ddc::CDSpan1D> const derivs_xmax) const
{
assert(vals.template extent<interpolation_mesh_type>()
== ddc::discrete_space<BSplines>().nbasis() - s_nbe_xmin - s_nbe_xmax);
Expand Down Expand Up @@ -305,7 +305,7 @@ operator()(
auto const& nbasis_proxy = ddc::discrete_space<bsplines_type>().nbasis();
Kokkos::parallel_for(
Kokkos::RangePolicy<exec_space>(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<bsplines_type>(i)) = 0.0;
}
Expand Down Expand Up @@ -335,7 +335,7 @@ operator()(
if constexpr (bsplines_type::is_periodic()) {
Kokkos::parallel_for(
Kokkos::RangePolicy<exec_space>(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<bsplines_type>(i))
Expand Down Expand Up @@ -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<int> cols_per_par_chunk,
std::optional<int> par_chunks_per_seq_chunk,
std::optional<unsigned int> preconditionner_max_block_size)
Expand All @@ -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<ExecSpace>(
Expand Down
2 changes: 0 additions & 2 deletions include/ddc/kernels/splines/spline_builder_batched.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ void SplineBuilderBatched<SplineBuilder, IDimX...>::operator()(
ddc::ChunkSpan<double, vals_domain_type, Layout, memory_space> 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<interpolation_mesh_type>;

// TODO : Consider optimizing
// Fill spline with vals (to work in spline afterward and preserve vals)
Expand Down
4 changes: 1 addition & 3 deletions include/ddc/kernels/splines/spline_evaluator_batched.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ class SplineEvaluatorBatched
ddc::ChunkSpan values = values_alloc.span_view();
Kokkos::parallel_for(
Kokkos::RangePolicy<exec_space>(0, 1),
KOKKOS_LAMBDA(const int unused_index) {
ddc::discrete_space<bsplines_type>().integrals(values);
});
KOKKOS_LAMBDA(int) { ddc::discrete_space<bsplines_type>().integrals(values); });

ddc::for_each(
ddc::policies::policy(exec_space()),
Expand Down
1 change: 0 additions & 1 deletion tests/splines/batched_spline_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ static void BatchedPeriodicSplineTest()
// Compute usefull domains (dom_interpolation, dom_batch, dom_bsplines and dom_spline)
ddc::DiscreteDomain<IDim<I, I>> const dom_interpolation = spline_builder.interpolation_domain();
auto const dom_batch = spline_builder.batch_domain();
ddc::DiscreteDomain<BSplines<I>> 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
Expand Down
4 changes: 2 additions & 2 deletions tests/splines/cosine_evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ struct CosineEvaluator

public:
template <class Domain>
Evaluator(Domain domain) : m_c0(1.0)
, m_c1(0.0)
Evaluator([[maybe_unused]] Domain domain) : m_c0(1.0)
, m_c1(0.0)
{
}

Expand Down