From b246dfdee911ae9ce03f9d7563ea566dbcb91685 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Thu, 9 Jan 2025 13:09:03 +0100 Subject: [PATCH 1/7] Simplify notations in splines tests (#747) --- tests/splines/batched_2d_spline_builder.cpp | 111 +++++++++----------- tests/splines/batched_spline_builder.cpp | 35 +++--- tests/splines/extrapolation_rule.cpp | 68 ++++++------ 3 files changed, 98 insertions(+), 116 deletions(-) diff --git a/tests/splines/batched_2d_spline_builder.cpp b/tests/splines/batched_2d_spline_builder.cpp index 34006a5be..74b075ade 100644 --- a/tests/splines/batched_2d_spline_builder.cpp +++ b/tests/splines/batched_2d_spline_builder.cpp @@ -174,31 +174,28 @@ void InterestDimInitializer(std::size_t const ncells) template void Batched2dSplineTest() { + using DDimI1 = DDimGPS; + using DDimI2 = DDimGPS; + // Instantiate execution spaces and initialize spaces ExecSpace const exec_space; std::size_t const ncells = 10; - InterestDimInitializer>(ncells); - InterestDimInitializer>(ncells); + InterestDimInitializer(ncells); + InterestDimInitializer(ncells); // Create the values domain (mesh) - ddc::DiscreteDomain> const interpolation_domain1 - = GrevillePoints>::template get_domain>(); - ddc::DiscreteDomain> const interpolation_domain2 - = GrevillePoints>::template get_domain>(); - ddc::DiscreteDomain, DDim> const + ddc::DiscreteDomain const interpolation_domain1 + = GrevillePoints>::template get_domain(); + ddc::DiscreteDomain const interpolation_domain2 + = GrevillePoints>::template get_domain(); + ddc::DiscreteDomain const interpolation_domain(interpolation_domain1, interpolation_domain2); // If we remove auto using the constructor syntax, nvcc does not compile - auto const dom_vals_tmp = ddc::DiscreteDomain...>( - ddc::DiscreteDomain>(DElem>(0), DVect>(ncells))...); - ddc::DiscreteDomain...> const dom_vals - = ddc::replace_dim_of, DDim>( - ddc::replace_dim_of< - DDim, - DDim>(dom_vals_tmp, interpolation_domain), - interpolation_domain); + auto const dom_vals_tmp + = ddc::DiscreteDomain(ddc::DiscreteDomain(DElem(0), DVect(ncells))...); + ddc::DiscreteDomain...> const dom_vals = ddc::replace_dim_of( + ddc::replace_dim_of(dom_vals_tmp, interpolation_domain), + interpolation_domain); #if defined(BC_HERMITE) // Create the derivs domain @@ -210,11 +207,10 @@ void Batched2dSplineTest() derivs_domain(derivs_domain1, derivs_domain2); auto const dom_derivs_1d - = ddc::replace_dim_of, ddc::Deriv>(dom_vals, derivs_domain1); - auto const dom_derivs2 - = ddc::replace_dim_of, ddc::Deriv>(dom_vals, derivs_domain2); + = ddc::replace_dim_of>(dom_vals, derivs_domain1); + auto const dom_derivs2 = ddc::replace_dim_of>(dom_vals, derivs_domain2); auto const dom_derivs - = ddc::replace_dim_of, ddc::Deriv>(dom_derivs_1d, derivs_domain2); + = ddc::replace_dim_of>(dom_derivs_1d, derivs_domain2); #endif // Create a SplineBuilder over BSplines and batched along other dimensions using some boundary conditions @@ -223,8 +219,8 @@ void Batched2dSplineTest() MemorySpace, BSplines, BSplines, - DDim, - DDim, + DDimI1, + DDimI2, s_bcl, s_bcr, s_bcl, @@ -233,14 +229,14 @@ void Batched2dSplineTest() DDim...> const spline_builder(dom_vals); // Compute usefull domains (dom_interpolation, dom_batch, dom_bsplines and dom_spline) - ddc::DiscreteDomain, DDim> const dom_interpolation + ddc::DiscreteDomain const dom_interpolation = spline_builder.interpolation_domain(); auto const dom_spline = spline_builder.batched_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 ddc::Chunk vals_1d_host_alloc(dom_interpolation, ddc::HostAllocator()); ddc::ChunkSpan const vals_1d_host = vals_1d_host_alloc.span_view(); - evaluator_type, DDim> const evaluator(dom_interpolation); + evaluator_type const evaluator(dom_interpolation); evaluator(vals_1d_host); auto vals_1d_alloc = ddc::create_mirror_view_and_copy(exec_space, vals_1d_host); ddc::ChunkSpan const vals_1d = vals_1d_alloc.span_view(); @@ -251,7 +247,7 @@ void Batched2dSplineTest() exec_space, vals.domain(), KOKKOS_LAMBDA(DElem...> const e) { - vals(e) = vals_1d(DElem, DDim>(e)); + vals(e) = vals_1d(DElem(e)); }); #if defined(BC_HERMITE) @@ -261,16 +257,14 @@ void Batched2dSplineTest() ddc::ChunkSpan const derivs_1d_lhs = derivs_1d_lhs_alloc.span_view(); if (s_bcl == ddc::BoundCond::HERMITE) { ddc::Chunk derivs_1d_lhs1_host_alloc( - ddc::DiscreteDomain< - ddc::Deriv, - DDim>(derivs_domain1, interpolation_domain2), + ddc::DiscreteDomain, DDimI2>(derivs_domain1, interpolation_domain2), ddc::HostAllocator()); ddc::ChunkSpan const derivs_1d_lhs1_host = derivs_1d_lhs1_host_alloc.span_view(); ddc::for_each( derivs_1d_lhs1_host.domain(), - KOKKOS_LAMBDA(ddc::DiscreteElement, DDim> const e) { + KOKKOS_LAMBDA(ddc::DiscreteElement, DDimI2> const e) { auto deriv_idx = ddc::DiscreteElement>(e).uid(); - auto x2 = ddc::coordinate(ddc::DiscreteElement>(e)); + auto x2 = ddc::coordinate(ddc::DiscreteElement(e)); derivs_1d_lhs1_host(e) = evaluator.deriv(x0(), x2, deriv_idx + shift - 1, 0); }); @@ -283,7 +277,7 @@ void Batched2dSplineTest() derivs_1d_lhs.domain(), KOKKOS_LAMBDA( typename decltype(derivs_1d_lhs.domain())::discrete_element_type const e) { - derivs_1d_lhs(e) = derivs_1d_lhs1(DElem, DDim>(e)); + derivs_1d_lhs(e) = derivs_1d_lhs1(DElem, DDimI2>(e)); }); } @@ -291,16 +285,14 @@ void Batched2dSplineTest() ddc::ChunkSpan const derivs_1d_rhs = derivs_1d_rhs_alloc.span_view(); if (s_bcl == ddc::BoundCond::HERMITE) { ddc::Chunk derivs_1d_rhs1_host_alloc( - ddc::DiscreteDomain< - ddc::Deriv, - DDim>(derivs_domain1, interpolation_domain2), + ddc::DiscreteDomain, DDimI2>(derivs_domain1, interpolation_domain2), ddc::HostAllocator()); ddc::ChunkSpan const derivs_1d_rhs1_host = derivs_1d_rhs1_host_alloc.span_view(); ddc::for_each( derivs_1d_rhs1_host.domain(), - KOKKOS_LAMBDA(ddc::DiscreteElement, DDim> const e) { + KOKKOS_LAMBDA(ddc::DiscreteElement, DDimI2> const e) { auto deriv_idx = ddc::DiscreteElement>(e).uid(); - auto x2 = ddc::coordinate(ddc::DiscreteElement>(e)); + auto x2 = ddc::coordinate(ddc::DiscreteElement(e)); derivs_1d_rhs1_host(e) = evaluator.deriv(xN(), x2, deriv_idx + shift - 1, 0); }); @@ -313,7 +305,7 @@ void Batched2dSplineTest() derivs_1d_rhs.domain(), KOKKOS_LAMBDA( typename decltype(derivs_1d_rhs.domain())::discrete_element_type const e) { - derivs_1d_rhs(e) = derivs_1d_rhs1(DElem, DDim>(e)); + derivs_1d_rhs(e) = derivs_1d_rhs1(DElem, DDimI2>(e)); }); } @@ -321,15 +313,13 @@ void Batched2dSplineTest() ddc::ChunkSpan const derivs2_lhs = derivs2_lhs_alloc.span_view(); if (s_bcl == ddc::BoundCond::HERMITE) { ddc::Chunk derivs2_lhs1_host_alloc( - ddc::DiscreteDomain< - DDim, - ddc::Deriv>(interpolation_domain1, derivs_domain2), + ddc::DiscreteDomain>(interpolation_domain1, derivs_domain2), ddc::HostAllocator()); ddc::ChunkSpan const derivs2_lhs1_host = derivs2_lhs1_host_alloc.span_view(); ddc::for_each( derivs2_lhs1_host.domain(), - KOKKOS_LAMBDA(ddc::DiscreteElement, ddc::Deriv> const e) { - auto x1 = ddc::coordinate(ddc::DiscreteElement>(e)); + KOKKOS_LAMBDA(ddc::DiscreteElement> const e) { + auto x1 = ddc::coordinate(ddc::DiscreteElement(e)); auto deriv_idx = ddc::DiscreteElement>(e).uid(); derivs2_lhs1_host(e) = evaluator.deriv(x1, x0(), 0, deriv_idx + shift - 1); }); @@ -342,7 +332,7 @@ void Batched2dSplineTest() derivs2_lhs.domain(), KOKKOS_LAMBDA( typename decltype(derivs2_lhs.domain())::discrete_element_type const e) { - derivs2_lhs(e) = derivs2_lhs1(DElem, ddc::Deriv>(e)); + derivs2_lhs(e) = derivs2_lhs1(DElem>(e)); }); } @@ -350,15 +340,13 @@ void Batched2dSplineTest() ddc::ChunkSpan const derivs2_rhs = derivs2_rhs_alloc.span_view(); if (s_bcl == ddc::BoundCond::HERMITE) { ddc::Chunk derivs2_rhs1_host_alloc( - ddc::DiscreteDomain< - DDim, - ddc::Deriv>(interpolation_domain1, derivs_domain2), + ddc::DiscreteDomain>(interpolation_domain1, derivs_domain2), ddc::HostAllocator()); ddc::ChunkSpan const derivs2_rhs1_host = derivs2_rhs1_host_alloc.span_view(); ddc::for_each( derivs2_rhs1_host.domain(), - KOKKOS_LAMBDA(ddc::DiscreteElement, ddc::Deriv> const e) { - auto x1 = ddc::coordinate(ddc::DiscreteElement>(e)); + KOKKOS_LAMBDA(ddc::DiscreteElement> const e) { + auto x1 = ddc::coordinate(ddc::DiscreteElement(e)); auto deriv_idx = ddc::DiscreteElement>(e).uid(); derivs2_rhs1_host(e) = evaluator.deriv(x1, xN(), 0, deriv_idx + shift - 1); }); @@ -371,7 +359,7 @@ void Batched2dSplineTest() derivs2_rhs.domain(), KOKKOS_LAMBDA( typename decltype(derivs2_rhs.domain())::discrete_element_type const e) { - derivs2_rhs(e) = derivs2_rhs1(DElem, ddc::Deriv>(e)); + derivs2_rhs(e) = derivs2_rhs1(DElem>(e)); }); } @@ -484,8 +472,8 @@ void Batched2dSplineTest() MemorySpace, BSplines, BSplines, - DDim, - DDim, + DDimI1, + DDimI2, extrapolation_rule_1_type, extrapolation_rule_1_type, extrapolation_rule_2_type, @@ -504,7 +492,7 @@ void Batched2dSplineTest() exec_space, coords_eval.domain(), KOKKOS_LAMBDA(DElem...> const e) { - coords_eval(e) = ddc::coordinate(DElem, DDim>(e)); + coords_eval(e) = ddc::coordinate(DElem(e)); }); @@ -543,8 +531,8 @@ void Batched2dSplineTest() 0., ddc::reducer::max(), KOKKOS_LAMBDA(DElem...> const e) { - Coord const x = ddc::coordinate(DElem>(e)); - Coord const y = ddc::coordinate(DElem>(e)); + Coord const x = ddc::coordinate(DElem(e)); + Coord const y = ddc::coordinate(DElem(e)); return Kokkos::abs(spline_eval_deriv1(e) - evaluator.deriv(x, y, 1, 0)); }); double const max_norm_error_diff2 = ddc::parallel_transform_reduce( @@ -553,8 +541,8 @@ void Batched2dSplineTest() 0., ddc::reducer::max(), KOKKOS_LAMBDA(DElem...> const e) { - Coord const x = ddc::coordinate(DElem>(e)); - Coord const y = ddc::coordinate(DElem>(e)); + Coord const x = ddc::coordinate(DElem(e)); + Coord const y = ddc::coordinate(DElem(e)); return Kokkos::abs(spline_eval_deriv2(e) - evaluator.deriv(x, y, 0, 1)); }); double const max_norm_error_diff12 = ddc::parallel_transform_reduce( @@ -563,8 +551,8 @@ void Batched2dSplineTest() 0., ddc::reducer::max(), KOKKOS_LAMBDA(DElem...> const e) { - Coord const x = ddc::coordinate(DElem>(e)); - Coord const y = ddc::coordinate(DElem>(e)); + Coord const x = ddc::coordinate(DElem(e)); + Coord const y = ddc::coordinate(DElem(e)); return Kokkos::abs(spline_eval_deriv12(e) - evaluator.deriv(x, y, 1, 1)); }); @@ -574,8 +562,7 @@ void Batched2dSplineTest() double const max_norm_diff2 = evaluator.max_norm(0, 1); double const max_norm_diff12 = evaluator.max_norm(1, 1); - SplineErrorBounds, DDim>> const error_bounds( - evaluator); + SplineErrorBounds> const error_bounds(evaluator); EXPECT_LE( max_norm_error, std:: diff --git a/tests/splines/batched_spline_builder.cpp b/tests/splines/batched_spline_builder.cpp index cad56aa05..1d9a5ac3d 100644 --- a/tests/splines/batched_spline_builder.cpp +++ b/tests/splines/batched_spline_builder.cpp @@ -179,27 +179,28 @@ void InterestDimInitializer(std::size_t const ncells) template void BatchedSplineTest() { + using DDimI = DDimGPS; + // Instantiate execution spaces and initialize spaces ExecSpace const exec_space; std::size_t const ncells = 10; - InterestDimInitializer>(ncells); + InterestDimInitializer(ncells); // Create the values domain (mesh) - ddc::DiscreteDomain> const interpolation_domain - = GrevillePoints>::template get_domain>(); + ddc::DiscreteDomain const interpolation_domain + = GrevillePoints>::template get_domain(); // If we remove auto using the constructor syntax, nvcc does not compile - auto const dom_vals_tmp = ddc::DiscreteDomain...>( - ddc::DiscreteDomain< - DDim>(DElem>(0), DVect>(ncells))...); + auto const dom_vals_tmp + = ddc::DiscreteDomain(ddc::DiscreteDomain(DElem(0), DVect(ncells))...); ddc::DiscreteDomain...> const dom_vals - = ddc::replace_dim_of, DDim>(dom_vals_tmp, interpolation_domain); + = ddc::replace_dim_of(dom_vals_tmp, interpolation_domain); #if defined(BC_HERMITE) // Create the derivs domain ddc::DiscreteDomain> const derivs_domain(DElem>(1), DVect>(s_degree_x / 2)); - auto const dom_derivs = ddc::replace_dim_of, ddc::Deriv>(dom_vals, derivs_domain); + auto const dom_derivs = ddc::replace_dim_of>(dom_vals, derivs_domain); #endif // Create a SplineBuilder over BSplines and batched along other dimensions using some boundary conditions @@ -207,7 +208,7 @@ void BatchedSplineTest() ExecSpace, MemorySpace, BSplines, - DDim, + DDimI, s_bcl, s_bcr, #if defined(SOLVER_LAPACK) @@ -218,14 +219,14 @@ void BatchedSplineTest() DDim...> const spline_builder(dom_vals); // Compute usefull domains (dom_interpolation, dom_batch, dom_bsplines and dom_spline) - ddc::DiscreteDomain> const dom_interpolation = spline_builder.interpolation_domain(); + ddc::DiscreteDomain const dom_interpolation = spline_builder.interpolation_domain(); auto const dom_batch = spline_builder.batch_domain(); auto const dom_spline = spline_builder.batched_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 ddc::Chunk vals_1d_host_alloc(dom_interpolation, ddc::HostAllocator()); ddc::ChunkSpan const vals_1d_host = vals_1d_host_alloc.span_view(); - evaluator_type> const evaluator(dom_interpolation); + evaluator_type const evaluator(dom_interpolation); evaluator(vals_1d_host); auto vals_1d_alloc = ddc::create_mirror_view_and_copy(exec_space, vals_1d_host); ddc::ChunkSpan const vals_1d = vals_1d_alloc.span_view(); @@ -235,9 +236,7 @@ void BatchedSplineTest() ddc::parallel_for_each( exec_space, vals.domain(), - KOKKOS_LAMBDA(DElem...> const e) { - vals(e) = vals_1d(DElem>(e)); - }); + KOKKOS_LAMBDA(DElem...> const e) { vals(e) = vals_1d(DElem(e)); }); #if defined(BC_HERMITE) // Allocate and fill a chunk containing derivs to be passed as input to spline_builder. @@ -315,7 +314,7 @@ void BatchedSplineTest() ExecSpace, MemorySpace, BSplines, - DDim, + DDimI, extrapolation_rule_type, extrapolation_rule_type, DDim...> const spline_evaluator_batched(extrapolation_rule, extrapolation_rule); @@ -327,7 +326,7 @@ void BatchedSplineTest() exec_space, coords_eval.domain(), KOKKOS_LAMBDA(DElem...> const e) { - coords_eval(e) = ddc::coordinate(DElem>(e)); + coords_eval(e) = ddc::coordinate(DElem(e)); }); @@ -360,7 +359,7 @@ void BatchedSplineTest() 0., ddc::reducer::max(), KOKKOS_LAMBDA(DElem...> const e) { - Coord const x = ddc::coordinate(DElem>(e)); + Coord const x = ddc::coordinate(DElem(e)); return Kokkos::abs(spline_eval_deriv(e) - evaluator.deriv(x, 1)); }); double const max_norm_error_integ = ddc::parallel_transform_reduce( @@ -379,7 +378,7 @@ void BatchedSplineTest() double const max_norm_diff = evaluator.max_norm(1); double const max_norm_int = evaluator.max_norm(-1); - SplineErrorBounds>> const error_bounds(evaluator); + SplineErrorBounds> const error_bounds(evaluator); EXPECT_LE( max_norm_error, std::max(error_bounds.error_bound(dx(ncells), s_degree_x), 1.0e-14 * max_norm)); diff --git a/tests/splines/extrapolation_rule.cpp b/tests/splines/extrapolation_rule.cpp index 3620a118a..1c31c6fc0 100644 --- a/tests/splines/extrapolation_rule.cpp +++ b/tests/splines/extrapolation_rule.cpp @@ -162,32 +162,29 @@ void InterestDimInitializer(std::size_t const ncells) template void ExtrapolationRuleSplineTest() { + using DDimI1 = DDimGPS1; + using DDimI2 = DDimGPS2; + // Instantiate execution spaces and initialize spaces ExecSpace const exec_space; std::size_t const ncells = 10; - InterestDimInitializer>(ncells); - ddc::init_discrete_space>( - GrevillePoints1>::template get_sampling>()); - InterestDimInitializer>(ncells); - ddc::init_discrete_space>( - GrevillePoints2>::template get_sampling>()); + InterestDimInitializer(ncells); + ddc::init_discrete_space( + GrevillePoints1>::template get_sampling()); + InterestDimInitializer(ncells); + ddc::init_discrete_space( + GrevillePoints2>::template get_sampling()); // Create the values domain (mesh) - ddc::DiscreteDomain, DDim> const interpolation_domain( - GrevillePoints1>::template get_domain>(), - GrevillePoints2>::template get_domain>()); + ddc::DiscreteDomain const interpolation_domain( + GrevillePoints1>::template get_domain(), + GrevillePoints2>::template get_domain()); // If we remove auto using the constructor syntax, nvcc does not compile - auto const dom_vals_tmp = ddc::DiscreteDomain...>( - ddc::DiscreteDomain>(DElem>(0), DVect>(ncells))...); - ddc::DiscreteDomain...> const dom_vals - = ddc::replace_dim_of, DDim>( - ddc::replace_dim_of< - DDim, - DDim>(dom_vals_tmp, interpolation_domain), - interpolation_domain); + auto const dom_vals_tmp + = ddc::DiscreteDomain(ddc::DiscreteDomain(DElem(0), DVect(ncells))...); + ddc::DiscreteDomain...> const dom_vals = ddc::replace_dim_of( + ddc::replace_dim_of(dom_vals_tmp, interpolation_domain), + interpolation_domain); // Create a SplineBuilder over BSplines and batched along other dimensions using some boundary conditions ddc::SplineBuilder2D< @@ -195,8 +192,8 @@ void ExtrapolationRuleSplineTest() MemorySpace, BSplines, BSplines, - DDim, - DDim, + DDimI1, + DDimI2, s_bcl1, s_bcr1, s_bcl2, @@ -205,14 +202,14 @@ void ExtrapolationRuleSplineTest() DDim...> const spline_builder(dom_vals); // Compute usefull domains (dom_interpolation, dom_batch, dom_bsplines and dom_spline) - ddc::DiscreteDomain, DDim> const dom_interpolation + ddc::DiscreteDomain const dom_interpolation = spline_builder.interpolation_domain(); auto const dom_spline = spline_builder.batched_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 ddc::Chunk vals_1d_host_alloc(dom_interpolation, ddc::HostAllocator()); ddc::ChunkSpan const vals_1d_host = vals_1d_host_alloc.span_view(); - evaluator_type, DDim> const evaluator(dom_interpolation); + evaluator_type const evaluator(dom_interpolation); evaluator(vals_1d_host); auto vals_1d_alloc = ddc::create_mirror_view_and_copy(exec_space, vals_1d_host); ddc::ChunkSpan const vals_1d = vals_1d_alloc.span_view(); @@ -223,7 +220,7 @@ void ExtrapolationRuleSplineTest() exec_space, vals.domain(), KOKKOS_LAMBDA(DElem...> const e) { - vals(e) = vals_1d(DElem, DDim>(e)); + vals(e) = vals_1d(DElem(e)); }); // Instantiate chunk of spline coefs to receive output of spline_builder @@ -272,8 +269,8 @@ void ExtrapolationRuleSplineTest() MemorySpace, BSplines, BSplines, - DDim, - DDim, + DDimI1, + DDimI2, extrapolation_rule_dim_1_type, extrapolation_rule_dim_1_type, extrapolation_rule_dim_2_type, @@ -296,8 +293,7 @@ void ExtrapolationRuleSplineTest() exec_space, coords_eval.domain(), KOKKOS_LAMBDA(DElem...> const e) { - coords_eval(e) - = ddc::coordinate(DElem, DDim>(e)) + displ; + coords_eval(e) = ddc::coordinate(DElem(e)) + displ; }); @@ -320,27 +316,27 @@ void ExtrapolationRuleSplineTest() #elif defined(ER_CONSTANT) typename decltype(ddc::remove_dims_of( vals.domain(), - vals.template domain>()))::discrete_element_type const + vals.template domain()))::discrete_element_type const e_without_interest(e); double tmp; if (Coord(coords_eval(e)) > xN()) { #if defined(BC_PERIODIC) tmp = vals(ddc::DiscreteElement...>( - vals.template domain>().back(), + vals.template domain().back(), e_without_interest)); #else typename decltype(ddc::remove_dims_of( vals.domain(), - vals.template domain, DDim>())):: - discrete_element_type const e_batch(e); + vals.template domain()))::discrete_element_type const + e_batch(e); tmp = vals(ddc::DiscreteElement...>( - vals.template domain>().back(), - vals.template domain>().back(), + vals.template domain().back(), + vals.template domain().back(), e_batch)); #endif } else { tmp = vals(ddc::DiscreteElement...>( - vals.template domain>().back(), + vals.template domain().back(), e_without_interest)); } return Kokkos::abs(spline_eval(e) - tmp); From b06383d6772a62742b627d44f4c683f70abc0de1 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Thu, 9 Jan 2025 17:48:36 +0100 Subject: [PATCH 2/7] Template tests by discrete dimensions instead of continuous dimensions (#748) --- tests/splines/batched_2d_spline_builder.cpp | 113 ++++++++++--------- tests/splines/batched_spline_builder.cpp | 114 ++++++++++---------- tests/splines/extrapolation_rule.cpp | 65 ++++++----- 3 files changed, 139 insertions(+), 153 deletions(-) diff --git a/tests/splines/batched_2d_spline_builder.cpp b/tests/splines/batched_2d_spline_builder.cpp index 74b075ade..9d5e42e10 100644 --- a/tests/splines/batched_2d_spline_builder.cpp +++ b/tests/splines/batched_2d_spline_builder.cpp @@ -100,9 +100,6 @@ struct DDimGPS : GrevillePoints>::interpolation_discrete_dimension_t { }; -template -using DDim = std::conditional_t || std::is_same_v, DDimGPS, X>; - #if defined(BC_PERIODIC) template using evaluator_type = Evaluator2D:: @@ -121,10 +118,6 @@ using DVect = ddc::DiscreteVector; template using Coord = ddc::Coordinate; -// Extract batch dimensions from DDim (remove dimension of interest). Usefull -template -using BatchDims = ddc::type_seq_remove_t, ddc::detail::TypeSeq>; - // Templated function giving first coordinate of the mesh in given dimension. template KOKKOS_FUNCTION Coord x0() @@ -171,11 +164,16 @@ void InterestDimInitializer(std::size_t const ncells) // Checks that when evaluating the spline at interpolation points one // recovers values that were used to build the spline -template +template < + typename ExecSpace, + typename MemorySpace, + typename DDimI1, + typename DDimI2, + typename... DDims> void Batched2dSplineTest() { - using DDimI1 = DDimGPS; - using DDimI2 = DDimGPS; + using I1 = typename DDimI1::continuous_dimension_type; + using I2 = typename DDimI2::continuous_dimension_type; // Instantiate execution spaces and initialize spaces ExecSpace const exec_space; @@ -188,14 +186,13 @@ void Batched2dSplineTest() = GrevillePoints>::template get_domain(); ddc::DiscreteDomain const interpolation_domain2 = GrevillePoints>::template get_domain(); - ddc::DiscreteDomain const - interpolation_domain(interpolation_domain1, interpolation_domain2); - // If we remove auto using the constructor syntax, nvcc does not compile - auto const dom_vals_tmp - = ddc::DiscreteDomain(ddc::DiscreteDomain(DElem(0), DVect(ncells))...); - ddc::DiscreteDomain...> const dom_vals = ddc::replace_dim_of( - ddc::replace_dim_of(dom_vals_tmp, interpolation_domain), - interpolation_domain); + // The following line creates a discrete domain over all dimensions (DDims...) where we immediately + // remove the dimensions DDimI1 and DDimI2. + ddc::remove_dims_of_t, DDimI1, DDimI2> const dom_vals_tmp( + ddc::DiscreteDomain( + ddc::DiscreteDomain(DElem(0), DVect(ncells))...)); + ddc::DiscreteDomain const + dom_vals(dom_vals_tmp, interpolation_domain1, interpolation_domain2); #if defined(BC_HERMITE) // Create the derivs domain @@ -226,7 +223,7 @@ void Batched2dSplineTest() s_bcl, s_bcr, ddc::SplineSolver::GINKGO, - DDim...> const spline_builder(dom_vals); + DDims...> const spline_builder(dom_vals); // Compute usefull domains (dom_interpolation, dom_batch, dom_bsplines and dom_spline) ddc::DiscreteDomain const dom_interpolation @@ -246,7 +243,7 @@ void Batched2dSplineTest() ddc::parallel_for_each( exec_space, vals.domain(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { vals(e) = vals_1d(DElem(e)); }); @@ -478,7 +475,7 @@ void Batched2dSplineTest() extrapolation_rule_1_type, extrapolation_rule_2_type, extrapolation_rule_2_type, - DDim...> const + DDims...> const spline_evaluator( extrapolation_rule_1, extrapolation_rule_1, @@ -491,7 +488,7 @@ void Batched2dSplineTest() ddc::parallel_for_each( exec_space, coords_eval.domain(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { coords_eval(e) = ddc::coordinate(DElem(e)); }); @@ -522,7 +519,7 @@ void Batched2dSplineTest() spline_eval.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { return Kokkos::abs(spline_eval(e) - vals(e)); }); double const max_norm_error_diff1 = ddc::parallel_transform_reduce( @@ -530,7 +527,7 @@ void Batched2dSplineTest() spline_eval_deriv1.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { Coord const x = ddc::coordinate(DElem(e)); Coord const y = ddc::coordinate(DElem(e)); return Kokkos::abs(spline_eval_deriv1(e) - evaluator.deriv(x, y, 1, 0)); @@ -540,7 +537,7 @@ void Batched2dSplineTest() spline_eval_deriv2.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { Coord const x = ddc::coordinate(DElem(e)); Coord const y = ddc::coordinate(DElem(e)); return Kokkos::abs(spline_eval_deriv2(e) - evaluator.deriv(x, y, 0, 1)); @@ -550,7 +547,7 @@ void Batched2dSplineTest() spline_eval_deriv1.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { Coord const x = ddc::coordinate(DElem(e)); Coord const y = ddc::coordinate(DElem(e)); return Kokkos::abs(spline_eval_deriv12(e) - evaluator.deriv(x, y, 1, 1)); @@ -619,10 +616,10 @@ TEST(SUFFIX(Batched2dSplineHost), 2DXY) Batched2dSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimX, - DimY, - DimX, - DimY>(); + DDimGPS, + DDimGPS, + DDimGPS, + DDimGPS>(); } TEST(SUFFIX(Batched2dSplineDevice), 2DXY) @@ -630,10 +627,10 @@ TEST(SUFFIX(Batched2dSplineDevice), 2DXY) Batched2dSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimX, - DimY, - DimX, - DimY>(); + DDimGPS, + DDimGPS, + DDimGPS, + DDimGPS>(); } TEST(SUFFIX(Batched2dSplineHost), 3DXY) @@ -641,10 +638,10 @@ TEST(SUFFIX(Batched2dSplineHost), 3DXY) Batched2dSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimX, - DimY, - DimX, - DimY, + DDimGPS, + DDimGPS, + DDimGPS, + DDimGPS, DDimBatch>(); } @@ -653,11 +650,11 @@ TEST(SUFFIX(Batched2dSplineHost), 3DXZ) Batched2dSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimX, - DimZ, - DimX, + DDimGPS, + DDimGPS, + DDimGPS, DDimBatch, - DimZ>(); + DDimGPS>(); } TEST(SUFFIX(Batched2dSplineHost), 3DYZ) @@ -665,11 +662,11 @@ TEST(SUFFIX(Batched2dSplineHost), 3DYZ) Batched2dSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimY, - DimZ, + DDimGPS, + DDimGPS, DDimBatch, - DimY, - DimZ>(); + DDimGPS, + DDimGPS>(); } TEST(SUFFIX(Batched2dSplineDevice), 3DXY) @@ -677,10 +674,10 @@ TEST(SUFFIX(Batched2dSplineDevice), 3DXY) Batched2dSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimX, - DimY, - DimX, - DimY, + DDimGPS, + DDimGPS, + DDimGPS, + DDimGPS, DDimBatch>(); } @@ -689,11 +686,11 @@ TEST(SUFFIX(Batched2dSplineDevice), 3DXZ) Batched2dSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimX, - DimZ, - DimX, + DDimGPS, + DDimGPS, + DDimGPS, DDimBatch, - DimZ>(); + DDimGPS>(); } TEST(SUFFIX(Batched2dSplineDevice), 3DYZ) @@ -701,9 +698,9 @@ TEST(SUFFIX(Batched2dSplineDevice), 3DYZ) Batched2dSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimY, - DimZ, + DDimGPS, + DDimGPS, DDimBatch, - DimY, - DimZ>(); + DDimGPS, + DDimGPS>(); } diff --git a/tests/splines/batched_spline_builder.cpp b/tests/splines/batched_spline_builder.cpp index 1d9a5ac3d..3165c00a7 100644 --- a/tests/splines/batched_spline_builder.cpp +++ b/tests/splines/batched_spline_builder.cpp @@ -113,9 +113,6 @@ struct DDimGPS : GrevillePoints>::interpolation_discrete_dimension_t { }; -template -using DDim = std::conditional_t, DDimGPS, X>; - template using evaluator_type = CosineEvaluator::Evaluator; @@ -126,10 +123,6 @@ using DVect = ddc::DiscreteVector; template using Coord = ddc::Coordinate; -// Extract batch dimensions from DDim (remove dimension of interest). Usefull -template -using BatchDims = ddc::type_seq_remove_t, ddc::detail::TypeSeq>; - // Templated function giving first coordinate of the mesh in given dimension. template KOKKOS_FUNCTION Coord x0() @@ -176,10 +169,10 @@ void InterestDimInitializer(std::size_t const ncells) // Checks that when evaluating the spline at interpolation points one // recovers values that were used to build the spline -template +template void BatchedSplineTest() { - using DDimI = DDimGPS; + using I = typename DDimI::continuous_dimension_type; // Instantiate execution spaces and initialize spaces ExecSpace const exec_space; @@ -190,11 +183,12 @@ void BatchedSplineTest() // Create the values domain (mesh) ddc::DiscreteDomain const interpolation_domain = GrevillePoints>::template get_domain(); - // If we remove auto using the constructor syntax, nvcc does not compile - auto const dom_vals_tmp - = ddc::DiscreteDomain(ddc::DiscreteDomain(DElem(0), DVect(ncells))...); - ddc::DiscreteDomain...> const dom_vals - = ddc::replace_dim_of(dom_vals_tmp, interpolation_domain); + // The following line creates a discrete domain over all dimensions (DDims...) where we immediately + // remove the dimension DDimI. + ddc::remove_dims_of_t, DDimI> const dom_vals_tmp( + ddc::DiscreteDomain( + ddc::DiscreteDomain(DElem(0), DVect(ncells))...)); + ddc::DiscreteDomain const dom_vals(dom_vals_tmp, interpolation_domain); #if defined(BC_HERMITE) // Create the derivs domain @@ -216,7 +210,7 @@ void BatchedSplineTest() #elif defined(SOLVER_GINKGO) ddc::SplineSolver::GINKGO, #endif - DDim...> const spline_builder(dom_vals); + DDims...> const spline_builder(dom_vals); // Compute usefull domains (dom_interpolation, dom_batch, dom_bsplines and dom_spline) ddc::DiscreteDomain const dom_interpolation = spline_builder.interpolation_domain(); @@ -236,7 +230,7 @@ void BatchedSplineTest() ddc::parallel_for_each( exec_space, vals.domain(), - KOKKOS_LAMBDA(DElem...> const e) { vals(e) = vals_1d(DElem(e)); }); + KOKKOS_LAMBDA(DElem const e) { vals(e) = vals_1d(DElem(e)); }); #if defined(BC_HERMITE) // Allocate and fill a chunk containing derivs to be passed as input to spline_builder. @@ -317,7 +311,7 @@ void BatchedSplineTest() DDimI, extrapolation_rule_type, extrapolation_rule_type, - DDim...> const spline_evaluator_batched(extrapolation_rule, extrapolation_rule); + DDims...> const spline_evaluator_batched(extrapolation_rule, extrapolation_rule); // Instantiate chunk of coordinates of dom_interpolation ddc::Chunk coords_eval_alloc(dom_vals, ddc::KokkosAllocator, MemorySpace>()); @@ -325,7 +319,7 @@ void BatchedSplineTest() ddc::parallel_for_each( exec_space, coords_eval.domain(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { coords_eval(e) = ddc::coordinate(DElem(e)); }); @@ -349,7 +343,7 @@ void BatchedSplineTest() spline_eval.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { return Kokkos::abs(spline_eval(e) - vals(e)); }); @@ -358,7 +352,7 @@ void BatchedSplineTest() spline_eval_deriv.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { Coord const x = ddc::coordinate(DElem(e)); return Kokkos::abs(spline_eval_deriv(e) - evaluator.deriv(x, 1)); }); @@ -427,8 +421,8 @@ TEST(SUFFIX(BatchedSplineHost), 1DX) BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimX, - DimX>(); + DDimGPS, + DDimGPS>(); } TEST(SUFFIX(BatchedSplineDevice), 1DX) @@ -436,8 +430,8 @@ TEST(SUFFIX(BatchedSplineDevice), 1DX) BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimX, - DimX>(); + DDimGPS, + DDimGPS>(); } TEST(SUFFIX(BatchedSplineHost), 2DX) @@ -445,8 +439,8 @@ TEST(SUFFIX(BatchedSplineHost), 2DX) BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimX, - DimX, + DDimGPS, + DDimGPS, DDimBatch1>(); } @@ -455,9 +449,9 @@ TEST(SUFFIX(BatchedSplineHost), 2DY) BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimY, + DDimGPS, DDimBatch1, - DimY>(); + DDimGPS>(); } TEST(SUFFIX(BatchedSplineDevice), 2DX) @@ -465,8 +459,8 @@ TEST(SUFFIX(BatchedSplineDevice), 2DX) BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimX, - DimX, + DDimGPS, + DDimGPS, DDimBatch1>(); } @@ -475,9 +469,9 @@ TEST(SUFFIX(BatchedSplineDevice), 2DY) BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimY, + DDimGPS, DDimBatch1, - DimY>(); + DDimGPS>(); } TEST(SUFFIX(BatchedSplineHost), 3DX) @@ -485,8 +479,8 @@ TEST(SUFFIX(BatchedSplineHost), 3DX) BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimX, - DimX, + DDimGPS, + DDimGPS, DDimBatch1, DDimBatch2>(); } @@ -496,9 +490,9 @@ TEST(SUFFIX(BatchedSplineHost), 3DY) BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimY, + DDimGPS, DDimBatch1, - DimY, + DDimGPS, DDimBatch2>(); } @@ -507,10 +501,10 @@ TEST(SUFFIX(BatchedSplineHost), 3DZ) BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimZ, + DDimGPS, DDimBatch1, DDimBatch2, - DimZ>(); + DDimGPS>(); } TEST(SUFFIX(BatchedSplineDevice), 3DX) @@ -518,8 +512,8 @@ TEST(SUFFIX(BatchedSplineDevice), 3DX) BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimX, - DimX, + DDimGPS, + DDimGPS, DDimBatch1, DDimBatch2>(); } @@ -529,9 +523,9 @@ TEST(SUFFIX(BatchedSplineDevice), 3DY) BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimY, + DDimGPS, DDimBatch1, - DimY, + DDimGPS, DDimBatch2>(); } @@ -540,10 +534,10 @@ TEST(SUFFIX(BatchedSplineDevice), 3DZ) BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimZ, + DDimGPS, DDimBatch1, DDimBatch2, - DimZ>(); + DDimGPS>(); } @@ -552,8 +546,8 @@ TEST(SUFFIX(BatchedSplineHost), 4DX) BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimX, - DimX, + DDimGPS, + DDimGPS, DDimBatch1, DDimBatch2, DDimBatch3>(); @@ -564,9 +558,9 @@ TEST(SUFFIX(BatchedSplineHost), 4DY) BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimY, + DDimGPS, DDimBatch1, - DimY, + DDimGPS, DDimBatch2, DDimBatch3>(); } @@ -576,10 +570,10 @@ TEST(SUFFIX(BatchedSplineHost), 4DZ) BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimZ, + DDimGPS, DDimBatch1, DDimBatch2, - DimZ, + DDimGPS, DDimBatch3>(); } @@ -588,11 +582,11 @@ TEST(SUFFIX(BatchedSplineHost), 4DT) BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimT, + DDimGPS, DDimBatch1, DDimBatch2, DDimBatch3, - DimT>(); + DDimGPS>(); } TEST(SUFFIX(BatchedSplineDevice), 4DX) @@ -600,8 +594,8 @@ TEST(SUFFIX(BatchedSplineDevice), 4DX) BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimX, - DimX, + DDimGPS, + DDimGPS, DDimBatch1, DDimBatch2, DDimBatch3>(); @@ -612,9 +606,9 @@ TEST(SUFFIX(BatchedSplineDevice), 4DY) BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimY, + DDimGPS, DDimBatch1, - DimY, + DDimGPS, DDimBatch2, DDimBatch3>(); } @@ -624,10 +618,10 @@ TEST(SUFFIX(BatchedSplineDevice), 4DZ) BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimZ, + DDimGPS, DDimBatch1, DDimBatch2, - DimZ, + DDimGPS, DDimBatch3>(); } @@ -636,9 +630,9 @@ TEST(SUFFIX(BatchedSplineDevice), 4DT) BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimT, + DDimGPS, DDimBatch1, DDimBatch2, DDimBatch3, - DimT>(); + DDimGPS>(); } diff --git a/tests/splines/extrapolation_rule.cpp b/tests/splines/extrapolation_rule.cpp index 1c31c6fc0..a91eac67a 100644 --- a/tests/splines/extrapolation_rule.cpp +++ b/tests/splines/extrapolation_rule.cpp @@ -86,12 +86,6 @@ struct DDimGPS2 : GrevillePoints2>::interpolation_discrete_dimension { }; -template -using DDim = std::conditional_t< - std::is_same_v, - DDimGPS1, - std::conditional_t, DDimGPS2, X>>; - #if defined(BC_PERIODIC) template using evaluator_type = Evaluator2D:: @@ -110,10 +104,6 @@ using DVect = ddc::DiscreteVector; template using Coord = ddc::Coordinate; -// Extract batch dimensions from DDim (remove dimension of interest). Usefull -template -using BatchDims = ddc::type_seq_remove_t, ddc::detail::TypeSeq>; - // Templated function giving first coordinate of the mesh in given dimension. template KOKKOS_FUNCTION Coord x0() @@ -159,11 +149,16 @@ void InterestDimInitializer(std::size_t const ncells) // Checks that when evaluating the spline at interpolation points one // recovers values that were used to build the spline -template +template < + typename ExecSpace, + typename MemorySpace, + typename DDimI1, + typename DDimI2, + typename... DDims> void ExtrapolationRuleSplineTest() { - using DDimI1 = DDimGPS1; - using DDimI2 = DDimGPS2; + using I1 = typename DDimI1::continuous_dimension_type; + using I2 = typename DDimI2::continuous_dimension_type; // Instantiate execution spaces and initialize spaces ExecSpace const exec_space; @@ -179,12 +174,12 @@ void ExtrapolationRuleSplineTest() ddc::DiscreteDomain const interpolation_domain( GrevillePoints1>::template get_domain(), GrevillePoints2>::template get_domain()); - // If we remove auto using the constructor syntax, nvcc does not compile - auto const dom_vals_tmp - = ddc::DiscreteDomain(ddc::DiscreteDomain(DElem(0), DVect(ncells))...); - ddc::DiscreteDomain...> const dom_vals = ddc::replace_dim_of( - ddc::replace_dim_of(dom_vals_tmp, interpolation_domain), - interpolation_domain); + // The following line creates a discrete domain over all dimensions (DDims...) where we immediately + // remove the dimensions DDimI1 and DDimI2. + ddc::remove_dims_of_t, DDimI1, DDimI2> const dom_vals_tmp( + ddc::DiscreteDomain( + ddc::DiscreteDomain(DElem(0), DVect(ncells))...)); + ddc::DiscreteDomain const dom_vals(dom_vals_tmp, interpolation_domain); // Create a SplineBuilder over BSplines and batched along other dimensions using some boundary conditions ddc::SplineBuilder2D< @@ -199,7 +194,7 @@ void ExtrapolationRuleSplineTest() s_bcl2, s_bcr2, ddc::SplineSolver::GINKGO, - DDim...> const spline_builder(dom_vals); + DDims...> const spline_builder(dom_vals); // Compute usefull domains (dom_interpolation, dom_batch, dom_bsplines and dom_spline) ddc::DiscreteDomain const dom_interpolation @@ -219,7 +214,7 @@ void ExtrapolationRuleSplineTest() ddc::parallel_for_each( exec_space, vals.domain(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { vals(e) = vals_1d(DElem(e)); }); @@ -275,7 +270,7 @@ void ExtrapolationRuleSplineTest() extrapolation_rule_dim_1_type, extrapolation_rule_dim_2_type, extrapolation_rule_dim_2_type, - DDim...> const + DDims...> const spline_evaluator_batched( extrapolation_rule_left_dim_1, extrapolation_rule_right_dim_1, @@ -292,7 +287,7 @@ void ExtrapolationRuleSplineTest() ddc::parallel_for_each( exec_space, coords_eval.domain(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { coords_eval(e) = ddc::coordinate(DElem(e)) + displ; }); @@ -310,7 +305,7 @@ void ExtrapolationRuleSplineTest() spline_eval.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { + KOKKOS_LAMBDA(DElem const e) { #if defined(ER_NULL) return Kokkos::abs(spline_eval(e)); #elif defined(ER_CONSTANT) @@ -321,7 +316,7 @@ void ExtrapolationRuleSplineTest() double tmp; if (Coord(coords_eval(e)) > xN()) { #if defined(BC_PERIODIC) - tmp = vals(ddc::DiscreteElement...>( + tmp = vals(ddc::DiscreteElement( vals.template domain().back(), e_without_interest)); #else @@ -329,13 +324,13 @@ void ExtrapolationRuleSplineTest() vals.domain(), vals.template domain()))::discrete_element_type const e_batch(e); - tmp = vals(ddc::DiscreteElement...>( + tmp = vals(ddc::DiscreteElement( vals.template domain().back(), vals.template domain().back(), e_batch)); #endif } else { - tmp = vals(ddc::DiscreteElement...>( + tmp = vals(ddc::DiscreteElement( vals.template domain().back(), e_without_interest)); } @@ -373,10 +368,10 @@ TEST(SUFFIX(ExtrapolationRuleSplineHost), 2DXY) ExtrapolationRuleSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DimX, - DimY, - DimX, - DimY>(); + DDimGPS1, + DDimGPS2, + DDimGPS1, + DDimGPS2>(); } TEST(SUFFIX(ExtrapolationRuleSplineDevice), 2DXY) @@ -384,8 +379,8 @@ TEST(SUFFIX(ExtrapolationRuleSplineDevice), 2DXY) ExtrapolationRuleSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DimX, - DimY, - DimX, - DimY>(); + DDimGPS1, + DDimGPS2, + DDimGPS1, + DDimGPS2>(); } From 0645888e195a8ecbfcb3665c16e710e429254a23 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Thu, 9 Jan 2025 21:05:34 +0100 Subject: [PATCH 3/7] Align the constructors of the different DiscreteDomain (#749) --- include/ddc/discrete_domain.hpp | 7 +++---- tests/splines/batched_2d_spline_builder.cpp | 8 +++----- tests/splines/batched_spline_builder.cpp | 8 +++----- tests/splines/extrapolation_rule.cpp | 8 +++----- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/include/ddc/discrete_domain.hpp b/include/ddc/discrete_domain.hpp index dafb17d8c..925e0edac 100644 --- a/include/ddc/discrete_domain.hpp +++ b/include/ddc/discrete_domain.hpp @@ -264,10 +264,9 @@ class DiscreteDomain<> KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteDomain() = default; - // Construct a DiscreteDomain from a reordered copy of `domain` - template - KOKKOS_FUNCTION constexpr explicit DiscreteDomain( - [[maybe_unused]] DiscreteDomain const& domain) + /// Construct a DiscreteDomain by copies and merge of domains + template && ...)>> + KOKKOS_FUNCTION constexpr explicit DiscreteDomain([[maybe_unused]] DDoms const&... domains) { } diff --git a/tests/splines/batched_2d_spline_builder.cpp b/tests/splines/batched_2d_spline_builder.cpp index 9d5e42e10..54c97225a 100644 --- a/tests/splines/batched_2d_spline_builder.cpp +++ b/tests/splines/batched_2d_spline_builder.cpp @@ -186,11 +186,9 @@ void Batched2dSplineTest() = GrevillePoints>::template get_domain(); ddc::DiscreteDomain const interpolation_domain2 = GrevillePoints>::template get_domain(); - // The following line creates a discrete domain over all dimensions (DDims...) where we immediately - // remove the dimensions DDimI1 and DDimI2. - ddc::remove_dims_of_t, DDimI1, DDimI2> const dom_vals_tmp( - ddc::DiscreteDomain( - ddc::DiscreteDomain(DElem(0), DVect(ncells))...)); + // The following line creates a discrete domain over all dimensions (DDims...) except DDimI1 and DDimI2. + auto const dom_vals_tmp = ddc::remove_dims_of_t, DDimI1, DDimI2>( + ddc::DiscreteDomain(DElem(0), DVect(ncells))...); ddc::DiscreteDomain const dom_vals(dom_vals_tmp, interpolation_domain1, interpolation_domain2); diff --git a/tests/splines/batched_spline_builder.cpp b/tests/splines/batched_spline_builder.cpp index 3165c00a7..f0d3b5a2a 100644 --- a/tests/splines/batched_spline_builder.cpp +++ b/tests/splines/batched_spline_builder.cpp @@ -183,11 +183,9 @@ void BatchedSplineTest() // Create the values domain (mesh) ddc::DiscreteDomain const interpolation_domain = GrevillePoints>::template get_domain(); - // The following line creates a discrete domain over all dimensions (DDims...) where we immediately - // remove the dimension DDimI. - ddc::remove_dims_of_t, DDimI> const dom_vals_tmp( - ddc::DiscreteDomain( - ddc::DiscreteDomain(DElem(0), DVect(ncells))...)); + // The following line creates a discrete domain over all dimensions (DDims...) except DDimI. + auto const dom_vals_tmp = ddc::remove_dims_of_t, DDimI>( + ddc::DiscreteDomain(DElem(0), DVect(ncells))...); ddc::DiscreteDomain const dom_vals(dom_vals_tmp, interpolation_domain); #if defined(BC_HERMITE) diff --git a/tests/splines/extrapolation_rule.cpp b/tests/splines/extrapolation_rule.cpp index a91eac67a..86d217664 100644 --- a/tests/splines/extrapolation_rule.cpp +++ b/tests/splines/extrapolation_rule.cpp @@ -174,11 +174,9 @@ void ExtrapolationRuleSplineTest() ddc::DiscreteDomain const interpolation_domain( GrevillePoints1>::template get_domain(), GrevillePoints2>::template get_domain()); - // The following line creates a discrete domain over all dimensions (DDims...) where we immediately - // remove the dimensions DDimI1 and DDimI2. - ddc::remove_dims_of_t, DDimI1, DDimI2> const dom_vals_tmp( - ddc::DiscreteDomain( - ddc::DiscreteDomain(DElem(0), DVect(ncells))...)); + // The following line creates a discrete domain over all dimensions (DDims...) except DDimI1 and DDimI2. + auto const dom_vals_tmp = ddc::remove_dims_of_t, DDimI1, DDimI2>( + ddc::DiscreteDomain(DElem(0), DVect(ncells))...); ddc::DiscreteDomain const dom_vals(dom_vals_tmp, interpolation_domain); // Create a SplineBuilder over BSplines and batched along other dimensions using some boundary conditions From 30cf15dd3214bc9ab5b6983064880727e6f8b792 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Thu, 9 Jan 2025 22:38:02 +0100 Subject: [PATCH 4/7] Remove unnecessary ctor call --- tests/splines/extrapolation_rule.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/splines/extrapolation_rule.cpp b/tests/splines/extrapolation_rule.cpp index 86d217664..f856e4b9f 100644 --- a/tests/splines/extrapolation_rule.cpp +++ b/tests/splines/extrapolation_rule.cpp @@ -314,23 +314,16 @@ void ExtrapolationRuleSplineTest() double tmp; if (Coord(coords_eval(e)) > xN()) { #if defined(BC_PERIODIC) - tmp = vals(ddc::DiscreteElement( - vals.template domain().back(), - e_without_interest)); + tmp = vals(vals.template domain().back(), e_without_interest); #else typename decltype(ddc::remove_dims_of( vals.domain(), vals.template domain()))::discrete_element_type const e_batch(e); - tmp = vals(ddc::DiscreteElement( - vals.template domain().back(), - vals.template domain().back(), - e_batch)); + tmp = vals(vals.template domain().back(), e_batch); #endif } else { - tmp = vals(ddc::DiscreteElement( - vals.template domain().back(), - e_without_interest)); + tmp = vals(vals.template domain().back(), e_without_interest); } return Kokkos::abs(spline_eval(e) - tmp); #endif From 4af47694e130ffad14fbabe94ad0b5f9bd134a44 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Fri, 10 Jan 2025 11:23:04 +0100 Subject: [PATCH 5/7] Rework to avoid if/else identical branches (#750) --- tests/splines/extrapolation_rule.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/splines/extrapolation_rule.cpp b/tests/splines/extrapolation_rule.cpp index f856e4b9f..cb64624fb 100644 --- a/tests/splines/extrapolation_rule.cpp +++ b/tests/splines/extrapolation_rule.cpp @@ -311,20 +311,20 @@ void ExtrapolationRuleSplineTest() vals.domain(), vals.template domain()))::discrete_element_type const e_without_interest(e); - double tmp; - if (Coord(coords_eval(e)) > xN()) { #if defined(BC_PERIODIC) - tmp = vals(vals.template domain().back(), e_without_interest); + double const tmp = vals(vals.template domain().back(), e_without_interest); #else + double tmp; + if (Coord(coords_eval(e)) > xN()) { typename decltype(ddc::remove_dims_of( vals.domain(), vals.template domain()))::discrete_element_type const e_batch(e); tmp = vals(vals.template domain().back(), e_batch); -#endif } else { tmp = vals(vals.template domain().back(), e_without_interest); } +#endif return Kokkos::abs(spline_eval(e) - tmp); #endif }); From f7ad494f23508d1cfd7e15c9441922ee3ceb78aa Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Fri, 10 Jan 2025 19:34:52 +0100 Subject: [PATCH 6/7] Support Ginkgo 1.8...<2 (#751) --- CMakeLists.txt | 2 +- README.md | 2 +- cmake/DDCConfig.cmake.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c506705d..8ac37d106 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,7 +192,7 @@ endif() if("${DDC_BUILD_KERNELS_SPLINES}") # Ginkgo - find_package(Ginkgo 1.8.0 EXACT REQUIRED) + find_package(Ginkgo 1.8...<2 REQUIRED) # Lapacke find_package(LAPACKE REQUIRED) diff --git a/README.md b/README.md index 0919a2b2f..76425fa39 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ To use DDC components, one needs the following dependencies: * (optional, IO interface) DDC::pdi * PDI 1.6...<2 * (optional, spline interpolation) DDC::splines - * Ginkgo 1.8.0 + * Ginkgo 1.8...<2 * Kokkos Kernels 4.5.1...<5 ## Getting the code and basic configuration diff --git a/cmake/DDCConfig.cmake.in b/cmake/DDCConfig.cmake.in index 811e34007..96237305c 100644 --- a/cmake/DDCConfig.cmake.in +++ b/cmake/DDCConfig.cmake.in @@ -24,7 +24,7 @@ if(@DDC_BUILD_KERNELS_FFT@) endif() if(@DDC_BUILD_KERNELS_SPLINES@) - ddc_find_dependency(Ginkgo 1.8.0 EXACT) + ddc_find_dependency(Ginkgo 1.8...<2) # DDC installs a FindLAPACKE.cmake file. # We choose to rely on it by prepending to CMAKE_MODULE_PATH # only the time of calling ddc_find_dependency. From 0e6a56c53ae791c142dd68eefe55a758ec131664 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Fri, 10 Jan 2025 19:45:04 +0100 Subject: [PATCH 7/7] Release version 0.4.0 --- CMakeLists.txt | 2 +- install_test/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ac37d106..3e785bab9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT cmake_minimum_required(VERSION 3.22) -project(DDC VERSION 0.3.0 LANGUAGES CXX) +project(DDC VERSION 0.4.0 LANGUAGES CXX) # List of options diff --git a/install_test/CMakeLists.txt b/install_test/CMakeLists.txt index 457683337..e1cef912c 100644 --- a/install_test/CMakeLists.txt +++ b/install_test/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.22) project(test-installed-ddc LANGUAGES CXX) -find_package(DDC 0.3 REQUIRED COMPONENTS fft pdi splines) +find_package(DDC 0.4 REQUIRED COMPONENTS fft pdi splines) message("DDC options:") message("DDC_BUILD_DOUBLE_PRECISION=${DDC_BUILD_DOUBLE_PRECISION}")