From 8c90777c4ac3ee28c62cd0e5eee2ddb5dbf6d662 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Fri, 29 Mar 2024 09:11:29 +0000 Subject: [PATCH] Remove unbatched advection and interpolator Unbatched interpolator and advections are removed because unused: - BslAdvectionVelocity - BslAdvectionSpatial - LagrangeInterpolator - SplineInterpolator - IInterpolator See merge request gysela-developpers/gyselalibxx!403 -------------------------------------------- --- .../bump_on_tail/bumpontail_fem_uniform.cpp | 1 - .../bump_on_tail/bumpontail_fft.cpp | 1 - .../geometryXVx/landau/landau_fem_uniform.cpp | 1 - simulations/geometryXVx/landau/landau_fft.cpp | 1 - simulations/geometryXVx/sheath/sheath.cpp | 1 - src/advection/bsl_advection_vx.hpp | 109 ------------------ src/advection/bsl_advection_x.hpp | 103 ----------------- src/interpolation/Lagrange_interpolator.hpp | 103 ----------------- src/interpolation/iinterpolator.hpp | 98 ---------------- src/interpolation/spline_interpolator.hpp | 108 ----------------- tests/geometryXVx/lagrange_test.cpp | 34 +++--- 11 files changed, 21 insertions(+), 539 deletions(-) delete mode 100644 src/advection/bsl_advection_vx.hpp delete mode 100644 src/advection/bsl_advection_x.hpp delete mode 100644 src/interpolation/Lagrange_interpolator.hpp delete mode 100644 src/interpolation/iinterpolator.hpp delete mode 100644 src/interpolation/spline_interpolator.hpp diff --git a/simulations/geometryXVx/bump_on_tail/bumpontail_fem_uniform.cpp b/simulations/geometryXVx/bump_on_tail/bumpontail_fem_uniform.cpp index eeeb726db..bddb6e42c 100644 --- a/simulations/geometryXVx/bump_on_tail/bumpontail_fem_uniform.cpp +++ b/simulations/geometryXVx/bump_on_tail/bumpontail_fem_uniform.cpp @@ -32,7 +32,6 @@ #include "restartinitialization.hpp" #include "singlemodeperturbinitialization.hpp" #include "species_info.hpp" -#include "spline_interpolator.hpp" #include "spline_interpolator_batched.hpp" #include "splitvlasovsolver.hpp" diff --git a/simulations/geometryXVx/bump_on_tail/bumpontail_fft.cpp b/simulations/geometryXVx/bump_on_tail/bumpontail_fft.cpp index a1abccdca..b8ed41cd6 100644 --- a/simulations/geometryXVx/bump_on_tail/bumpontail_fft.cpp +++ b/simulations/geometryXVx/bump_on_tail/bumpontail_fft.cpp @@ -28,7 +28,6 @@ #include "restartinitialization.hpp" #include "singlemodeperturbinitialization.hpp" #include "species_info.hpp" -#include "spline_interpolator.hpp" #include "spline_interpolator_batched.hpp" #include "splitvlasovsolver.hpp" diff --git a/simulations/geometryXVx/landau/landau_fem_uniform.cpp b/simulations/geometryXVx/landau/landau_fem_uniform.cpp index e6f8675da..653a313be 100644 --- a/simulations/geometryXVx/landau/landau_fem_uniform.cpp +++ b/simulations/geometryXVx/landau/landau_fem_uniform.cpp @@ -31,7 +31,6 @@ #include "restartinitialization.hpp" #include "singlemodeperturbinitialization.hpp" #include "species_info.hpp" -#include "spline_interpolator.hpp" #include "spline_interpolator_batched.hpp" #include "splitvlasovsolver.hpp" diff --git a/simulations/geometryXVx/landau/landau_fft.cpp b/simulations/geometryXVx/landau/landau_fft.cpp index 8161e7ee7..e4b07a090 100644 --- a/simulations/geometryXVx/landau/landau_fft.cpp +++ b/simulations/geometryXVx/landau/landau_fft.cpp @@ -28,7 +28,6 @@ #include "restartinitialization.hpp" #include "singlemodeperturbinitialization.hpp" #include "species_info.hpp" -#include "spline_interpolator.hpp" #include "spline_interpolator_batched.hpp" #include "splitvlasovsolver.hpp" diff --git a/simulations/geometryXVx/sheath/sheath.cpp b/simulations/geometryXVx/sheath/sheath.cpp index 83f6ef8ca..52bc98002 100644 --- a/simulations/geometryXVx/sheath/sheath.cpp +++ b/simulations/geometryXVx/sheath/sheath.cpp @@ -43,7 +43,6 @@ #include "sheath.yaml.hpp" #include "singlemodeperturbinitialization.hpp" #include "species_info.hpp" -#include "spline_interpolator.hpp" #include "spline_interpolator_batched.hpp" #include "splitrighthandsidesolver.hpp" #include "splitvlasovsolver.hpp" diff --git a/src/advection/bsl_advection_vx.hpp b/src/advection/bsl_advection_vx.hpp deleted file mode 100644 index 9cdbf5702..000000000 --- a/src/advection/bsl_advection_vx.hpp +++ /dev/null @@ -1,109 +0,0 @@ -// SPDX-License-Identifier: MIT - -#pragma once - -#include - -#include -#include -#include - -#include "iadvectionvx.hpp" - -/** - * @brief A class which computes the velocity advection along the dimension of interest DDimV. - */ -template -class BslAdvectionVelocity : public IAdvectionVelocity -{ - using DDimSp = typename Geometry::DDimSp; - using FdistribuDDom = typename Geometry::FdistribuDDom; - using SpatialDDom = typename Geometry::SpatialDDom; - using DElemV = ddc::DiscreteElement; - using DElemSp = ddc::DiscreteElement; - using CDimV = typename DDimV::continuous_dimension_type; - -private: - IPreallocatableInterpolator const& m_interpolator_v; - -public: - /** - * @brief Constructor - * @param[in] interpolator_v interpolator along the DDimV direction which refers to the velocity space. - */ - explicit BslAdvectionVelocity(IPreallocatableInterpolator const& interpolator_v) - : m_interpolator_v(interpolator_v) - { - } - - ~BslAdvectionVelocity() override = default; - - /** - * @brief Advects fdistribu along DDimV for a duration dt. - * @param[in, out] allfdistribu Reference to the whole distribution function for one species, allocated on the device (ie it lets the choice of the location depend on the build configuration). - * @param[in] electric_field Reference to the electric field which derives from electrostatic potential, allocated on the device. - * @param[in] dt Time step - * @return A reference to the allfdistribu array containing the value of the function at the coordinates. - */ - device_t> operator()( - device_t> const allfdistribu, - device_t> const electric_field, - double const dt) const override - { - Kokkos::Profiling::pushRegion("BslAdvectionVelocity"); - - auto allfdistribu_host_alloc = ddc::create_mirror_view_and_copy(allfdistribu); - ddc::ChunkSpan allfdistribu_host = allfdistribu_host_alloc.span_view(); - auto electric_field_host_alloc = ddc::create_mirror_view_and_copy(electric_field); - ddc::ChunkSpan electric_field_host = electric_field_host_alloc.span_view(); - - FdistribuDDom const dom = allfdistribu.domain(); - ddc::DiscreteDomain const v_dom = ddc::select(dom); - ddc::DiscreteDomain const sp_dom = ddc::select(dom); - - // pre-allocate some memory to prevent allocation later in loop - ddc::Chunk, ddc::DiscreteDomain> feet_coords(v_dom); - ddc::Chunk> contiguous_slice(v_dom); - std::unique_ptr> const interpolator_v_ptr - = m_interpolator_v.preallocate(); - IInterpolator const& interpolator_v = *interpolator_v_ptr; - - SpatialDDom const spatial_dom(allfdistribu.domain()); - - auto c_dom = ddc::remove_dims_of( - ddc::remove_dims_of(ddc::remove_dims_of(dom, sp_dom), spatial_dom), - v_dom); - using DElemC = typename decltype(c_dom)::discrete_element_type; - using DElemSpatial = typename SpatialDDom::discrete_element_type; - - ddc::for_each(c_dom, [&](DElemC const ic) { - ddc::for_each(sp_dom, [&](DElemSp const isp) { - double const sqrt_me_on_mspecies = std::sqrt(mass(ielec()) / mass(isp)); - - ddc::for_each(spatial_dom, [&](DElemSpatial const ix) { - // compute the displacement - double const dvx - = charge(isp) * sqrt_me_on_mspecies * dt * electric_field_host(ix); - - // compute the coordinates of the feet - ddc::for_each(v_dom, [&](DElemV const iv) { - feet_coords(iv) = ddc::Coordinate(ddc::coordinate(iv) - dvx); - }); - - // copy the slice in contiguous memory - ddc::parallel_deepcopy(contiguous_slice, allfdistribu_host[ic][isp][ix]); - - // build a spline representation of the data - interpolator_v(contiguous_slice, feet_coords.span_cview()); - - // copy back - ddc::parallel_deepcopy(allfdistribu_host[ic][isp][ix], contiguous_slice); - }); - }); - }); - - ddc::parallel_deepcopy(allfdistribu, allfdistribu_host); - Kokkos::Profiling::popRegion(); - return allfdistribu; - } -}; diff --git a/src/advection/bsl_advection_x.hpp b/src/advection/bsl_advection_x.hpp deleted file mode 100644 index 0b341d007..000000000 --- a/src/advection/bsl_advection_x.hpp +++ /dev/null @@ -1,103 +0,0 @@ -// SPDX-License-Identifier: MIT - -#pragma once - -#include - -#include -#include -#include - -#include "iadvectionx.hpp" - -/** - * @brief A class which computes the spatial advection along the dimension of interest DDimX. - */ -template -class BslAdvectionSpatial : public IAdvectionSpatial -{ - using DDimSp = typename Geometry::DDimSp; - using DDimV = typename Geometry::template velocity_dim_for; - using DDom = typename Geometry::FdistribuDDom; - using DElemX = ddc::DiscreteElement; - using DElemV = ddc::DiscreteElement; - using DElemSp = ddc::DiscreteElement; - using DElemSpV = ddc::DiscreteElement; - using CDimX = typename DDimX::continuous_dimension_type; - -private: - IPreallocatableInterpolator const& m_interpolator_x; - -public: - /** - * @brief Constructor - * @param[in] interpolator_x interpolator along the DDimX direction which refers to the spatial space. - */ - BslAdvectionSpatial(IPreallocatableInterpolator const& interpolator_x) - : m_interpolator_x(interpolator_x) - { - } - - ~BslAdvectionSpatial() override = default; - - /** - * @brief Advects fdistribu along DDimX for a duration dt. - * @param[in, out] allfdistribu Reference to the whole distribution function for one species, allocated on the device (ie it lets the choice of the location depend on the build configuration). - * @param[in] dt time step - * @return A reference to the allfdistribu array containing the value of the function at the coordinates. - */ - device_t> operator()( - device_t> const allfdistribu, - double const dt) const override - { - Kokkos::Profiling::pushRegion("BslAdvectionSpatial"); - auto allfdistribu_host_alloc = ddc::create_mirror_view_and_copy(allfdistribu); - ddc::ChunkSpan allfdistribu_host = allfdistribu_host_alloc.span_view(); - - DDom const dom = allfdistribu.domain(); - ddc::DiscreteDomain const x_dom = ddc::select(dom); - ddc::DiscreteDomain const v_dom = ddc::select(dom); - ddc::DiscreteDomain const sp_dom = ddc::select(dom); - - // pre-allocate some memory to prevent allocation later in loop - ddc::Chunk, ddc::DiscreteDomain> feet_coords(x_dom); - ddc::Chunk> contiguous_slice(x_dom); - std::unique_ptr> const interpolator_x_ptr - = m_interpolator_x.preallocate(); - IInterpolator const& interpolator_x = *interpolator_x_ptr; - - auto c_dom = ddc::remove_dims_of( - dom, - ddc::DiscreteDomain(sp_dom, x_dom, v_dom)); - using DElemC = typename decltype(c_dom)::discrete_element_type; - - ddc::for_each(c_dom, [&](DElemC const ic) { - ddc::for_each(sp_dom, [&](DElemSp const isp) { - double const sqrt_me_on_mspecies = std::sqrt(mass(ielec()) / mass(isp)); - - ddc::for_each(v_dom, [&](DElemV const iv) { - // compute the displacement - double const dx = sqrt_me_on_mspecies * dt * ddc::coordinate(iv); - - // compute the coordinates of the feet - ddc::for_each(x_dom, [&](DElemX const ix) { - feet_coords(ix) = ddc::Coordinate(ddc::coordinate(ix) - dx); - }); - - // copy the slice in contiguous memory - ddc::parallel_deepcopy(contiguous_slice, allfdistribu_host[ic][isp][iv]); - - // interpolate the function at the feet using the provided interpolator - interpolator_x(contiguous_slice, feet_coords.span_cview()); - - // copy back - ddc::parallel_deepcopy(allfdistribu_host[ic][isp][iv], contiguous_slice); - }); - }); - }); - - ddc::parallel_deepcopy(allfdistribu, allfdistribu_host); - Kokkos::Profiling::popRegion(); - return allfdistribu; - } -}; diff --git a/src/interpolation/Lagrange_interpolator.hpp b/src/interpolation/Lagrange_interpolator.hpp deleted file mode 100644 index 6ce4a58b2..000000000 --- a/src/interpolation/Lagrange_interpolator.hpp +++ /dev/null @@ -1,103 +0,0 @@ -// SPDX-License-Identifier: MIT -#pragma once -#include - -#include "Lagrange.hpp" -#include "iinterpolator.hpp" - -/** - * @brief A class for interpolating a function using Lagrange polynomials. - * It is designed to work with both uniform and non-uniform mesh, and have the advantage to be local. - * - */ -template -class LagrangeInterpolator : public IInterpolator -{ - using CDim = typename DDim::continuous_dimension_type; - -private: - int m_degree; - ddc::DiscreteDomain m_domain; - ddc::DiscreteVector m_ghost; - -public: - /** - * @brief Create a Lagrange interpolator object. - * @param[in] degree Degree of polynomials - * @param[in] domain Discrete domain related to direction of interest for computations - * @param[in] ghost Discrete vector which gives the number of ghost points. By default choose 2. - */ - LagrangeInterpolator( - int degree, - ddc::DiscreteDomain domain, - ddc::DiscreteVector ghost) - : m_degree(degree) - , m_domain(domain) - , m_ghost(ghost) - { - } - - ~LagrangeInterpolator() override = default; - - /** - * @brief Approximate the value of a function at a set of coordinates using the - * current values at a known set of interpolation points. - * - * @param[in, out] inout_data On input: an array containing the value of the function at the interpolation points. - * On output: an array containing the value of the function at the coordinates. - * @param[in] coordinates The coordinates where the function should be evaluated. - * - * @return A reference to the inout_data array containing the value of the function at the coordinates. - */ - ddc::ChunkSpan> operator()( - ddc::ChunkSpan> const inout_data, - ddc::ChunkSpan, ddc::DiscreteDomain> const - coordinates) const override - { - Lagrange - evaluator(m_degree, inout_data, m_domain, m_ghost); - - ddc::for_each( - coordinates.domain(), - KOKKOS_LAMBDA(ddc::DiscreteElement const ix) { - inout_data(ix) = evaluator.evaluate(coordinates(ix)); - }); - - return inout_data; - } -}; - -/** - * @brief A class which stores information necessary to create an instance of the LagrangeInterpolator class. - * - * This class allows an instance of the LagrangeInterpolator class where necessary. This allows the - * memory allocated in the private members of the Interpolator to be freed when the object is not in use. - */ -template -class PreallocatableLagrangeInterpolator : public IPreallocatableInterpolator -{ - LagrangeInterpolator const& evaluator; - -public: - /** - * @brief Create an object capable of creating LagrangeInterpolator objects. - * @param[in] evaluator An operator which evaluates the value of the interpolation polynomial at requested coordinates. - */ - explicit PreallocatableLagrangeInterpolator( - LagrangeInterpolator const& evaluator) - : evaluator(evaluator) - { - } - - ~PreallocatableLagrangeInterpolator() override = default; - - /** - * Create an instance of the LagrangeInterpolator class. - * - * @return A unique pointer to an instance of the LagrangeInterpolator class. - */ - std::unique_ptr> preallocate() const override - { - return std::make_unique>(evaluator); - } -}; diff --git a/src/interpolation/iinterpolator.hpp b/src/interpolation/iinterpolator.hpp deleted file mode 100644 index 93df4f70d..000000000 --- a/src/interpolation/iinterpolator.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// SPDX-License-Identifier: MIT - -#pragma once - -#include - -#include - -/** - * @brief A class which provides an interpolating function. - * - * An abstract class which implements a function allowing - * the value of a function to be approximated at a set of - * coordinates from a set of known values of the function. - */ -template -class IInterpolator -{ - using CDim = typename DDim::continuous_dimension_type; - -public: - virtual ~IInterpolator() = default; - - /** - * @brief Approximate the value of a function at a set of coordinates using the - * current values at a known set of interpolation points. - * - * @param[in, out] inout_data On input: an array containing the value of the function at the interpolation points. - * On output: an array containing the value of the function at the coordinates. - * @param[in] coordinates The coordinates where the function should be evaluated. - * - * @return A reference to the inout_data array containing the value of the function at the coordinates. - */ - virtual ddc::ChunkSpan> operator()( - ddc::ChunkSpan> inout_data, - ddc::ChunkSpan, ddc::DiscreteDomain> coordinates) - const = 0; -}; - -/** - * @brief A class which provides access to an interpolating function which can be preallocated where useful. - * - * An abstract class which implements a preallocate function returning an unique pointer to an IInterpolator. - * A pointer is used so that the returned object can be any sub-class of IInterpolator. - * The type (and thus the implementation of the operator) will be determined when the pointer is - * dereferenced. - * - * The preallocate function should be used to allocate an instance of the IInterpolator before - * using it repeatedly. Once the preallocated object goes out of scope it will be deallocated. - * This means that objects of this class take up little or no space in memory. - * - * An example of this is seen in BslAdvectionVelocity. The IPreallocatableInterpolator stored in the - * BslAdvectionVelocity takes up no memory between advections, however during the execution of the - * BslAdvectionVelocity::operator() function the IPreallocatableInterpolator::preallocate() function - * is called. This leads to the creation of an IInterpolator instance, ensuring that all buffers necessary - * for the interpolation during the advection are allocated before the IInterpolator is used for - * interpolation in the advection loop. This ensures that these buffers are only allocated once per - * advection at the start of the BslAdvectionVelocity::operator() function. At the end of this function - * the unique pointer goes out of scope and the buffers are deallocated. - */ -template -class IPreallocatableInterpolator : public IInterpolator -{ - using CDim = typename DDim::continuous_dimension_type; - -public: - ~IPreallocatableInterpolator() override = default; - - /** - * @brief Allocate an instance of an InterpolatorProxy to use as an IInterpolator. - * - * Allocate and return an unique pointer to an instance of an IInterpolator. - * - * @return An allocated instance of an InterpolatorProxy. - * - * @see InterpolatorProxy - * @see IInterpolator - */ - virtual std::unique_ptr> preallocate() const = 0; - - /** - * @brief Approximate the value of a function at a set of coordinates using the - * current values at a known set of interpolation points by temporarily preallocating an IInterpolator. - * - * @param[in, out] inout_data On input: an array containing the value of the function at the interpolation points. - * On output: an array containing the value of the function at the coordinates. - * @param[in] coordinates The coordinates where the function should be evaluated. - * - * @return A reference to the inout_data array containing the value of the function at the coordinates. - */ - ddc::ChunkSpan> operator()( - ddc::ChunkSpan> const inout_data, - ddc::ChunkSpan, ddc::DiscreteDomain> const - coordinates) const override - { - return (*preallocate())(inout_data, coordinates); - } -}; diff --git a/src/interpolation/spline_interpolator.hpp b/src/interpolation/spline_interpolator.hpp deleted file mode 100644 index ab6ca8da7..000000000 --- a/src/interpolation/spline_interpolator.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// SPDX-License-Identifier: MIT - -#pragma once - -#include -#include - -#include "iinterpolator.hpp" - -/** - * @brief A class for interpolating a function using splines. - * - */ -template -class SplineInterpolator : public IInterpolator -{ - using CDim = typename DDim::continuous_dimension_type; - -private: - SplineBuilder const& m_builder; - - SplineEvaluator const& m_evaluator; - - mutable ddc::Chunk> m_coefs; - - std::vector m_derivs_min_alloc; - - std::vector m_derivs_max_alloc; - -public: - /** - * @brief Create a spline interpolator object. - * @param[in] builder An operator which builds spline coefficients from the values of a function at known interpolation points. - * @param[in] evaluator An operator which evaluates the value of a spline at requested coordinates. - */ - SplineInterpolator( - SplineBuilder const& builder, - SplineEvaluator const& evaluator) - : m_builder(builder) - , m_evaluator(evaluator) - , m_coefs(builder.spline_domain()) - , m_derivs_min_alloc(BSplines::degree() / 2, 0.) - , m_derivs_max_alloc(BSplines::degree() / 2, 0.) - { - } - - ~SplineInterpolator() override = default; - - ddc::ChunkSpan> operator()( - ddc::ChunkSpan> const inout_data, - ddc::ChunkSpan, ddc::DiscreteDomain> const - coordinates) const override - { - std::optional derivs_min; - std::optional derivs_max; - if constexpr (BcMin == BoundCond::HERMITE) { - derivs_min = CDSpan1D(m_derivs_min_alloc.data(), m_derivs_min_alloc.size()); - } - if constexpr (BcMax == BoundCond::HERMITE) { - derivs_max = CDSpan1D(m_derivs_max_alloc.data(), m_derivs_max_alloc.size()); - } - m_builder(m_coefs, inout_data, derivs_min, derivs_max); - m_evaluator(inout_data, coordinates, m_coefs); - return inout_data; - } -}; - -/** - * @brief A class which stores information necessary to create an instance of the SplineInterpolator class. - * - * This class allows an instance of the SplineInterpolator class where necessary. This allows the - * memory allocated in the private members of the SplineInterpolator to be freed when the object is not in use. - * These objects are: m_coefs, m_derivs_min_alloc, m_derivs_max_alloc. - */ -template -class PreallocatableSplineInterpolator : public IPreallocatableInterpolator -{ - SplineBuilder const& m_builder; - - SplineEvaluator const& m_evaluator; - -public: - /** - * @brief Create an object capable of creating SplineInterpolator objects. - * @param[in] builder An operator which builds spline coefficients from the values of a function at known interpolation points. - * @param[in] evaluator An operator which evaluates the value of a spline at requested coordinates. - */ - PreallocatableSplineInterpolator( - SplineBuilder const& builder, - SplineEvaluator const& evaluator) - : m_builder(builder) - , m_evaluator(evaluator) - { - } - - ~PreallocatableSplineInterpolator() override = default; - - /** - * Create an instance of the SplineInterpolator class. - * - * @return A unique pointer to an instance of the SplineInterpolator class. - */ - std::unique_ptr> preallocate() const override - { - return std::make_unique< - SplineInterpolator>(m_builder, m_evaluator); - } -}; diff --git a/tests/geometryXVx/lagrange_test.cpp b/tests/geometryXVx/lagrange_test.cpp index f90fdfec3..5e3a01a80 100644 --- a/tests/geometryXVx/lagrange_test.cpp +++ b/tests/geometryXVx/lagrange_test.cpp @@ -7,7 +7,7 @@ #include #include -#include "Lagrange_interpolator.hpp" +#include "Lagrange_interpolator_batched.hpp" // Here Z stands to specify that we use ad hoc geometry struct RDimZ { @@ -57,35 +57,43 @@ class LagrangeTest ddc::DiscreteVector npoints(x_size); ddc::DiscreteDomain interpolation_domain_x(lbound, npoints); - ddc::Chunk Essai_alloc(interpolation_domain_x, ddc::HostAllocator()); - ddc::ChunkSpan Essai = Essai_alloc.span_view(); - ddc::for_each(Essai.domain(), [&](DElemZ const ix) { - Essai(ix) = fpol(ddc::coordinate(ix).value(), deg); + ddc::Chunk Essai_host_alloc(interpolation_domain_x, ddc::HostAllocator()); + ddc::ChunkSpan Essai_host = Essai_host_alloc.span_view(); + ddc::for_each(Essai_host.domain(), [&](DElemZ const ix) { + Essai_host(ix) = fpol(ddc::coordinate(ix).value(), deg); }); int cpt = 1; std::default_random_engine generator; std::uniform_real_distribution unif_distr(-1, 1); - ddc::Chunk, ddc::DiscreteDomain> Sample( + ddc::Chunk, ddc::DiscreteDomain> Sample_host( interpolation_domain_x); - ddc::for_each(Sample.domain(), [&](DElemZ const ix) { + ddc::for_each(Sample_host.domain(), [&](DElemZ const ix) { if (cpt % int(0.1 * x_size) == 0) { - Sample(ix) = ddc::Coordinate( + Sample_host(ix) = ddc::Coordinate( ddc::coordinate(ix).value() + (cpt > 0.1 * x_size) * (cpt < 0.9 * x_size) * perturb * unif_distr(generator) / x_size); } else { - Sample(ix) = ddc::Coordinate(ddc::coordinate(ix).value()); + Sample_host(ix) = ddc::Coordinate(ddc::coordinate(ix).value()); } cpt++; }); ddc::DiscreteVector static constexpr gwx {0}; - LagrangeInterpolator - Test_Interpolator(deg, Essai.domain(), gwx); - Test_Interpolator(Essai, Sample); + LagrangeInterpolatorBatched + Test_Interpolator(deg, gwx); + auto Essai = ddc::create_mirror_view_and_copy( + Kokkos::DefaultExecutionSpace(), + Essai_host.span_view()); + auto Sample = ddc::create_mirror_view_and_copy( + Kokkos::DefaultExecutionSpace(), + Sample_host.span_view()); + Test_Interpolator(Essai.span_view(), Sample.span_cview()); + ddc::parallel_deepcopy(Essai_host, Essai); + ddc::parallel_deepcopy(Sample_host, Sample); ddc::for_each(interpolation_domain_x, [&](DElemZ const ix) { - Erreur.push_back(std::abs(Essai(ix) - fpol(Sample(ix), deg))); + Erreur.push_back(std::abs(Essai_host(ix) - fpol(Sample_host(ix), deg))); }); double s = std::transform_reduce( std::begin(Erreur),