39 typename TArrayExtents,
44 typename TLinearizeArrayIndexFunctor = LinearizeArrayIndexRight,
45 template<
typename>
typename PermuteFieldsSingleBlob = PermuteFieldsInOrder>
50 using size_type =
typename TArrayExtents::value_type;
56 using Permuter = PermuteFieldsSingleBlob<FlatRecordDim<TRecordDim>>;
60 #if defined(__NVCC__) && __CUDACC_VER_MAJOR__ >= 12
63 constexpr
SoA() =
default;
76 constexpr
auto typeSizes = []() constexpr
79 forEachLeafCoord<TRecordDim>([&r, i = 0](
auto rc)
mutable constexpr
80 { r[i++] =
sizeof(
GetType<TRecordDim, decltype(rc)>); });
83 return flatSize * typeSizes[blobIndex];
89 mp_for_each_inline<mp_transform<mp_identity, FRD>>(
92 using FieldType =
typename decltype(ti)::type;
94 size +=
static_cast<size_type>(
sizeof(FieldType)) * flatSize;
100 return flatSize *
static_cast<size_type>(sizeOf<TRecordDim>);
109 constexpr
auto subArrays = mp_size<FRD>::value;
110 Array<size_type, subArrays> r{};
115 constexpr
auto i = decltype(ic)::value;
117 using ThisFieldType = mp_at_c<FRD, i>;
118 r[i + 1] +=
static_cast<size_type
>(
sizeof(ThisFieldType)) * staticFlatSize;
119 using NextFieldType = mp_at_c<FRD, i + 1>;
120 r[i + 1] =
roundUpToMultiple(r[i + 1],
static_cast<size_type
>(
alignof(NextFieldType)));
126 template<std::size_t... RecordCoords>
135 template<std::size_t... RecordCoords>
140 const size_type elementOffset
141 = flatArrayIndex *
static_cast<size_type
>(
sizeof(
GetType<TRecordDim,
RecordCoord<RecordCoords...>>));
145 return {blob, elementOffset};
149 constexpr std::size_t flatFieldIndex =
150 #if defined(__NVCC__) && __CUDACC_VER_MAJOR__ == 11 && __CUDACC_VER_MINOR__ <= 6
153 Permuter::template permute<
flatRecordCoord<TRecordDim, RecordCoord<RecordCoords...>>>;
158 if constexpr(TArrayExtents::rankStatic == TArrayExtents::rank)
161 constexpr
auto subArrayOffsets = computeSubArrayOffsets();
162 return {0, subArrayOffsets[flatFieldIndex] + elementOffset};
169 size_type offset = 0;
170 mp_for_each_inline<mp_iota_c<flatFieldIndex>>(
173 constexpr
auto i = decltype(ic)::value;
174 using ThisFieldType = mp_at_c<FRD, i>;
175 offset +=
static_cast<size_type
>(
sizeof(ThisFieldType)) * flatSize;
176 using NextFieldType = mp_at_c<FRD, i + 1>;
177 offset =
roundUpToMultiple(offset,
static_cast<size_type
>(
alignof(NextFieldType)));
179 offset += elementOffset;
186 = elementOffset +
static_cast<size_type
>(flatOffsetOf<FRD, flatFieldIndex, false>) * flatSize;
195 template<
typename TArrayExtents,
typename TRecordDim>
201 template<
typename ArrayExtents,
typename RecordDim,
typename LinearizeArrayIndexFunctor = LinearizeArrayIndexRight>
208 template<
typename ArrayExtents,
typename RecordDim,
typename LinearizeArrayIndexFunctor = LinearizeArrayIndexRight>
215 template<
typename ArrayExtents,
typename RecordDim,
typename LinearizeArrayIndexFunctor = LinearizeArrayIndexRight>
228 template<
typename ArrayExtents,
typename RecordDim>
233 template<
typename Mapping>
234 inline constexpr
bool isSoA =
false;
242 typename LinearizeArrayIndexFunctor>
243 inline constexpr
bool isSoA<SoA<ArrayExtents, RecordDim, Blobs, SubArrayAlignment, LinearizeArrayIndexFunctor>>
#define LLAMA_LAMBDA_INLINE
Gives strong indication to the compiler to inline the attributed lambda.
#define LLAMA_CONSTEVAL
Expands to consteval if the compilers supports the keyword, otherwise to constexpr.
#define LLAMA_FN_HOST_ACC_INLINE
SoA(TArrayExtents, TRecordDim) -> SoA< TArrayExtents, TRecordDim >
typename internal::FlattenRecordDimImpl< RecordDim >::type FlatRecordDim
Returns a flat type list containing all leaf field types of the given record dimension.
ArrayExtents(Args...) -> ArrayExtents< typename internal::IndexTypeFromArgs< std::size_t, Args... >::type,(Args{}, dyn)... >
constexpr std::size_t flatRecordCoord
constexpr void mp_for_each_inline(F &&f)
Like boost::mp11::mp_for_each, but marked with LLAMA_FN_HOST_ACC_INLINE.
constexpr auto roundUpToMultiple(Integral n, Integral mult) -> Integral
Returns the integral n rounded up to be a multiple of mult.
typename internal::GetTypeImpl< RecordDim, RecordCoordOrTags... >::type GetType
typename ArrayExtents::value_type size_type
typename ArrayExtents::Index ArrayIndex
constexpr auto extents() const -> ArrayExtents
constexpr SoA(TArrayExtents extents, TRecordDim={})
TLinearizeArrayIndexFunctor LinearizeArrayIndexFunctor
static constexpr SubArrayAlignment subArrayAlignment
static constexpr std::size_t blobCount
constexpr auto blobSize([[maybe_unused]] size_type blobIndex) const -> size_type
constexpr auto blobNrAndOffset(typename Base::ArrayIndex ai, RecordCoord< RecordCoords... > rc={}) const -> NrAndOffset< size_type >
static constexpr Blobs blobs
constexpr auto blobNrAndOffset(size_type flatArrayIndex, RecordCoord< RecordCoords... >={}) const -> NrAndOffset< size_type >
PermuteFieldsSingleBlob< FlatRecordDim< TRecordDim > > Permuter