Skip to content

Commit

Permalink
Resolve "Forgotten desallocation Paraconf"
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Nov 20, 2023
1 parent 8eb065c commit 68140c1
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ int main(int argc, char** argv)
if (iter_start == 0) {
SingleModePerturbInitialization const
init(allfequilibrium_device,
ddc::discrete_space<IDimSp>().perturb_modes(),
ddc::discrete_space<IDimSp>().perturb_amplitudes());
ddc::host_discrete_space<IDimSp>().perturb_modes(),
ddc::host_discrete_space<IDimSp>().perturb_amplitudes());
init(allfdistribu_device);
} else {
RestartInitialization const restart(iter_start, time_start);
Expand Down
4 changes: 2 additions & 2 deletions simulations/geometryXVx/bump_on_tail/bumpontail_fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ int main(int argc, char** argv)
if (iter_start == 0) {
SingleModePerturbInitialization const
init(allfequilibrium_device,
ddc::discrete_space<IDimSp>().perturb_modes(),
ddc::discrete_space<IDimSp>().perturb_amplitudes());
ddc::host_discrete_space<IDimSp>().perturb_modes(),
ddc::host_discrete_space<IDimSp>().perturb_amplitudes());
init(allfdistribu_device);
} else {
RestartInitialization const restart(iter_start, time_start);
Expand Down
4 changes: 2 additions & 2 deletions simulations/geometryXVx/landau/landau_fem_uniform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ int main(int argc, char** argv)
if (iter_start == 0) {
SingleModePerturbInitialization const
init(allfequilibrium_device,
ddc::discrete_space<IDimSp>().perturb_modes(),
ddc::discrete_space<IDimSp>().perturb_amplitudes());
ddc::host_discrete_space<IDimSp>().perturb_modes(),
ddc::host_discrete_space<IDimSp>().perturb_amplitudes());
init(allfdistribu_device);
} else {
RestartInitialization const restart(iter_start, time_start);
Expand Down
4 changes: 2 additions & 2 deletions simulations/geometryXVx/landau/landau_fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ int main(int argc, char** argv)
if (iter_start == 0) {
SingleModePerturbInitialization const
init(allfequilibrium_device,
ddc::discrete_space<IDimSp>().perturb_modes(),
ddc::discrete_space<IDimSp>().perturb_amplitudes());
ddc::host_discrete_space<IDimSp>().perturb_modes(),
ddc::host_discrete_space<IDimSp>().perturb_amplitudes());
init(allfdistribu_device);
} else {
RestartInitialization const restart(iter_start, time_start);
Expand Down
4 changes: 2 additions & 2 deletions simulations/geometryXVx/sheath/sheath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ int main(int argc, char** argv)
if (iter_start == 0) {
SingleModePerturbInitialization const
init(allfequilibrium_device,
ddc::discrete_space<IDimSp>().perturb_modes(),
ddc::discrete_space<IDimSp>().perturb_amplitudes());
ddc::host_discrete_space<IDimSp>().perturb_modes(),
ddc::host_discrete_space<IDimSp>().perturb_amplitudes());
init(allfdistribu_device);
} else {
RestartInitialization const restart(iter_start, time_start);
Expand Down
4 changes: 2 additions & 2 deletions simulations/geometryXYVxVy/landau/landau4d_fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ int main(int argc, char** argv)
DFieldSpXYVxVy allfdistribu(meshSpXYVxVy);
SingleModePerturbInitialization const
init(allfequilibrium,
ddc::discrete_space<IDimSp>().perturb_modes(),
ddc::discrete_space<IDimSp>().perturb_amplitudes());
ddc::host_discrete_space<IDimSp>().perturb_modes(),
ddc::host_discrete_space<IDimSp>().perturb_amplitudes());
init(allfdistribu);

// --> Algorithm info
Expand Down
31 changes: 17 additions & 14 deletions src/speciesinfo/species_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ class SpeciesInformation
ddc::deepcopy(m_perturb_mode, impl.m_perturb_mode);
}

