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 729d1ea commit e698d3f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/llama/Simd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,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 @@ -339,6 +342,9 @@ namespace llama
// structured Simd type and record reference
if constexpr(isRecordRef<Simd> && isRecordRef<T>)
{
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); });
}
Expand Down

0 comments on commit e698d3f

Please sign in to comment.