Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits > Class Template Reference

Array-of-Struct-of-Arrays. More...

#include <Cabana_AoSoA.hpp>

Public Types

using aosoa_type
 AoSoA type.
 
using host_mirror_type = AoSoA<DataTypes, Kokkos::HostSpace, VectorLength>
 Host mirror type.
 
using member_types = DataTypes
 Member data types.
 
using memory_space = typename MemorySpace::memory_space
 Memory space.
 
using execution_space = typename memory_space::execution_space
 Default execution space.
 
using memory_traits = MemoryTraits
 Memory traits type.
 
using size_type = typename memory_space::size_type
 Size type.
 
using soa_type = SoA<member_types, vector_length>
 SoA type.
 
using soa_view = Kokkos::View<soa_type*, memory_space, memory_traits>
 Managed data view.
 
using index_type = Impl::Index<vector_length>
 Index type.
 
using tuple_type = Tuple<member_types>
 Tuple type.
 
template<std::size_t M>
using member_data_type = typename MemberTypeAtIndex<M, member_types>::type
 
template<std::size_t M>
using member_value_type
 Struct member array element value type at a given index M.
 
template<std::size_t M>
using member_pointer_type
 Struct member array element pointer type at a given index M.
 
template<std::size_t M>
using member_slice_type
 Member slice type at a given member index M.
 

Public Member Functions

 AoSoA (const std::string &label="")
 Default constructor.
 
 AoSoA (const std::string label, const size_type n)
 Allocate a container with n tuples.
 
 AoSoA (soa_type *ptr, const size_type num_soa, const size_type n)
 Create an unmanaged AoSoA with user-provided memory.
 
std::string label () const
 Returns the data structure label.
 
KOKKOS_FUNCTION size_type size () const
 Returns the number of tuples in the container.
 
KOKKOS_FUNCTION bool empty () const
 Returns if the container is empty or not.
 
KOKKOS_FUNCTION size_type capacity () const
 Returns the size of the storage space currently allocated for the container, expressed in terms of tuples.
 
void resize (const size_type n)
 Resizes the container so that it contains n tuples.
 
void reserve (const size_type n)
 Requests that the container capacity be at least enough to contain n tuples.
 
void shrinkToFit ()
 Remove unused capacity.
 
KOKKOS_INLINE_FUNCTION size_type numSoA () const
 Get the number of structs-of-arrays in the container.
 
KOKKOS_INLINE_FUNCTION size_type arraySize (const size_type s) const
 Get the size of the data array at a given struct member index.
 
KOKKOS_FORCEINLINE_FUNCTION soa_typeaccess (const size_type s) const
 Get a reference to the SoA at a given index.
 
KOKKOS_INLINE_FUNCTION tuple_type getTuple (const size_type i) const
 Get a tuple at a given index via a deep copy.
 
KOKKOS_INLINE_FUNCTION void setTuple (const size_type i, const tuple_type &tpl) const
 Set a tuple at a given index via a deep copy.
 
soa_typedata () const
 Get a typed raw pointer to the entire data block.
 

Static Public Attributes

static constexpr int vector_length = VectorLength
 Vector length (size of the arrays held by the structs).
 
static constexpr std::size_t number_of_members = member_types::size
 Number of member types.
 
static constexpr std::size_t max_supported_rank = 3
 The maximum rank supported for member types.
 

Detailed Description

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
class Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >

Array-of-Struct-of-Arrays.

Represents tuples and their data via an array-of-structs-of-arrays.

Template Parameters
DataType(required) Specifically this must be an instance of MemberTypes with the data layout of the structs. For example:
General sequence of types for SoA and AoSoA member data.
Definition Cabana_MemberTypes.hpp:28
would define an AoSoA where each tuple had a 3x3 matrix of doubles, a 3-vector of doubles, and an integer. The AoSoA is then templated on this sequence of types. In general, put larger datatypes first in the MemberType parameter pack (i.e. matrices and vectors) and group members of the same type together to achieve the smallest possible memory footprint based on compiler-generated padding.
MemorySpace(required) The Kokkos memory space.
VectorLength(optional) The vector length within the structs of the AoSoA. If not specified, this defaults to the preferred layout for the MemorySpace.
MemoryTraits(optional) Memory traits for the AoSoA data. Can be used to indicate managed memory, unmanaged memory, etc.

Member Typedef Documentation

◆ aosoa_type

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
using Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::aosoa_type
Initial value:
AoSoA(const std::string &label="")
Default constructor.
Definition Cabana_AoSoA.hpp:209

AoSoA type.

◆ member_data_type

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
template<std::size_t M>
using Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::member_data_type = typename MemberTypeAtIndex<M, member_types>::type

Member data type at a given index M. Note this is the user-defined member data type - not the potentially transformed type actually stored by the structs (SoAs) to achieve a given layout.

◆ member_pointer_type

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
template<std::size_t M>
using Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::member_pointer_type
Initial value:
typename std::add_pointer<member_value_type<M>>::type

Struct member array element pointer type at a given index M.

◆ member_slice_type

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
template<std::size_t M>
using Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::member_slice_type
Initial value:
sizeof( soa_type ) / sizeof( member_value_type<M> )>
typename MemorySpace::memory_space memory_space
Memory space.
Definition Cabana_AoSoA.hpp:140
static constexpr int vector_length
Vector length (size of the arrays held by the structs).
Definition Cabana_AoSoA.hpp:152
SoA< member_types, vector_length > soa_type
SoA type.
Definition Cabana_AoSoA.hpp:161
typename std::remove_all_extents< member_data_type< M > >::type member_value_type
Struct member array element value type at a given index M.
Definition Cabana_AoSoA.hpp:186
A slice of an array-of-structs-of-arrays with data access to a single multidimensional member.
Definition Cabana_Slice.hpp:502
Definition Cabana_Types.hpp:37

