Skip to content

Commit a242f77

Browse files
committed
Allow xsimd 14.1.0
1 parent ba273ca commit a242f77

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

cpp/src/arrow/util/bpacking_simd_kernel_internal.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,15 @@ template <typename Arch>
153153
constexpr bool IsNeon = std::is_base_of_v<xsimd::neon, Arch>;
154154

155155
/// Wrapper around ``xsimd::bitwise_lshift`` with optimizations for non implemented sizes.
156-
//
157-
// We replace the variable left shift by a variable multiply with a power of two.
158-
//
159-
// This trick is borrowed from Daniel Lemire and Leonid Boytsov, Decoding billions of
160-
// integers per second through vectorization, Software Practice & Experience 45 (1), 2015.
161-
// http://arxiv.org/abs/1209.2137
162-
//
156+
///
157+
/// We replace the variable left shift by a variable multiply with a power of two.
158+
///
159+
/// This trick is borrowed from Daniel Lemire and Leonid Boytsov, Decoding billions of
160+
/// integers per second through vectorization, Software Practice & Experience 45 (1),
161+
/// 2015. http://arxiv.org/abs/1209.2137
162+
///
163163
/// TODO(xsimd) Tracking in https://github.com/xtensor-stack/xsimd/pull/1220
164+
/// When migrating, be sure to use batch_constant overload, and not the batch one.
164165
template <typename Arch, typename Int, Int... kShifts>
165166
auto left_shift(const xsimd::batch<Int, Arch>& batch,
166167
xsimd::batch_constant<Int, Arch, kShifts...> shifts)
@@ -200,14 +201,16 @@ auto left_shift(const xsimd::batch<Int, Arch>& batch,
200201
return xsimd::bitwise_cast<Int>(shifted0 | shifted1);
201202
}
202203

203-
// TODO(xsimd) bug fixed likely in xsimd>14.0.0
204+
// TODO(xsimd) bug fixed in xsimd 14.1.0
204205
// https://github.com/xtensor-stack/xsimd/pull/1266
206+
#if XSIMD_VERSION_MAJOR < 14 || ((XSIMD_VERSION_MAJOR == 14) && XSIMD_VERSION_MINOR == 0)
205207
if constexpr (IsNeon<Arch>) {
206208
using SInt = std::make_signed_t<Int>;
207209
constexpr auto signed_shifts =
208210
xsimd::batch_constant<SInt, Arch, static_cast<SInt>(kShifts)...>();
209211
return xsimd::kernel::bitwise_lshift(batch, signed_shifts.as_batch(), Arch{});
210212
}
213+
#endif
211214

212215
return batch << shifts;
213216
}
@@ -237,7 +240,8 @@ auto right_shift_by_excess(const xsimd::batch<Int, Arch>& batch,
237240
constexpr auto IntSize = sizeof(Int);
238241

239242
// Architecture for which there is no variable right shift but a larger fallback exists.
240-
/// TODO(xsimd) Tracking for Avx2 in https://github.com/xtensor-stack/xsimd/pull/1220
243+
// TODO(xsimd) Tracking for Avx2 in https://github.com/xtensor-stack/xsimd/pull/1220
244+
// When migrating, be sure to use batch_constant overload, and not the batch one.
241245
if constexpr (kIsAvx2 && (IntSize == sizeof(uint8_t) || IntSize == sizeof(uint16_t))) {
242246
using twice_uint = SizedUint<2 * IntSize>;
243247

@@ -265,14 +269,16 @@ auto right_shift_by_excess(const xsimd::batch<Int, Arch>& batch,
265269
return xsimd::bitwise_rshift<kMaxRShift>(left_shift(batch, kLShifts));
266270
}
267271

268-
// TODO(xsimd) bug fixed likely in xsimd>14.0.0
272+
// TODO(xsimd) bug fixed in xsimd 14.1.0
269273
// https://github.com/xtensor-stack/xsimd/pull/1266
274+
#if XSIMD_VERSION_MAJOR < 14 || ((XSIMD_VERSION_MAJOR == 14) && XSIMD_VERSION_MINOR == 0)
270275
if constexpr (IsNeon<Arch>) {
271276
using SInt = std::make_signed_t<Int>;
272277
constexpr auto signed_shifts =
273278
xsimd::batch_constant<SInt, Arch, static_cast<SInt>(kShifts)...>();
274279
return xsimd::kernel::bitwise_rshift(batch, signed_shifts.as_batch(), Arch{});
275280
}
281+
#endif
276282

277283
return batch >> shifts;
278284
}

0 commit comments

Comments
 (0)