diff --git a/tests/splines/batched_2d_spline_builder.cpp b/tests/splines/batched_2d_spline_builder.cpp index 57ea0dedd..8d7bb3f27 100644 --- a/tests/splines/batched_2d_spline_builder.cpp +++ b/tests/splines/batched_2d_spline_builder.cpp @@ -4,6 +4,8 @@ #include #include + +#include "ddc/discrete_domain.hpp" #if defined(BC_HERMITE) #include #endif @@ -209,22 +211,26 @@ struct BatchDimsInitializerFn> template void Batched2dSplineTest() { + using DDim1 = DDim; + using DDim2 = DDim; + using DElemAll = DElem...>; + // Instantiate execution spaces and initialize spaces Kokkos::DefaultHostExecutionSpace const host_exec_space; ExecSpace const exec_space; std::size_t const ncells = 10; - InterestDimInitializer>(ncells); - InterestDimInitializer>(ncells); - BatchDimsInitializerFn, DDim, DDim...>> const + InterestDimInitializer(ncells); + InterestDimInitializer(ncells); + BatchDimsInitializerFn...>> const batch_dims_initializer; batch_dims_initializer(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...>( @@ -232,12 +238,11 @@ void Batched2dSplineTest() X, void, void>>(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); + ddc::DiscreteDomain...> const dom_vals = ddc::replace_dim_of< + DDim, + DDim1>( + ddc::replace_dim_of, DDim2>(dom_vals_tmp, interpolation_domain), + interpolation_domain); #if defined(BC_HERMITE) // Create the derivs domain @@ -248,12 +253,10 @@ void Batched2dSplineTest() ddc::DiscreteDomain, ddc::Deriv> const 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); + auto const dom_derivs_1d = 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 @@ -262,8 +265,8 @@ void Batched2dSplineTest() MemorySpace, BSplines, BSplines, - DDim, - DDim, + DDim1, + DDim2, s_bcl, s_bcr, s_bcl, @@ -272,16 +275,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::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_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(); @@ -291,9 +292,7 @@ void Batched2dSplineTest() ddc::parallel_for_each( exec_space, vals.domain(), - KOKKOS_LAMBDA(DElem...> const e) { - vals(e) = vals_1d(DElem, DDim>(e)); - }); + KOKKOS_LAMBDA(DElemAll 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. @@ -302,16 +301,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, DDim2>(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, DDim2> 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); }); @@ -324,7 +321,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, DDim2>(e)); }); } @@ -332,16 +329,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, DDim2>(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, DDim2> 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); }); @@ -354,7 +349,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, DDim2>(e)); }); } @@ -362,15 +357,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); }); @@ -383,7 +376,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)); }); } @@ -391,15 +384,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); }); @@ -412,7 +403,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)); }); } @@ -525,8 +516,8 @@ void Batched2dSplineTest() MemorySpace, BSplines, BSplines, - DDim, - DDim, + DDim1, + DDim2, extrapolation_rule_1_type, extrapolation_rule_1_type, extrapolation_rule_2_type, @@ -544,9 +535,7 @@ void Batched2dSplineTest() ddc::parallel_for_each( exec_space, coords_eval.domain(), - KOKKOS_LAMBDA(DElem...> const e) { - coords_eval(e) = ddc::coordinate(e); - }); + KOKKOS_LAMBDA(DElemAll const e) { coords_eval(e) = ddc::coordinate(e); }); // Instantiate chunks to receive outputs of spline_evaluator @@ -575,17 +564,15 @@ void Batched2dSplineTest() spline_eval.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { - return Kokkos::abs(spline_eval(e) - vals(e)); - }); + KOKKOS_LAMBDA(DElemAll const e) { return Kokkos::abs(spline_eval(e) - vals(e)); }); double const max_norm_error_diff1 = ddc::parallel_transform_reduce( exec_space, spline_eval_deriv1.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { - Coord const x = ddc::coordinate(DElem>(e)); - Coord const y = ddc::coordinate(DElem>(e)); + KOKKOS_LAMBDA(DElemAll 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( @@ -593,9 +580,9 @@ void Batched2dSplineTest() spline_eval_deriv2.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { - Coord const x = ddc::coordinate(DElem>(e)); - Coord const y = ddc::coordinate(DElem>(e)); + KOKKOS_LAMBDA(DElemAll 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( @@ -603,9 +590,9 @@ void Batched2dSplineTest() spline_eval_deriv1.domain(), 0., ddc::reducer::max(), - KOKKOS_LAMBDA(DElem...> const e) { - Coord const x = ddc::coordinate(DElem>(e)); - Coord const y = ddc::coordinate(DElem>(e)); + KOKKOS_LAMBDA(DElemAll 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)); }); @@ -615,7 +602,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>> error_bounds(evaluator); + SplineErrorBounds> 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 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);