Cabana is a MPI+Kokkos performance portable library for particle-based simulations. It provides particle data structures, algorithms, and utilities to enable simulations on a variety of platforms including many-core architectures and GPUs.
This use case describes the SoA and AoSoA classes provided by Cabana. Their goal is to provide a vectorization-friendly collections of contiguous elements that exhibit good alignment.
Defined in header <Cabana_SoA.hpp>
template <typename DataTypes, int VectorLength>
struct SoA;
Cabana::SoA
is a struct template that provides a way to store a fixed-size collection of heterogeneous arrays whose size is the specified vector length.
Conceptually Cabana::SoA<Cabana::MemberTypes<float[3], char>, 8>
is equivalent to std::tuple<float[3][8], char[8]>
.
The data structure keeps a separate, homogeneous data array for each particle field, each having the same number of elements. The motivation is easier vectorization for the compiler.
DataTypes
: The types of the elements that the SoA stores as fixed size arrays.
It is required to be a specialization of Cabana::MemberTypes
which is defined as
template <typename... Types>
MemberTypes<Types...>;
VectorLength
: The number of elements stored in contiguous memory locations for each data type.
Cabana::get
: accesses the specified element of the SoA.
Defined in header <Cabana_AoSoA.hpp>
template <class DataTypes, class DeviceType,
int VectorLength = Impl::PerformanceTraits<
typename DeviceType::execution_space>::vector_length,
class MemoryTraits = Kokkos::MemoryManaged>
class AoSoA;
DataTypes
: The types of the elements stored in the underlying Cabana::SoA
s.
DeviceType
: The Kokkos device type that carries the information about where to execute code and where to allocate storage.
VectorLength
: The vector length for the structure of arrays (optional).
MemoryTraits
: The Kokkos memory traits that tells who controls memory allocation and deallocation (optional).
slice
: accesses the particle data fields.