Skip to content

Commit

Permalink
fix: Added non-avx path for index transposing (#12087)
Browse files Browse the repository at this point in the history
Summary:

This diff creates a different transposeIndex path if XSIMD_WITH_AVX2 is not present. Previously it was simply not supported.

Differential Revision: D67659247
  • Loading branch information
Jialiang Tan authored and facebook-github-bot committed Jan 14, 2025
1 parent 5c770df commit 67a66d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 0 additions & 4 deletions velox/exec/tests/OperatorUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,6 @@ TEST_F(OperatorUtilsTest, outputBatchRows) {
}

TEST_F(OperatorUtilsTest, wrapMany) {
#if !XSIMD_WITH_AVX2
GTEST_SKIP();
#endif

// Creates a RowVector with nullable and non-null vectors sharing
// different dictionary wraps. Rewraps these with a new wrap with
// and without nulls. Checks that the outcome has a single level of
Expand Down
23 changes: 19 additions & 4 deletions velox/vector/BaseVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,6 @@ void BaseVector::transposeIndices(
const vector_size_t* wrapIndices,
vector_size_t* resultIndices) {
#if XSIMD_WITH_AVX2

constexpr int32_t kBatch = xsimd::batch<int32_t>::size;
static_assert(kBatch == 8);
static_assert(sizeof(vector_size_t) == sizeof(int32_t));
Expand All @@ -1021,7 +1020,9 @@ void BaseVector::transposeIndices(
.store_unaligned(resultIndices + i);
}
#else
VELOX_NYI();
for (auto i = 0; i < wrapSize; ++i) {
resultIndices[i] = baseIndices[wrapIndices[i]];
}
#endif
}

Expand All @@ -1035,7 +1036,6 @@ void BaseVector::transposeIndicesWithNulls(
vector_size_t* resultIndices,
uint64_t* resultNulls) {
#if XSIMD_WITH_AVX2

constexpr int32_t kBatch = xsimd::batch<int32_t>::size;
static_assert(kBatch == 8);
static_assert(sizeof(vector_size_t) == sizeof(int32_t));
Expand All @@ -1061,7 +1061,22 @@ void BaseVector::transposeIndicesWithNulls(
.store_unaligned(resultIndices + i);
}
#else
VELOX_NYI();
for (auto i = 0; i < wrapSize; ++i) {
auto index = wrapIndices[i];
bool wrapIsNull = wrapNulls && bits::isBitNull(wrapNulls, i);
if (wrapIsNull) {
bits::setNull(resultNulls, i, true);
continue;
}
if (baseNulls) {
if (bits::isBitNull(baseNulls, index)) {
bits::setNull(resultNulls, i, true);
continue;
}
bits::clearNull(resultNulls, i);
resultIndices[i] = baseIndices[index];
}
}
#endif
}

Expand Down

0 comments on commit 67a66d3

Please sign in to comment.