ECP-copa / Cabana

Performance-portable library for particle-based simulations
Other
209 stars 50 forks source link

Why does AOSOA not support non-arithmetic data type?? #770

Open FlyingCat2023 opened 6 days ago

FlyingCat2023 commented 6 days ago

For some reasons I would like to use a class as the Datatype. However, I found it is not supported in Cabana_MemberTypes.hpp. What is the background of forcing its member to be arithmetic types?

template <std::size_t M, typename T, typename... Types> struct CheckMemberTypesImpl { using type = T; static_assert( std::is_trivial::value, "Member types must be trivial" ); using value_type = typename std::remove_all_extents::type; static_assert( std::is_arithmetic::value, "Member value types must be arithmetic" );

static constexpr bool value = CheckMemberTypesImpl<M - 1, Types...>::value;

}; //! \endcond

streeve commented 1 day ago

First, we're fundamentally limited by https://kokkos.org/kokkos-core-wiki/ProgrammingGuide/View.html?highlight=trivial#what-types-of-data-may-a-view-contain

But you're correct that we're more restrictive since https://github.com/ECP-copa/Cabana/pull/203. The discussion there is pretty good, but I'm happy to discuss further

FlyingCat2023 commented 1 day ago

Thank for replying. As in #203 Rfbird asked for use cases, here I provide one that uses truncated hierarchical B-spline (THB) which is typical for many particle in cell (PIC) solvers. The THB spline is uniquely defined by the grid topology around its knot/grid node. If we consider it as a property of the node, an AOSOA data structure will be helpful to manage the data of the grids including the splines.