Skip to content

Commit

Permalink
Add fastpath for loading/storing SimdN<T, 1, ...>
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed Jan 2, 2024
1 parent 82ab735 commit 40c07af
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions include/llama/Simd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,11 @@ namespace llama
// structured dstSimd type and record reference
if constexpr(isRecordRef<Simd> && isRecordRef<T>)
{
forEachLeafCoord<typename Simd::AccessibleRecordDim>([&](auto rc) LLAMA_LAMBDA_INLINE
{ internal::loadSimdFromField(srcRef, dstSimd, rc); });
if constexpr(simdLanes<Simd> == simdLanes<T>) // fast path mainly for scalar SimdN<T, 1, ...>
dstSimd = srcRef;
else
forEachLeafCoord<typename Simd::AccessibleRecordDim>(
[&](auto rc) LLAMA_LAMBDA_INLINE { internal::loadSimdFromField(srcRef, dstSimd, rc); });
}
// unstructured dstSimd and reference type
else if constexpr(!isRecordRef<Simd> && !isRecordRef<T>)
Expand All @@ -340,8 +343,11 @@ namespace llama
// structured Simd type and record reference
if constexpr(isRecordRef<Simd> && isRecordRef<T>)
{
forEachLeafCoord<typename T::AccessibleRecordDim>([&](auto rc) LLAMA_LAMBDA_INLINE
{ internal::storeSimdToField(srcSimd, dstRef, rc); });
if constexpr(simdLanes<Simd> == simdLanes<T>) // fast path mainly for scalar SimdN<T, 1, ...>
dstRef = srcSimd;
else
forEachLeafCoord<typename T::AccessibleRecordDim>(
[&](auto rc) LLAMA_LAMBDA_INLINE { internal::storeSimdToField(srcSimd, dstRef, rc); });
}
// unstructured srcSimd and reference type
else if constexpr(!isRecordRef<Simd> && !isRecordRef<T>)
Expand Down

0 comments on commit 40c07af

Please sign in to comment.