From 9743d944ae1a8386f63654b04217d900ffad16ad Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Wed, 1 Jan 2025 11:42:43 +0100 Subject: [PATCH 1/2] Rename Index->DElem alias and rework some ifdef --- tests/splines/batched_2d_spline_builder.cpp | 84 +++++++++---------- tests/splines/batched_spline_builder.cpp | 37 ++++---- tests/splines/extrapolation_rule.cpp | 74 +++++++--------- tests/splines/non_periodic_spline_builder.cpp | 11 ++- tests/splines/periodic_spline_builder.cpp | 13 ++- ...periodic_spline_builder_ordered_points.cpp | 5 +- tests/splines/periodicity_spline_builder.cpp | 6 +- 7 files changed, 104 insertions(+), 126 deletions(-) diff --git a/tests/splines/batched_2d_spline_builder.cpp b/tests/splines/batched_2d_spline_builder.cpp index cba34e0ed..57ea0dedd 100644 --- a/tests/splines/batched_2d_spline_builder.cpp +++ b/tests/splines/batched_2d_spline_builder.cpp @@ -125,7 +125,7 @@ using evaluator_type = Evaluator2D::Evaluator< #endif template -using Index = ddc::DiscreteElement; +using DElem = ddc::DiscreteElement; template using DVect = ddc::DiscreteVector; template @@ -220,21 +220,18 @@ void Batched2dSplineTest() batch_dims_initializer(ncells); // Create the values domain (mesh) -#if defined(BC_HERMITE) ddc::DiscreteDomain> const interpolation_domain1 = GrevillePoints>::template get_domain>(); ddc::DiscreteDomain> const interpolation_domain2 = GrevillePoints>::template get_domain>(); -#endif - ddc::DiscreteDomain, DDim> const interpolation_domain( - GrevillePoints>::template get_domain>(), - GrevillePoints>::template get_domain>()); + ddc::DiscreteDomain, DDim> 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>(Index>(0), DVect>(ncells))...); + void>>(DElem>(0), DVect>(ncells))...); ddc::DiscreteDomain...> const dom_vals = ddc::replace_dim_of, DDim>( ddc::replace_dim_of< @@ -245,9 +242,9 @@ void Batched2dSplineTest() #if defined(BC_HERMITE) // Create the derivs domain ddc::DiscreteDomain> const - derivs_domain1(Index>(1), DVect>(s_degree / 2)); + derivs_domain1(DElem>(1), DVect>(s_degree / 2)); ddc::DiscreteDomain> const - derivs_domain2(Index>(1), DVect>(s_degree / 2)); + derivs_domain2(DElem>(1), DVect>(s_degree / 2)); ddc::DiscreteDomain, ddc::Deriv> const derivs_domain(derivs_domain1, derivs_domain2); @@ -294,8 +291,8 @@ void Batched2dSplineTest() ddc::parallel_for_each( exec_space, vals.domain(), - KOKKOS_LAMBDA(Index...> const e) { - vals(e) = vals_1d(Index, DDim>(e)); + KOKKOS_LAMBDA(DElem...> const e) { + vals(e) = vals_1d(DElem, DDim>(e)); }); #if defined(BC_HERMITE) @@ -327,7 +324,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(Index, DDim>(e)); + derivs_1d_lhs(e) = derivs_1d_lhs1(DElem, DDim>(e)); }); } @@ -357,7 +354,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(Index, DDim>(e)); + derivs_1d_rhs(e) = derivs_1d_rhs1(DElem, DDim>(e)); }); } @@ -386,7 +383,7 @@ void Batched2dSplineTest() derivs2_lhs.domain(), KOKKOS_LAMBDA( typename decltype(derivs2_lhs.domain())::discrete_element_type const e) { - derivs2_lhs(e) = derivs2_lhs1(Index, ddc::Deriv>(e)); + derivs2_lhs(e) = derivs2_lhs1(DElem, ddc::Deriv>(e)); }); } @@ -415,7 +412,7 @@ void Batched2dSplineTest() derivs2_rhs.domain(), KOKKOS_LAMBDA( typename decltype(derivs2_rhs.domain())::discrete_element_type const e) { - derivs2_rhs(e) = derivs2_rhs1(Index, ddc::Deriv>(e)); + derivs2_rhs(e) = derivs2_rhs1(DElem, ddc::Deriv>(e)); }); } @@ -480,13 +477,13 @@ void Batched2dSplineTest() dom_derivs, KOKKOS_LAMBDA(typename decltype(dom_derivs)::discrete_element_type const e) { derivs_mixed_lhs_lhs(e) - = derivs_mixed_lhs_lhs1(Index, ddc::Deriv>(e)); + = derivs_mixed_lhs_lhs1(DElem, ddc::Deriv>(e)); derivs_mixed_rhs_lhs(e) - = derivs_mixed_rhs_lhs1(Index, ddc::Deriv>(e)); + = derivs_mixed_rhs_lhs1(DElem, ddc::Deriv>(e)); derivs_mixed_lhs_rhs(e) - = derivs_mixed_lhs_rhs1(Index, ddc::Deriv>(e)); + = derivs_mixed_lhs_rhs1(DElem, ddc::Deriv>(e)); derivs_mixed_rhs_rhs(e) - = derivs_mixed_rhs_rhs1(Index, ddc::Deriv>(e)); + = derivs_mixed_rhs_rhs1(DElem, ddc::Deriv>(e)); }); } #endif @@ -511,14 +508,18 @@ void Batched2dSplineTest() #else spline_builder(coef, vals.span_cview()); #endif + // Instantiate a SplineEvaluator over interest dimension and batched along other dimensions #if defined(BC_PERIODIC) - ddc::PeriodicExtrapolationRule const extrapolation_rule_1; - ddc::PeriodicExtrapolationRule const extrapolation_rule_2; + using extrapolation_rule_1_type = ddc::PeriodicExtrapolationRule; + using extrapolation_rule_2_type = ddc::PeriodicExtrapolationRule; #else - ddc::NullExtrapolationRule const extrapolation_rule_1; - ddc::NullExtrapolationRule const extrapolation_rule_2; + using extrapolation_rule_1_type = ddc::NullExtrapolationRule; + using extrapolation_rule_2_type = ddc::NullExtrapolationRule; #endif + extrapolation_rule_1_type const extrapolation_rule_1; + extrapolation_rule_2_type const extrapolation_rule_2; + ddc::SplineEvaluator2D< ExecSpace, MemorySpace, @@ -526,17 +527,10 @@ void Batched2dSplineTest() BSplines, DDim, DDim, -#if defined(BC_PERIODIC) - ddc::PeriodicExtrapolationRule, - ddc::PeriodicExtrapolationRule, - ddc::PeriodicExtrapolationRule, - ddc::PeriodicExtrapolationRule, -#else - ddc::NullExtrapolationRule, - ddc::NullExtrapolationRule, - ddc::NullExtrapolationRule, - ddc::NullExtrapolationRule, -#endif + extrapolation_rule_1_type, + extrapolation_rule_1_type, + extrapolation_rule_2_type, + extrapolation_rule_2_type, DDim...> const spline_evaluator( extrapolation_rule_1, @@ -550,7 +544,7 @@ void Batched2dSplineTest() ddc::parallel_for_each( exec_space, coords_eval.domain(), - KOKKOS_LAMBDA(Index...> const e) { + KOKKOS_LAMBDA(DElem...> const e) { coords_eval(e) = ddc::coordinate(e); }); @@ -581,7 +575,7 @@ void Batched2dSplineTest() spline_eval.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(Index...> 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( @@ -589,9 +583,9 @@ void Batched2dSplineTest() spline_eval_deriv1.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(Index...> const e) { - Coord const x = ddc::coordinate(Index>(e)); - Coord const y = ddc::coordinate(Index>(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)); }); double const max_norm_error_diff2 = ddc::parallel_transform_reduce( @@ -599,9 +593,9 @@ void Batched2dSplineTest() spline_eval_deriv2.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(Index...> const e) { - Coord const x = ddc::coordinate(Index>(e)); - Coord const y = ddc::coordinate(Index>(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)); }); double const max_norm_error_diff12 = ddc::parallel_transform_reduce( @@ -609,9 +603,9 @@ void Batched2dSplineTest() spline_eval_deriv1.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(Index...> const e) { - Coord const x = ddc::coordinate(Index>(e)); - Coord const y = ddc::coordinate(Index>(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)); }); diff --git a/tests/splines/batched_spline_builder.cpp b/tests/splines/batched_spline_builder.cpp index b2cd5a98e..99190b8d4 100644 --- a/tests/splines/batched_spline_builder.cpp +++ b/tests/splines/batched_spline_builder.cpp @@ -120,7 +120,7 @@ template using evaluator_type = CosineEvaluator::Evaluator; template -using Index = ddc::DiscreteElement; +using DElem = ddc::DiscreteElement; template using DVect = ddc::DiscreteVector; template @@ -219,14 +219,14 @@ void BatchedSplineTest() // If we remove auto using the constructor syntax, nvcc does not compile auto const dom_vals_tmp = ddc::DiscreteDomain...>( ddc::DiscreteDomain< - DDim>(Index>(0), DVect>(ncells))...); + DDim>(DElem>(0), DVect>(ncells))...); ddc::DiscreteDomain...> const dom_vals = ddc::replace_dim_of, DDim>(dom_vals_tmp, interpolation_domain); #if defined(BC_HERMITE) // Create the derivs domain ddc::DiscreteDomain> const - derivs_domain(Index>(1), DVect>(s_degree_x / 2)); + derivs_domain(DElem>(1), DVect>(s_degree_x / 2)); auto const dom_derivs = ddc::replace_dim_of, ddc::Deriv>(dom_vals, derivs_domain); #endif @@ -265,8 +265,8 @@ void BatchedSplineTest() ddc::parallel_for_each( exec_space, vals.domain(), - KOKKOS_LAMBDA(Index...> const e) { - vals(e) = vals_1d(Index>(e)); + KOKKOS_LAMBDA(DElem...> const e) { + vals(e) = vals_1d(DElem>(e)); }); #if defined(BC_HERMITE) @@ -290,7 +290,7 @@ void BatchedSplineTest() derivs_lhs.domain(), KOKKOS_LAMBDA( typename decltype(derivs_lhs.domain())::discrete_element_type const e) { - derivs_lhs(e) = derivs_lhs1(Index>(e)); + derivs_lhs(e) = derivs_lhs1(DElem>(e)); }); } @@ -313,7 +313,7 @@ void BatchedSplineTest() derivs_rhs.domain(), KOKKOS_LAMBDA( typename decltype(derivs_rhs.domain())::discrete_element_type const e) { - derivs_rhs(e) = derivs_rhs1(Index>(e)); + derivs_rhs(e) = derivs_rhs1(DElem>(e)); }); } #endif @@ -335,22 +335,19 @@ void BatchedSplineTest() // Instantiate a SplineEvaluator over interest dimension and batched along other dimensions #if defined(BC_PERIODIC) - ddc::PeriodicExtrapolationRule const extrapolation_rule; + using extrapolation_rule_type = ddc::PeriodicExtrapolationRule; #else - ddc::NullExtrapolationRule const extrapolation_rule; + using extrapolation_rule_type = ddc::NullExtrapolationRule; #endif + extrapolation_rule_type const extrapolation_rule; + ddc::SplineEvaluator< ExecSpace, MemorySpace, BSplines, DDim, -#if defined(BC_PERIODIC) - ddc::PeriodicExtrapolationRule, - ddc::PeriodicExtrapolationRule, -#else - ddc::NullExtrapolationRule, - ddc::NullExtrapolationRule, -#endif + extrapolation_rule_type, + extrapolation_rule_type, DDim...> const spline_evaluator_batched(extrapolation_rule, extrapolation_rule); // Instantiate chunk of coordinates of dom_interpolation @@ -359,7 +356,7 @@ void BatchedSplineTest() ddc::parallel_for_each( exec_space, coords_eval.domain(), - KOKKOS_LAMBDA(Index...> const e) { coords_eval(e) = ddc::coordinate(e); }); + KOKKOS_LAMBDA(DElem...> const e) { coords_eval(e) = ddc::coordinate(e); }); // Instantiate chunks to receive outputs of spline_evaluator @@ -381,7 +378,7 @@ void BatchedSplineTest() spline_eval.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(Index...> const e) { + KOKKOS_LAMBDA(DElem...> const e) { return Kokkos::abs(spline_eval(e) - vals(e)); }); @@ -390,8 +387,8 @@ void BatchedSplineTest() spline_eval_deriv.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(Index...> const e) { - Coord const x = ddc::coordinate(Index>(e)); + KOKKOS_LAMBDA(DElem...> const 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( diff --git a/tests/splines/extrapolation_rule.cpp b/tests/splines/extrapolation_rule.cpp index 597cea9c2..6b0cd96eb 100644 --- a/tests/splines/extrapolation_rule.cpp +++ b/tests/splines/extrapolation_rule.cpp @@ -113,7 +113,7 @@ using evaluator_type = Evaluator2D::Evaluator< #endif template -using Index = ddc::DiscreteElement; +using DElem = ddc::DiscreteElement; template using DVect = ddc::DiscreteVector; template @@ -216,7 +216,7 @@ void ExtrapolationRuleSplineTest() ddc::DiscreteDomain>(Index>(0), DVect>(ncells))...); + void>>(DElem>(0), DVect>(ncells))...); ddc::DiscreteDomain...> const dom_vals = ddc::replace_dim_of, DDim>( ddc::replace_dim_of< @@ -259,8 +259,8 @@ void ExtrapolationRuleSplineTest() ddc::parallel_for_each( exec_space, vals.domain(), - KOKKOS_LAMBDA(Index...> const e) { - vals(e) = vals_1d(Index, DDim>(e)); + KOKKOS_LAMBDA(DElem...> const e) { + vals(e) = vals_1d(DElem, DDim>(e)); }); // Instantiate chunk of spline coefs to receive output of spline_builder @@ -272,32 +272,38 @@ void ExtrapolationRuleSplineTest() // Instantiate a SplineEvaluator over interest dimension and batched along other dimensions #if defined(ER_NULL) - ddc::NullExtrapolationRule const extrapolation_rule_left_dim_1; - ddc::NullExtrapolationRule const extrapolation_rule_right_dim_1; + using extrapolation_rule_dim_1_type = ddc::NullExtrapolationRule; + extrapolation_rule_dim_1_type const extrapolation_rule_left_dim_1; + extrapolation_rule_dim_1_type const extrapolation_rule_right_dim_1; #if defined(BC_PERIODIC) - ddc::PeriodicExtrapolationRule const extrapolation_rule_left_dim_2; - ddc::PeriodicExtrapolationRule const extrapolation_rule_right_dim_2; + using extrapolation_rule_dim_2_type = ddc::PeriodicExtrapolationRule; + extrapolation_rule_dim_2_type const extrapolation_rule_left_dim_2; + extrapolation_rule_dim_2_type const extrapolation_rule_right_dim_2; #else - ddc::NullExtrapolationRule const extrapolation_rule_left_dim_2; - ddc::NullExtrapolationRule const extrapolation_rule_right_dim_2; + using extrapolation_rule_dim_2_type = ddc::NullExtrapolationRule; + extrapolation_rule_dim_2_type const extrapolation_rule_left_dim_2; + extrapolation_rule_dim_2_type const extrapolation_rule_right_dim_2; #endif #elif defined(ER_CONSTANT) #if defined(BC_PERIODIC) - ddc::ConstantExtrapolationRule const extrapolation_rule_left_dim_1(x0()); - ddc::ConstantExtrapolationRule const extrapolation_rule_right_dim_1(xN()); - ddc::PeriodicExtrapolationRule const extrapolation_rule_left_dim_2; - ddc::PeriodicExtrapolationRule const extrapolation_rule_right_dim_2; + using extrapolation_rule_dim_1_type = ddc::ConstantExtrapolationRule; + using extrapolation_rule_dim_2_type = ddc::PeriodicExtrapolationRule; + extrapolation_rule_dim_1_type const extrapolation_rule_left_dim_1(x0()); + extrapolation_rule_dim_1_type const extrapolation_rule_right_dim_1(xN()); + extrapolation_rule_dim_2_type const extrapolation_rule_left_dim_2; + extrapolation_rule_dim_2_type const extrapolation_rule_right_dim_2; #else - ddc::ConstantExtrapolationRule const - extrapolation_rule_left_dim_1(x0(), x0(), xN()); - ddc::ConstantExtrapolationRule const + using extrapolation_rule_dim_1_type = ddc::ConstantExtrapolationRule; + using extrapolation_rule_dim_2_type = ddc::ConstantExtrapolationRule; + extrapolation_rule_dim_1_type const extrapolation_rule_left_dim_1(x0(), x0(), xN()); + extrapolation_rule_dim_1_type const extrapolation_rule_right_dim_1(xN(), x0(), xN()); - ddc::ConstantExtrapolationRule const - extrapolation_rule_left_dim_2(x0(), x0(), xN()); - ddc::ConstantExtrapolationRule const + extrapolation_rule_dim_2_type const extrapolation_rule_left_dim_2(x0(), x0(), xN()); + extrapolation_rule_dim_2_type const extrapolation_rule_right_dim_2(xN(), x0(), xN()); #endif #endif + ddc::SplineEvaluator2D< ExecSpace, MemorySpace, @@ -305,26 +311,10 @@ void ExtrapolationRuleSplineTest() BSplines, DDim, DDim, -#if defined(ER_NULL) - ddc::NullExtrapolationRule, - ddc::NullExtrapolationRule, -#elif defined(ER_CONSTANT) - ddc::ConstantExtrapolationRule, - ddc::ConstantExtrapolationRule, -#endif -#if defined(BC_PERIODIC) - ddc::PeriodicExtrapolationRule, - ddc::PeriodicExtrapolationRule, -#else -#if defined(ER_NULL) - ddc::NullExtrapolationRule, - ddc::NullExtrapolationRule, -#elif defined(ER_CONSTANT) - ddc::ConstantExtrapolationRule, - ddc::ConstantExtrapolationRule, -#endif -#endif - + extrapolation_rule_dim_1_type, + extrapolation_rule_dim_1_type, + extrapolation_rule_dim_2_type, + extrapolation_rule_dim_2_type, DDim...> const spline_evaluator_batched( extrapolation_rule_left_dim_1, @@ -338,7 +328,7 @@ void ExtrapolationRuleSplineTest() ddc::parallel_for_each( exec_space, coords_eval.domain(), - KOKKOS_LAMBDA(Index...> const e) { + KOKKOS_LAMBDA(DElem...> const e) { coords_eval(e) = ddc::coordinate(e); // Set coords_eval outside of the domain (+1 to ensure left bound is outside domain) ddc::get(coords_eval(e)) @@ -363,7 +353,7 @@ void ExtrapolationRuleSplineTest() spline_eval.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(Index...> const e) { + KOKKOS_LAMBDA(DElem...> const e) { #if defined(ER_NULL) return Kokkos::abs(spline_eval(e)); #elif defined(ER_CONSTANT) diff --git a/tests/splines/non_periodic_spline_builder.cpp b/tests/splines/non_periodic_spline_builder.cpp index bce20b20f..b324dcffc 100644 --- a/tests/splines/non_periodic_spline_builder.cpp +++ b/tests/splines/non_periodic_spline_builder.cpp @@ -66,9 +66,8 @@ using evaluator_type = CosineEvaluator::Evaluator; using evaluator_type = PolynomialEvaluator::Evaluator; #endif -using IndexX = ddc::DiscreteElement; +using DElemX = ddc::DiscreteElement; using DVectX = ddc::DiscreteVector; -using BsplIndexX = ddc::DiscreteElement; using SplineX = ddc::Chunk>; using FieldX = ddc::Chunk>; using CoordX = ddc::Coordinate; @@ -130,7 +129,7 @@ void TestNonPeriodicSplineBuilderTestIdentity() ddc::parallel_for_each( execution_space(), yvals.domain(), - KOKKOS_LAMBDA(IndexX const ix) { yvals(ix) = evaluator(ddc::coordinate(ix)); }); + KOKKOS_LAMBDA(DElemX const ix) { yvals(ix) = evaluator(ddc::coordinate(ix)); }); int const shift = s_degree_x % 2; // shift = 0 for even order, 1 for odd order ddc::Chunk derivs_lhs_alloc(derivs_domain, ddc::KokkosAllocator()); @@ -187,7 +186,7 @@ void TestNonPeriodicSplineBuilderTestIdentity() ddc::parallel_for_each( execution_space(), interpolation_domain, - KOKKOS_LAMBDA(IndexX const ix) { coords_eval(ix) = ddc::coordinate(ix); }); + KOKKOS_LAMBDA(DElemX const ix) { coords_eval(ix) = ddc::coordinate(ix); }); ddc::Chunk spline_eval_alloc(interpolation_domain, ddc::KokkosAllocator()); @@ -269,7 +268,7 @@ void TestNonPeriodicSplineBuilderTestIdentity() interpolation_domain, 0.0, ddc::reducer::max(), - KOKKOS_LAMBDA(IndexX const ix) { + KOKKOS_LAMBDA(DElemX const ix) { double const error = spline_eval(ix) - yvals(ix); return Kokkos::fabs(error); }); @@ -278,7 +277,7 @@ void TestNonPeriodicSplineBuilderTestIdentity() interpolation_domain, 0.0, ddc::reducer::max(), - KOKKOS_LAMBDA(IndexX const ix) { + KOKKOS_LAMBDA(DElemX const ix) { CoordX const x = ddc::coordinate(ix); double const error_deriv = spline_eval_deriv(ix) - evaluator.deriv(x, 1); return Kokkos::fabs(error_deriv); diff --git a/tests/splines/periodic_spline_builder.cpp b/tests/splines/periodic_spline_builder.cpp index 7552f4ad2..7da6dc92c 100644 --- a/tests/splines/periodic_spline_builder.cpp +++ b/tests/splines/periodic_spline_builder.cpp @@ -46,9 +46,8 @@ struct DDimX : GrevillePoints::interpolation_discrete_dimension_type using evaluator_type = CosineEvaluator::Evaluator; -using IndexX = ddc::DiscreteElement; +using DElemX = ddc::DiscreteElement; using DVectX = ddc::DiscreteVector; -using BsplIndexX = ddc::DiscreteElement; using CoordX = ddc::Coordinate; // Checks that when evaluating the spline at interpolation points one @@ -105,7 +104,7 @@ void TestPeriodicSplineBuilderTestIdentity() ddc::parallel_for_each( execution_space(), yvals.domain(), - KOKKOS_LAMBDA(IndexX const ix) { yvals(ix) = evaluator(ddc::coordinate(ix)); }); + KOKKOS_LAMBDA(DElemX const ix) { yvals(ix) = evaluator(ddc::coordinate(ix)); }); // 6. Finally build the spline by filling `coef` spline_builder(coef.span_view(), yvals.span_cview()); @@ -127,7 +126,7 @@ void TestPeriodicSplineBuilderTestIdentity() ddc::parallel_for_each( execution_space(), interpolation_domain, - KOKKOS_LAMBDA(IndexX const ix) { coords_eval(ix) = ddc::coordinate(ix); }); + KOKKOS_LAMBDA(DElemX const ix) { coords_eval(ix) = ddc::coordinate(ix); }); ddc::Chunk spline_eval_alloc(interpolation_domain, ddc::KokkosAllocator()); @@ -155,7 +154,7 @@ void TestPeriodicSplineBuilderTestIdentity() quadrature_coefficients.domain(), 0.0, ddc::reducer::sum(), - KOKKOS_LAMBDA(IndexX const ix) { return quadrature_coefficients(ix) * yvals(ix); }); + KOKKOS_LAMBDA(DElemX const ix) { return quadrature_coefficients(ix) * yvals(ix); }); // 8. Checking errors double const max_norm_error = ddc::parallel_transform_reduce( @@ -163,7 +162,7 @@ void TestPeriodicSplineBuilderTestIdentity() interpolation_domain, 0.0, ddc::reducer::max(), - KOKKOS_LAMBDA(IndexX const ix) { + KOKKOS_LAMBDA(DElemX const ix) { double const error = spline_eval(ix) - yvals(ix); return Kokkos::fabs(error); }); @@ -172,7 +171,7 @@ void TestPeriodicSplineBuilderTestIdentity() interpolation_domain, 0.0, ddc::reducer::max(), - KOKKOS_LAMBDA(IndexX const ix) { + KOKKOS_LAMBDA(DElemX const ix) { CoordX const x = ddc::coordinate(ix); double const error_deriv = spline_eval_deriv(ix) - evaluator.deriv(x, 1); return Kokkos::fabs(error_deriv); diff --git a/tests/splines/periodic_spline_builder_ordered_points.cpp b/tests/splines/periodic_spline_builder_ordered_points.cpp index d7be8c751..cb2a02312 100644 --- a/tests/splines/periodic_spline_builder_ordered_points.cpp +++ b/tests/splines/periodic_spline_builder_ordered_points.cpp @@ -28,9 +28,8 @@ struct DDimX : GrevillePoints::interpolation_discrete_dimension_type { }; -using IndexX = ddc::DiscreteElement; +using DElemX = ddc::DiscreteElement; using DVectX = ddc::DiscreteVector; -using BsplIndexX = ddc::DiscreteElement; using SplineX = ddc::Chunk>; using FieldX = ddc::Chunk>; using CoordX = ddc::Coordinate; @@ -54,7 +53,7 @@ TEST(PeriodicSplineBuilderOrderTest, OrderedPoints) double last(ddc::coordinate(interpolation_domain.front())); double current; - for (IndexX const ix : interpolation_domain) { + for (DElemX const ix : interpolation_domain) { current = ddc::coordinate(ix); EXPECT_LE(current, ddc::discrete_space().rmax()); EXPECT_GE(current, ddc::discrete_space().rmin()); diff --git a/tests/splines/periodicity_spline_builder.cpp b/tests/splines/periodicity_spline_builder.cpp index fe4afd448..c5330362c 100644 --- a/tests/splines/periodicity_spline_builder.cpp +++ b/tests/splines/periodicity_spline_builder.cpp @@ -57,7 +57,7 @@ template using evaluator_type = CosineEvaluator::Evaluator; template -using Index = ddc::DiscreteElement; +using DElem = ddc::DiscreteElement; template using DVect = ddc::DiscreteVector; template @@ -172,7 +172,7 @@ void PeriodicitySplineBuilderTest() ddc::parallel_for_each( exec_space, coords_eval.domain(), - KOKKOS_LAMBDA(Index> const e) { + KOKKOS_LAMBDA(DElem> const e) { coords_eval(e) = ddc::coordinate(e) + Coord(1.5); }); // Translate function 1.5x domain width to the right. @@ -190,7 +190,7 @@ void PeriodicitySplineBuilderTest() spline_eval.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(Index> const e) { + KOKKOS_LAMBDA(DElem> const e) { return Kokkos::abs( spline_eval(e) - (-vals(e))); // Because function is even, we get f_eval = -f From e7d8c71bec118113cf3214f6d3be6695bb118797 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Wed, 1 Jan 2025 12:24:47 +0100 Subject: [PATCH 2/2] Simplify the allocator --- tests/splines/batched_2d_spline_builder.cpp | 4 +--- tests/splines/batched_spline_builder.cpp | 4 +--- tests/splines/extrapolation_rule.cpp | 4 +--- tests/splines/periodicity_spline_builder.cpp | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/splines/batched_2d_spline_builder.cpp b/tests/splines/batched_2d_spline_builder.cpp index 57ea0dedd..330a1f5ca 100644 --- a/tests/splines/batched_2d_spline_builder.cpp +++ b/tests/splines/batched_2d_spline_builder.cpp @@ -277,9 +277,7 @@ void Batched2dSplineTest() 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::KokkosAllocator()); + 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(vals_1d_host); diff --git a/tests/splines/batched_spline_builder.cpp b/tests/splines/batched_spline_builder.cpp index 99190b8d4..9097c84d7 100644 --- a/tests/splines/batched_spline_builder.cpp +++ b/tests/splines/batched_spline_builder.cpp @@ -251,9 +251,7 @@ void BatchedSplineTest() 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::KokkosAllocator()); + 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(vals_1d_host); diff --git a/tests/splines/extrapolation_rule.cpp b/tests/splines/extrapolation_rule.cpp index 6b0cd96eb..598a50c87 100644 --- a/tests/splines/extrapolation_rule.cpp +++ b/tests/splines/extrapolation_rule.cpp @@ -245,9 +245,7 @@ void ExtrapolationRuleSplineTest() 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::KokkosAllocator()); + 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(vals_1d_host); diff --git a/tests/splines/periodicity_spline_builder.cpp b/tests/splines/periodicity_spline_builder.cpp index c5330362c..7cf9b9bc7 100644 --- a/tests/splines/periodicity_spline_builder.cpp +++ b/tests/splines/periodicity_spline_builder.cpp @@ -139,9 +139,7 @@ void PeriodicitySplineBuilderTest() ddc::DiscreteDomain> const dom_bsplines = 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 - ddc::Chunk vals_host_alloc( - dom_vals, - ddc::KokkosAllocator()); + ddc::Chunk vals_host_alloc(dom_vals, ddc::HostAllocator()); ddc::ChunkSpan const vals_host = vals_host_alloc.span_view(); evaluator_type> const evaluator(dom_vals); evaluator(vals_host);