Skip to content

Commit

Permalink
Sync DDC
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Oct 18, 2023
1 parent 2105c6d commit 48b17cc
Show file tree
Hide file tree
Showing 32 changed files with 540 additions and 363 deletions.
2 changes: 2 additions & 0 deletions src/advection/bsl_advection_vx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class BslAdvectionVelocity : public IAdvectionVelocity<Geometry, DDimV>
ddc::ChunkSpan<const double, SpatialDDom> const electric_field,
double const dt) const override
{
Kokkos::Profiling::pushRegion("BslAdvectionVelocity");
FdistribuDDom const dom = allfdistribu.domain();
ddc::DiscreteDomain<DDimV> const v_dom = ddc::select<DDimV>(dom);
ddc::DiscreteDomain<DDimSp> const sp_dom = ddc::select<DDimSp>(dom);
Expand Down Expand Up @@ -79,6 +80,7 @@ class BslAdvectionVelocity : public IAdvectionVelocity<Geometry, DDimV>
});
});

Kokkos::Profiling::popRegion();
return allfdistribu;
}
};
2 changes: 2 additions & 0 deletions src/advection/bsl_advection_x.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class BslAdvectionSpatial : public IAdvectionSpatial<Geometry, DDimX>
ddc::ChunkSpan<double, DDom> const allfdistribu,
double const dt) const override
{
Kokkos::Profiling::pushRegion("BslAdvectionSpatial");
DDom const dom = allfdistribu.domain();
ddc::DiscreteDomain<DDimX> const x_dom = ddc::select<DDimX>(dom);
ddc::DiscreteDomain<DDimV> const v_dom = ddc::select<DDimV>(dom);
Expand Down Expand Up @@ -78,6 +79,7 @@ class BslAdvectionSpatial : public IAdvectionSpatial<Geometry, DDimX>
});
});

Kokkos::Profiling::popRegion();
return allfdistribu;
}
};
2 changes: 2 additions & 0 deletions src/geometryXVx/poisson/chargedensitycalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ChargeDensityCalculator::ChargeDensityCalculator(

void ChargeDensityCalculator::operator()(DSpanX const rho, DViewSpXVx const allfdistribu) const
{
Kokkos::Profiling::pushRegion("ChargeDensityCalculator");
DFieldVx f_vx_slice(allfdistribu.domain<IDimVx>());
ddc::Chunk<double, BSDomainVx> vx_spline_coef(m_spline_vx_builder.spline_domain());

Expand All @@ -40,4 +41,5 @@ void ChargeDensityCalculator::operator()(DSpanX const rho, DViewSpXVx const allf
rho(ix) += charge(isp) * m_spline_vx_evaluator.integrate(vx_spline_coef.span_cview());
});
});
Kokkos::Profiling::popRegion();
}
12 changes: 6 additions & 6 deletions src/geometryXVx/poisson/electricfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ ElectricField::ElectricField(
// Compute efield = -dPhi/dx where Phi is the electrostatic potential
// input : Phi values
//===========================================================================
DSpanX ElectricField::operator()(
DSpanX const electric_field,
DBSViewX const electrostatic_potential) const
void ElectricField::operator()(DSpanX const electric_field, DBSViewX const electrostatic_potential)
const
{
IDomainX const& x_dom = electric_field.domain();
ddc::for_each(x_dom, [&](IndexX const ix) {
electric_field(ix)
= -m_spline_x_evaluator.deriv(ddc::coordinate(ix), electrostatic_potential);
});
return electric_field;
}

DSpanX ElectricField::operator()(DSpanX const electric_field, DViewX const electrostatic_potential)
void ElectricField::operator()(DSpanX const electric_field, DViewX const electrostatic_potential)
const
{
Kokkos::Profiling::pushRegion("ElectricField");
ddc::Chunk<double, BSDomainX> elecpot_spline_coef(m_spline_x_builder.spline_domain());
m_spline_x_builder(elecpot_spline_coef, electrostatic_potential);
return (*this)(electric_field, elecpot_spline_coef);
(*this)(electric_field, elecpot_spline_coef);
Kokkos::Profiling::popRegion();
}
4 changes: 2 additions & 2 deletions src/geometryXVx/poisson/electricfield.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ElectricField
SplineXBuilder const& spline_x_builder,
SplineEvaluator<BSplinesX> const& spline_x_evaluator);

