-
Notifications
You must be signed in to change notification settings - Fork 4.1k
GH-49579: [C++] Fix xsimd 14.1.0 build failure #49580
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -153,14 +153,15 @@ 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 | ||||||
| // | ||||||
| /// | ||||||
| /// 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> | ||||||
| auto left_shift(const xsimd::batch<Int, Arch>& batch, | ||||||
| xsimd::batch_constant<Int, Arch, kShifts...> shifts) | ||||||
|
|
@@ -200,14 +201,16 @@ auto left_shift(const xsimd::batch<Int, Arch>& batch, | |||||
| return xsimd::bitwise_cast<Int>(shifted0 | shifted1); | ||||||
| } | ||||||
|
|
||||||
| // TODO(xsimd) bug fixed likely in xsimd>14.0.0 | ||||||
| // 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; | ||||||
| } | ||||||
|
|
@@ -237,7 +240,8 @@ auto right_shift_by_excess(const xsimd::batch<Int, Arch>& batch, | |||||
| 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 | ||||||
| // TODO(xsimd) Tracking for Avx2 in https://github.com/xtensor-stack/xsimd/pull/1220 | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that the PR is also merged. Do we need
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still need to keep it because some builds use a version of xsimd that does not yet have the fix.
Contrary to the fix in this PR, in this case the back-ported fix also works with newer xsimd versions, so we don't really need to. |
||||||
| // When migrating, be sure to use batch_constant overload, and not the batch one. | ||||||
| if constexpr (kIsAvx2 && (IntSize == sizeof(uint8_t) || IntSize == sizeof(uint16_t))) { | ||||||
| using twice_uint = SizedUint<2 * IntSize>; | ||||||
|
|
||||||
|
|
@@ -265,14 +269,16 @@ auto right_shift_by_excess(const xsimd::batch<Int, Arch>& batch, | |||||
| return xsimd::bitwise_rshift<kMaxRShift>(left_shift(batch, kLShifts)); | ||||||
| } | ||||||
|
|
||||||
| // TODO(xsimd) bug fixed likely in xsimd>14.0.0 | ||||||
| // TODO(xsimd) bug fixed in xsimd 14.1.0 | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO we keep the TODO until (hopefully sooner rather than later) we bump again the minimum version of xsimd and delete that piece of code. |
||||||
| // 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{}); | ||||||
| } | ||||||
| #endif | ||||||
|
|
||||||
| return batch >> shifts; | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove
TODObecause the bug was fixed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave the TODO as this points to code to remove in the future.