Member slice type at a given member index M.

◆ member_value_type

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
template<std::size_t M>
using Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::member_value_type
Initial value:
typename std::remove_all_extents<member_data_type<M>>::type

Struct member array element value type at a given index M.

Constructor & Destructor Documentation

◆ AoSoA() [1/3]

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::AoSoA ( const std::string & label = "")
inline

Default constructor.

Parameters
labelAn optional label for the data structure.

The container size is zero and no memory is allocated.

◆ AoSoA() [2/3]

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::AoSoA ( const std::string label,
const size_type n )
inline

Allocate a container with n tuples.

Parameters
labelA label for the data structure.
nThe number of tuples in the container.

◆ AoSoA() [3/3]

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::AoSoA ( soa_type * ptr,
const size_type num_soa,
const size_type n )
inline

Create an unmanaged AoSoA with user-provided memory.

Parameters
ptrPointer to user-allocated AoSoA data.
num_soaThe number of SoAs the user has allocated.
nThe number of tuples in the container.

Member Function Documentation

◆ access()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
KOKKOS_FORCEINLINE_FUNCTION soa_type & Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::access ( const size_type s) const
inline

Get a reference to the SoA at a given index.

Parameters
sThe SoA index.
Returns
The SoA reference at the given index.

◆ arraySize()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
KOKKOS_INLINE_FUNCTION size_type Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::arraySize ( const size_type s) const
inline

Get the size of the data array at a given struct member index.

Parameters
sThe struct index to get the array size for.
Returns
The size of the array at the given struct index.

◆ capacity()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
KOKKOS_FUNCTION size_type Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::capacity ( ) const
inline

Returns the size of the storage space currently allocated for the container, expressed in terms of tuples.

Returns
The capacity of the container.

This capacity is not necessarily equal to the container size. It can be equal or greater, with the extra space allowing to accommodate for growth without the need to reallocate on each insertion.

Notice that this capacity does not suppose a limit on the size of the container. When this capacity is exhausted and more is needed, it is automatically expanded by the container (reallocating the storage space).

The capacity of a container can be explicitly altered by calling member reserve.

◆ data()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
soa_type * Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::data ( ) const
inline

Get a typed raw pointer to the entire data block.

Returns
A typed raw-pointer to the entire data block.

◆ empty()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
KOKKOS_FUNCTION bool Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::empty ( ) const
inline

Returns if the container is empty or not.

Returns
True if the number of tuples in the container is zero.

This is the number of actual objects held in the container, which is not necessarily equal to its storage capacity.

◆ getTuple()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
KOKKOS_INLINE_FUNCTION tuple_type Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::getTuple ( const size_type i) const
inline

Get a tuple at a given index via a deep copy.

Parameters
iThe index to get the tuple from.
Returns
A tuple containing a deep copy of the data at the given index.

◆ label()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
std::string Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::label ( ) const
inline

Returns the data structure label.

Returns
A string identifying the data structure.

This label will be assigned to the underlying Kokkos view managing the data of this class and can be used for debugging and profiling purposes.

◆ numSoA()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
KOKKOS_INLINE_FUNCTION size_type Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::numSoA ( ) const
inline

Get the number of structs-of-arrays in the container.

Returns
The number of structs-of-arrays in the container.

◆ reserve()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
void Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::reserve ( const size_type n)
inline

Requests that the container capacity be at least enough to contain n tuples.

If n is greater than the current container capacity, the function causes the container to reallocate its storage increasing its capacity to n (or greater).

In all other cases, the function call does not cause a reallocation and the container capacity is not affected.

If reallocation occurs, all slices and all references to the elements are invalidated. If no reallocation takes place, no slices or references are invalidated.

This function has no effect on the container size and cannot alter its tuples.

◆ resize()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
void Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::resize ( const size_type n)
inline

Resizes the container so that it contains n tuples.

If n is smaller than the current container size, the content is reduced to its first n tuples.

If n is greater than the current container size, the content is expanded by inserting at the end as many tuples as needed to reach a size of n.

If n is also greater than the current container capacity, an automatic reallocation of the allocated storage space takes place.

Notice that this function changes the actual content of the container by inserting or erasing tuples from it. If reallocation occurs, all slices and all references to the elements are invalidated. If no reallocation takes place, no slices or references are invalidated.

◆ setTuple()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
KOKKOS_INLINE_FUNCTION void Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::setTuple ( const size_type i,
const tuple_type & tpl ) const
inline

Set a tuple at a given index via a deep copy.

Parameters
iThe index to set the tuple at.
tplThe tuple to get the data from.

◆ shrinkToFit()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
void Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::shrinkToFit ( )
inline

Remove unused capacity.

Will reduce the capacity to be the smallest number of SoAs needed to hold size() tuples. If reallocation occurs, all slices and all references to the elements are invalidated. If no reallocation takes place, no slices or references are invalidated.

◆ size()

template<class DataTypes, class MemorySpace, int VectorLength = Impl::PerformanceTraits< typename MemorySpace::execution_space>::vector_length, class MemoryTraits = Kokkos::MemoryManaged>
KOKKOS_FUNCTION size_type Cabana::AoSoA< DataTypes, MemorySpace, VectorLength, MemoryTraits >::size ( ) const
inline

Returns the number of tuples in the container.

Returns
The number of tuples in the container.

This is the number of actual objects held in the container, which is not necessarily equal to its storage capacity.


The documentation for this class was generated from the following file: