Skip to content

Commit

Permalink
Simplify SoA implementation a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed May 4, 2023
1 parent d596a6e commit dbd8aa5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions include/llama/mapping/SoA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace llama::mapping
typename Base::ArrayIndex ai,
RecordCoord<RecordCoords...> = {}) const -> NrAndOffset<size_type>
{
const auto elementOffset = LinearizeArrayDimsFunctor{}(ai, Base::extents())
const size_type elementOffset = LinearizeArrayDimsFunctor{}(ai, Base::extents())
* static_cast<size_type>(sizeof(GetType<TRecordDim, RecordCoord<RecordCoords...>>));
if constexpr(blobs == Blobs::OnePerField)
{
Expand All @@ -139,17 +139,15 @@ namespace llama::mapping
*& // mess with nvcc compiler state to workaround bug
#endif
Flattener::template flatIndex<RecordCoords...>;
const auto flatSize = LinearizeArrayDimsFunctor{}.size(Base::extents());
const size_type flatSize = LinearizeArrayDimsFunctor{}.size(Base::extents());
using FRD = typename Flattener::FlatRecordDim;
if constexpr(subArrayAlignment == SubArrayAlignment::Align)
{
if constexpr(TArrayExtents::rankStatic == TArrayExtents::rank)
{
// full array extents are known statically, we can precompute the sub array offsets
constexpr auto subArrayOffsets = computeSubArrayOffsets();
size_type offset = subArrayOffsets[flatFieldIndex];
offset += elementOffset;
return {0, offset};
return {0, subArrayOffsets[flatFieldIndex] + elementOffset};
}
else
{
Expand Down

0 comments on commit dbd8aa5

Please sign in to comment.