Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
GH-49921: [C++] Bump xsimd to 14.2.0#49922
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
c35115bafc248adfd89d60009cdf9f19a95d44c5b3312ec583f697f022ffada8278222c1cad43File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -47,6 +47,6 @@ rapidjson | ||
| re2 | ||
| snappy | ||
| thrift-cpp>=0.11.0 | ||
| xsimd>=14.0 | ||
| xsimd>=14.2 | ||
| zlib | ||
| zstd | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -151,73 +151,6 @@ constexpr bool IsSse2 = std::is_base_of_v<xsimd::sse2, Arch>; | ||
| template <typename Arch> | ||
| constexpr bool IsAvx2 = std::is_base_of_v<xsimd::avx2, Arch>; | ||
| /// Whether we are compiling for the Neon or above in the arm64 family. | ||
| template <typename Arch> | ||
| constexpr bool IsNeon = std::is_base_of_v<xsimd::neon, Arch>; | ||
| /// Wrapper around ``xsimd::bitwise_lshift`` with optimizations for non implemented sizes. | ||
| /// | ||
| /// We replace the variable left shift by a variable multiply with a power of two. | ||
| /// | ||
| /// This trick is borrowed from Daniel Lemire and Leonid Boytsov, Decoding billions of | ||
| /// integers per second through vectorization, Software Practice & Experience 45 (1), | ||
| /// 2015. http://arxiv.org/abs/1209.2137 | ||
| /// | ||
| /// TODO(xsimd) Tracking in https://github.com/xtensor-stack/xsimd/pull/1220 | ||
| /// When migrating, be sure to use batch_constant overload, and not the batch one. | ||
| template <typename Arch, typename Int, Int... kShifts> | ||
| ARROW_FORCE_INLINE auto left_shift(const xsimd::batch<Int, Arch>& batch, | ||
| xsimd::batch_constant<Int, Arch, kShifts...> shifts) | ||
| -> xsimd::batch<Int, Arch> { | ||
| constexpr bool kIsSse2 = IsSse2<Arch>; | ||
| constexpr bool kIsAvx2 = IsAvx2<Arch>; | ||
| static_assert( | ||
| !(kIsSse2 && kIsAvx2), | ||
| "In xsimd, an x86 arch is either part of the SSE family or of the AVX family," | ||
| "not both. If this check fails, it means the assumptions made here to detect SSE " | ||
| "and AVX are out of date."); | ||
| constexpr auto kMults = xsimd::make_batch_constant<Int, 1, Arch>() << shifts; | ||
| constexpr auto IntSize = sizeof(Int); | ||
| // Sizes and architecture for which there is no variable left shift and there is a | ||
| // multiplication | ||
| if constexpr ( // | ||
| (kIsSse2 && (IntSize == sizeof(uint16_t) || IntSize == sizeof(uint32_t))) // | ||
| || (kIsAvx2 && (IntSize == sizeof(uint16_t))) // | ||
| ) { | ||
| return batch * kMults; | ||
| } | ||
| // Architecture for which there is no variable left shift on uint8_t but a fallback | ||
| // exists for uint16_t. | ||
| if constexpr ((kIsSse2 || kIsAvx2) && (IntSize == sizeof(uint8_t))) { | ||
| const auto batch16 = xsimd::bitwise_cast<uint16_t>(batch); | ||
| constexpr auto kShifts0 = select_stride<uint16_t, 0>(shifts); | ||
| const auto shifted0 = left_shift(batch16, kShifts0) & 0x00FF; | ||
| constexpr auto kShifts1 = select_stride<uint16_t, 1>(shifts); | ||
| const auto shifted1 = left_shift(batch16 & 0xFF00, kShifts1); | ||
| return xsimd::bitwise_cast<Int>(shifted0 | shifted1); | ||
| } | ||
| // TODO(xsimd) bug fixed in xsimd 14.1.0 | ||
| // https://github.com/xtensor-stack/xsimd/pull/1266 | ||
| #if XSIMD_VERSION_MAJOR < 14 || ((XSIMD_VERSION_MAJOR == 14) && XSIMD_VERSION_MINOR == 0) | ||
| if constexpr (IsNeon<Arch>) { | ||
| using SInt = std::make_signed_t<Int>; | ||
| constexpr auto signed_shifts = | ||
| xsimd::batch_constant<SInt, Arch, static_cast<SInt>(kShifts)...>(); | ||
| return xsimd::kernel::bitwise_lshift(batch, signed_shifts.as_batch(), Arch{}); | ||
| } | ||
| #endif | ||
| return batch << shifts; | ||
| } | ||
| /// Fallback for variable shift right. | ||
| /// | ||
| /// When we know that the relevant bits will not overflow, we can instead shift left all | ||
| @@ -243,9 +176,8 @@ ARROW_FORCE_INLINE auto right_shift_by_excess( | ||
| constexpr auto IntSize = sizeof(Int); | ||
| // Architecture for which there is no variable right shift but a larger fallback exists. | ||
| // TODO(xsimd) Tracking for Avx2 in https://github.com/xtensor-stack/xsimd/pull/1220 | ||
| // When migrating, be sure to use batch_constant overload, and not the batch one. | ||
| // Architectures for which there is no variable right shift but a larger fallback | ||
| // exists. | ||
| if constexpr (kIsAvx2 && (IntSize == sizeof(uint8_t) || IntSize == sizeof(uint16_t))) { | ||
| using twice_uint = SizedUint<2 * IntSize>; | ||
| @@ -262,27 +194,17 @@ ARROW_FORCE_INLINE auto right_shift_by_excess( | ||
| return xsimd::bitwise_cast<Int>(shifted0 | shifted1); | ||
| } | ||
| // These conditions are the ones matched in `left_shift`, i.e. the ones where variable | ||
| // shift right will not be available but a left shift (fallback) exists. | ||
| // Architectures for which there is no variable right shift but a left shift exists | ||
| // (possibly using the multiply trick inside of xsimd). | ||
| // We use a variable left shift and fixed right shift. | ||
| if constexpr (kIsSse2 && (IntSize != sizeof(uint64_t))) { | ||
AntoinePrv marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| constexpr Int kMaxRShift = max_value(std::array{kShifts...}); | ||
| constexpr auto kLShifts = | ||
| xsimd::make_batch_constant<Int, kMaxRShift, Arch>() - shifts; | ||
| return xsimd::bitwise_rshift<kMaxRShift>(left_shift(batch, kLShifts)); | ||
| } | ||
| // TODO(xsimd) bug fixed in xsimd 14.1.0 | ||
| // https://github.com/xtensor-stack/xsimd/pull/1266 | ||
| #if XSIMD_VERSION_MAJOR < 14 || ((XSIMD_VERSION_MAJOR == 14) && XSIMD_VERSION_MINOR == 0) | ||
| if constexpr (IsNeon<Arch>) { | ||
| using SInt = std::make_signed_t<Int>; | ||
| constexpr auto signed_shifts = | ||
| xsimd::batch_constant<SInt, Arch, static_cast<SInt>(kShifts)...>(); | ||
| return xsimd::kernel::bitwise_rshift(batch, signed_shifts.as_batch(), Arch{}); | ||
| return xsimd::bitwise_rshift<kMaxRShift>(batch << kLShifts); | ||
| } | ||
Comment on lines
200
to
207
Comment on lines
200
to
207
AntoinePrv marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| #endif | ||
| return batch >> shifts; | ||
| } | ||
| @@ -1040,7 +962,7 @@ struct LargeKernel { | ||
| const auto high_swizzled = xsimd::swizzle(bytes, kHighSwizzles); | ||
| const auto high_words = xsimd::bitwise_cast<unpacked_type>(high_swizzled); | ||
| const auto high_shifted = left_shift(high_words, kHighLShifts); | ||
| const auto high_shifted = high_words << kHighLShifts; | ||
AntoinePrv marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // We can have a single mask and apply it after OR because the shifts will ensure that | ||
| // there are zeros where the high/low values are incomplete. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.