Impl(ddc::Chunk<int, discrete_domain_type> charge,
ddc::Chunk<double, discrete_domain_type> mass,
ddc::Chunk<double, discrete_domain_type> perturb_amplitude,
ddc::Chunk<int, discrete_domain_type> perturb_mode)
Impl(ddc::Chunk<int, discrete_domain_type, ddc::KokkosAllocator<int, MemorySpace>> charge,
ddc::Chunk<double, discrete_domain_type, ddc::KokkosAllocator<double, MemorySpace>>
mass,
ddc::Chunk<double, discrete_domain_type, ddc::KokkosAllocator<double, MemorySpace>>
perturb_amplitude,
ddc::Chunk<int, discrete_domain_type, ddc::KokkosAllocator<int, MemorySpace>>
perturb_mode)
: m_charge(std::move(charge))
, m_mass(std::move(mass))
, m_perturb_amplitude(std::move(perturb_amplitude))
Expand All @@ -88,24 +91,24 @@ class SpeciesInformation
return m_ielec;
}

ddc::ChunkSpan<const int, discrete_domain_type> charges() const
auto charges() const
{
return m_charge;
return m_charge.span_view();
}

ddc::ChunkSpan<const double, discrete_domain_type> masses() const
auto masses() const
{
return m_mass;
return m_mass.span_view();
}

ddc::ChunkSpan<const double, discrete_domain_type> perturb_amplitudes() const
auto perturb_amplitudes() const
{
return m_perturb_amplitude;
return m_perturb_amplitude.span_view();
}

ddc::ChunkSpan<const int, discrete_domain_type> perturb_modes() const
auto perturb_modes() const
{
return m_perturb_mode;
return m_perturb_mode.span_view();
}
};
};
Expand All @@ -117,10 +120,10 @@ KOKKOS_INLINE_FUNCTION ddc::DiscreteElement<SpeciesInformation> ielec()

inline int charge(ddc::DiscreteElement<SpeciesInformation> const isp)
{
return ddc::discrete_space<SpeciesInformation>().charges()(isp);
return ddc::host_discrete_space<SpeciesInformation>().charges()(isp);
}

inline double mass(ddc::DiscreteElement<SpeciesInformation> const isp)
{
return ddc::discrete_space<SpeciesInformation>().masses()(isp);
return ddc::host_discrete_space<SpeciesInformation>().masses()(isp);
}
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,6 @@ int main(int argc, char** argv)

std::cout << " -------------------------------------------------------------------"
<< std::endl;

PC_tree_destroy(&conf_voicexx);
}
2 changes: 2 additions & 0 deletions tests/geometryRTheta/polar_poisson/polarpoissonfemsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,7 @@ int main(int argc, char** argv)
});
std::cout << "Max error : " << max_err << std::endl;

PC_tree_destroy(&conf_voicexx);

return 0;
}
8 changes: 6 additions & 2 deletions vendor/ddc/include/ddc/chunk_span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ class ChunkSpan<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy, Memo
/** Constructs a new ChunkSpan from a Chunk, yields a new view to the same data
* @param other the Chunk to view
*/
template <class OElementType, class Allocator>
template <
class OElementType,
class Allocator,
class = std::enable_if_t<std::is_same_v<typename Allocator::memory_space, MemorySpace>>>
KOKKOS_FUNCTION constexpr ChunkSpan(
Chunk<OElementType, mdomain_type, Allocator>& other) noexcept
: base_type(other.m_internal_mdspan, other.m_domain)
Expand All @@ -146,7 +149,8 @@ class ChunkSpan<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy, Memo
class OElementType,
class SFINAEElementType = ElementType,
class = std::enable_if_t<std::is_const_v<SFINAEElementType>>,
class Allocator>
class Allocator,
class = std::enable_if_t<std::is_same_v<typename Allocator::memory_space, MemorySpace>>>
KOKKOS_FUNCTION constexpr ChunkSpan(
Chunk<OElementType, mdomain_type, Allocator> const& other) noexcept
: base_type(other.m_internal_mdspan, other.m_domain)
Expand Down
6 changes: 6 additions & 0 deletions vendor/ddc/include/ddc/discrete_space.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,10 @@ KOKKOS_FORCEINLINE_FUNCTION detail::ddim_impl_t<DDim, MemorySpace> const& discre
}
}

template <class DDim>
detail::ddim_impl_t<DDim, Kokkos::HostSpace> const& host_discrete_space()
{
return detail::g_discrete_space_dual<DDim>->get_host();
}

} // namespace ddc

0 comments on commit 68140c1

Please sign in to comment.