Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix simd::gatherBits for Mac M1 or when AVX2 is disabled #8415

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions velox/common/base/SimdUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void gatherBits(
const uint64_t* bits,
folly::Range<const int32_t*> indexRange,
uint64_t* result) {
constexpr int32_t kStep = xsimd::batch<int32_t>::size;
auto size = indexRange.size();
auto indices = indexRange.data();
uint8_t* resultPtr = reinterpret_cast<uint8_t*>(result);
Expand All @@ -36,14 +37,16 @@ void gatherBits(
return;
}
int32_t i = 0;
for (; i + 8 < size; i += 8) {
*(resultPtr++) =
simd::gather8Bits(bits, xsimd::load_unaligned(indices + i), 8);
for (; i + kStep < size; i += kStep) {
uint16_t flags =
simd::gather8Bits(bits, xsimd::load_unaligned(indices + i), kStep);
bits::storeBitsToByte<kStep>(flags, resultPtr, i);
}
auto bitsLeft = size - i;
if (bitsLeft > 0) {
*resultPtr =
uint16_t flags =
simd::gather8Bits(bits, xsimd::load_unaligned(indices + i), bitsLeft);
bits::storeBitsToByte<kStep>(flags, resultPtr, i);
}
}

Expand Down
Loading