DSpanX operator()(DSpanX electric_field, DViewX electrostatic_potential) const;
void operator()(DSpanX electric_field, DViewX electrostatic_potential) const;

DSpanX operator()(DSpanX electric_field, DBSViewX electrostatic_potential) const;
void operator()(DSpanX electric_field, DBSViewX electrostatic_potential) const;
};
2 changes: 2 additions & 0 deletions src/geometryXVx/poisson/femnonperiodicpoissonsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ void FemNonPeriodicPoissonSolver::operator()(
DSpanX const electric_field,
DViewSpXVx const allfdistribu) const
{
Kokkos::Profiling::pushRegion("PoissonSolver");
assert(electrostatic_potential.domain() == ddc::get_domain<IDimX>(allfdistribu));
IDomainX const dom_x = electrostatic_potential.domain();

Expand All @@ -202,4 +203,5 @@ void FemNonPeriodicPoissonSolver::operator()(
electrostatic_potential(ix) = m_spline_x_nu_evaluator(ddc::coordinate(ix), phi_spline_coef);
electric_field(ix) = -m_spline_x_nu_evaluator.deriv(ddc::coordinate(ix), phi_spline_coef);
});
Kokkos::Profiling::popRegion();
}
2 changes: 2 additions & 0 deletions src/geometryXVx/poisson/femperiodicpoissonsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ void FemPeriodicPoissonSolver::operator()(
DSpanX const electric_field,
DViewSpXVx const allfdistribu) const
{
Kokkos::Profiling::pushRegion("PoissonSolver");
assert(electrostatic_potential.domain() == ddc::get_domain<IDimX>(allfdistribu));
IDomainX const dom_x = electrostatic_potential.domain();

Expand All @@ -188,4 +189,5 @@ void FemPeriodicPoissonSolver::operator()(
electrostatic_potential(ix) = m_spline_x_evaluator(ddc::coordinate(ix), phi_spline_coef);
electric_field(ix) = -m_spline_x_evaluator.deriv(ddc::coordinate(ix), phi_spline_coef);
});
Kokkos::Profiling::popRegion();
}
2 changes: 2 additions & 0 deletions src/geometryXYVxVy/poisson/chargedensitycalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ChargeDensityCalculator::ChargeDensityCalculator(

void ChargeDensityCalculator::operator()(DSpanXY const rho, DViewSpXYVxVy const allfdistribu) const
{
Kokkos::Profiling::pushRegion("ChargeDensityCalculator");
DFieldVxVy f_vxvy_slice(allfdistribu.domain<IDimVx, IDimVy>());
ddc::Chunk<double, BSDomainVxVy> vxvy_spline_coef(m_spline_vxvy_builder.spline_domain());

Expand Down Expand Up @@ -70,4 +71,5 @@ void ChargeDensityCalculator::operator()(DSpanXY const rho, DViewSpXYVxVy const
* m_spline_vxvy_evaluator.integrate(vxvy_spline_coef.span_cview());
});
});
Kokkos::Profiling::popRegion();
}
4 changes: 3 additions & 1 deletion src/geometryXYVxVy/poisson/electricfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ void ElectricField::operator()(
DSpanXY const electric_field_y,
DViewXY const electrostatic_potential) const
{
Kokkos::Profiling::pushRegion("PoissonSolver");
ddc::Chunk<double, BSDomainXY> elecpot_spline_coef((m_spline_xy_builder.spline_domain()));
m_spline_xy_builder(elecpot_spline_coef, electrostatic_potential);
return (*this)(electric_field_x, electric_field_y, elecpot_spline_coef);
(*this)(electric_field_x, electric_field_y, elecpot_spline_coef);
Kokkos::Profiling::popRegion();
}
2 changes: 2 additions & 0 deletions src/geometryXYVxVy/poisson/fftpoissonsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void FftPoissonSolver::operator()(
DSpanXY const electric_field_y,
DViewSpXYVxVy const allfdistribu) const
{
Kokkos::Profiling::pushRegion("PoissonSolver");
assert((electrostatic_potential.domain() == ddc::get_domain<IDimX, IDimY>(allfdistribu)));
IDomainXY const xy_dom = electrostatic_potential.domain();

Expand Down Expand Up @@ -79,4 +80,5 @@ void FftPoissonSolver::operator()(

// Compute efield = -dPhi/dx where Phi is the electrostatic potential
m_electric_field(electric_field_x, electric_field_y, electrostatic_potential);
Kokkos::Profiling::popRegion();
}
14 changes: 13 additions & 1 deletion vendor/ddc/benchmarks/deepcopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,16 @@ BENCHMARK(memcpy_2d)->Args({large_dim1_2D, large_dim2_2D});
BENCHMARK(deepcopy_2d)->Args({large_dim1_2D, large_dim2_2D});
BENCHMARK(deepcopy_subchunk_2d)->Args({large_dim1_2D, large_dim2_2D});

BENCHMARK_MAIN();
int main(int argc, char** argv)
{
::benchmark::Initialize(&argc, argv);
if (::benchmark::ReportUnrecognizedArguments(argc, argv)) {
return 1;
}
{
ddc::ScopeGuard const guard;
::benchmark::RunSpecifiedBenchmarks();
}
::benchmark::Shutdown();
return 0;
}
62 changes: 33 additions & 29 deletions vendor/ddc/include/ddc/chunk_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,91 +132,91 @@ class ChunkCommon<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy>
mdomain_type m_domain;

public:
static constexpr int rank() noexcept
static KOKKOS_FUNCTION constexpr int rank() noexcept
{
return extents_type::rank();
}

static constexpr int rank_dynamic() noexcept
static KOKKOS_FUNCTION constexpr int rank_dynamic() noexcept
{
return extents_type::rank_dynamic();
}

static constexpr size_type static_extent(std::size_t r) noexcept
static KOKKOS_FUNCTION constexpr size_type static_extent(std::size_t r) noexcept
{
return extents_type::static_extent(r);
}

static constexpr bool is_always_unique() noexcept
static KOKKOS_FUNCTION constexpr bool is_always_unique() noexcept
{
return mapping_type::is_always_unique();
}

static constexpr bool is_always_exhaustive() noexcept
static KOKKOS_FUNCTION constexpr bool is_always_exhaustive() noexcept
{
return mapping_type::is_always_exhaustive();
}

static constexpr bool is_always_strided() noexcept
static KOKKOS_FUNCTION constexpr bool is_always_strided() noexcept
{
return mapping_type::is_always_strided();
}

public:
constexpr accessor_type accessor() const
KOKKOS_FUNCTION constexpr accessor_type accessor() const
{
return m_internal_mdspan.accessor();
}

constexpr DiscreteVector<DDims...> extents() const noexcept
KOKKOS_FUNCTION constexpr DiscreteVector<DDims...> extents() const noexcept
{
return DiscreteVector<DDims...>(
(m_internal_mdspan.extent(type_seq_rank_v<DDims, detail::TypeSeq<DDims...>>)
- front<DDims>(m_domain).uid())...);
}

template <class QueryDDim>
constexpr size_type extent() const noexcept
KOKKOS_FUNCTION constexpr size_type extent() const noexcept
{
return m_internal_mdspan.extent(type_seq_rank_v<QueryDDim, detail::TypeSeq<DDims...>>)
- front<QueryDDim>(m_domain).uid();
}

constexpr size_type size() const noexcept
KOKKOS_FUNCTION constexpr size_type size() const noexcept
{
return allocation_mdspan().size();
}

constexpr mapping_type mapping() const noexcept
KOKKOS_FUNCTION constexpr mapping_type mapping() const noexcept
{
return allocation_mdspan().mapping();
}

constexpr bool is_unique() const noexcept
KOKKOS_FUNCTION constexpr bool is_unique() const noexcept
{
return allocation_mdspan().is_unique();
}

constexpr bool is_exhaustive() const noexcept
KOKKOS_FUNCTION constexpr bool is_exhaustive() const noexcept
{
return allocation_mdspan().is_exhaustive();
}

constexpr bool is_strided() const noexcept
KOKKOS_FUNCTION constexpr bool is_strided() const noexcept
{
return allocation_mdspan().is_strided();
}

template <class QueryDDim>
constexpr size_type stride() const
KOKKOS_FUNCTION constexpr size_type stride() const
{
return m_internal_mdspan.stride(type_seq_rank_v<QueryDDim, detail::TypeSeq<DDims...>>);
}

/** Provide access to the domain on which this chunk is defined
* @return the domain on which this chunk is defined
*/
constexpr mdomain_type domain() const noexcept
KOKKOS_FUNCTION constexpr mdomain_type domain() const noexcept
{
return m_domain;
}
Expand All @@ -225,20 +225,22 @@ class ChunkCommon<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy>
* @return the domain on which this chunk is defined
*/
template <class... QueryDDims>
constexpr DiscreteDomain<QueryDDims...> domain() const noexcept
KOKKOS_FUNCTION constexpr DiscreteDomain<QueryDDims...> domain() const noexcept
{
return select<QueryDDims...>(domain());
}

protected:
/// Empty ChunkCommon
constexpr ChunkCommon() = default;
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon() = default;

/** Constructs a new ChunkCommon from scratch
* @param internal_mdspan
* @param domain
*/
constexpr ChunkCommon(internal_mdspan_type internal_mdspan, mdomain_type const& domain) noexcept
KOKKOS_FUNCTION constexpr ChunkCommon(
internal_mdspan_type internal_mdspan,
mdomain_type const& domain) noexcept
: m_internal_mdspan(std::move(internal_mdspan))
, m_domain(domain)
{
Expand All @@ -251,53 +253,55 @@ class ChunkCommon<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy>
template <
class Mapping = mapping_type,
std::enable_if_t<std::is_constructible_v<Mapping, extents_type>, int> = 0>
constexpr ChunkCommon(ElementType* ptr, mdomain_type const& domain)
KOKKOS_FUNCTION constexpr ChunkCommon(ElementType* ptr, mdomain_type const& domain)
: ChunkCommon {ptr, domain, make_mapping_for(domain)}
{
}

/** Constructs a new ChunkCommon by copy, yields a new view to the same data
* @param other the ChunkCommon to copy
*/
constexpr ChunkCommon(ChunkCommon const& other) = default;
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon(ChunkCommon const& other) = default;

/** Constructs a new ChunkCommon by move
* @param other the ChunkCommon to move
*/
constexpr ChunkCommon(ChunkCommon&& other) = default;
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon(ChunkCommon&& other) = default;

KOKKOS_DEFAULTED_FUNCTION ~ChunkCommon() = default;

/** Copy-assigns a new value to this ChunkCommon, yields a new view to the same data
* @param other the ChunkCommon to copy
* @return *this
*/
constexpr ChunkCommon& operator=(ChunkCommon const& other) = default;
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon& operator=(ChunkCommon const& other) = default;

/** Move-assigns a new value to this ChunkCommon
* @param other the ChunkCommon to move
* @return *this
*/
constexpr ChunkCommon& operator=(ChunkCommon&& other) = default;
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon& operator=(ChunkCommon&& other) = default;

/** Access to the underlying allocation pointer
* @return allocation pointer
*/
constexpr ElementType* data_handle() const
KOKKOS_FUNCTION constexpr ElementType* data_handle() const
{
return &m_internal_mdspan(front<DDims>(m_domain).uid()...);
}

/** Provide a modifiable view of the data
* @return a modifiable view of the data
*/
constexpr internal_mdspan_type internal_mdspan() const
KOKKOS_FUNCTION constexpr internal_mdspan_type internal_mdspan() const
{
return m_internal_mdspan;
}

/** Provide a modifiable view of the data
* @return a modifiable view of the data
*/
constexpr allocation_mdspan_type allocation_mdspan() const
KOKKOS_FUNCTION constexpr allocation_mdspan_type allocation_mdspan() const
{
DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
extents_type extents_s(::ddc::extents<DDims>(m_domain).value()...);
Expand All @@ -316,7 +320,7 @@ class ChunkCommon<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy>
* @param domain the domain that sustains the view
*/
template <class Mapping = mapping_type>
constexpr std::enable_if_t<
KOKKOS_FUNCTION constexpr std::enable_if_t<
std::is_constructible_v<Mapping, extents_type>,
std::experimental::layout_stride::mapping<extents_type>>
make_mapping_for(mdomain_type const& domain)
Expand All @@ -334,7 +338,7 @@ class ChunkCommon<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy>
* @param ptr the allocation pointer to the data_handle()
* @param domain the domain that sustains the view
*/
constexpr ChunkCommon(
KOKKOS_FUNCTION constexpr ChunkCommon(
ElementType* ptr,
mdomain_type const& domain,
std::experimental::layout_stride::mapping<extents_type>&& s_domain)
Expand Down
Loading

0 comments on commit 48b17cc

Please sign in to comment.