Skip to content

Commit a10f254

Browse files
authored
GH-49921: [C++] Bump xsimd to 14.2.0 (#49922)
### Rationale for this change - Fix for the current SVE ODR violation in the latest version xtensor-stack/xsimd#1311 - Pre-requisit to GH-45331 ### What changes are included in this PR? Bump version and cleanup backports. ### Are these changes tested? Yes, in CI. ### Are there any user-facing changes? No * GitHub Issue: #49921 Authored-by: AntoinePrv <AntoinePrv@users.noreply.github.com> Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
1 parent 7bddb83 commit a10f254

6 files changed

Lines changed: 13 additions & 91 deletions

File tree

c_glib/vcpkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"pkgconf"
88
],
99
"$comment": "We can update builtin-baseline by 'vcpkg x-update-baseline'",
10-
"builtin-baseline": "40c89449f0ccce12d21f8a906639f6c2c649b9e7"
10+
"builtin-baseline": "9b965a116838c6cdcd36bca60d1b81b030c8ab8d"
1111
}

ci/conda_env_cpp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ rapidjson
4747
re2
4848
snappy
4949
thrift-cpp>=0.11.0
50-
xsimd>=14.0
50+
xsimd>=14.2
5151
zlib
5252
zstd

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2858,7 +2858,7 @@ if(ARROW_USE_XSIMD)
28582858
IS_RUNTIME_DEPENDENCY
28592859
FALSE
28602860
REQUIRED_VERSION
2861-
"14.0.0")
2861+
"14.2.0")
28622862

28632863
if(xsimd_SOURCE STREQUAL "BUNDLED")
28642864
set(ARROW_XSIMD arrow::xsimd)

cpp/src/arrow/util/bpacking_simd_kernel_internal.h

Lines changed: 7 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -151,73 +151,6 @@ constexpr bool IsSse2 = std::is_base_of_v<xsimd::sse2, Arch>;
151151
template <typename Arch>
152152
constexpr bool IsAvx2 = std::is_base_of_v<xsimd::avx2, Arch>;
153153

154-
/// Whether we are compiling for the Neon or above in the arm64 family.
155-
template <typename Arch>
156-
constexpr bool IsNeon = std::is_base_of_v<xsimd::neon, Arch>;
157-
158-
/// Wrapper around ``xsimd::bitwise_lshift`` with optimizations for non implemented sizes.
159-
///
160-
/// We replace the variable left shift by a variable multiply with a power of two.
161-
///
162-
/// This trick is borrowed from Daniel Lemire and Leonid Boytsov, Decoding billions of
163-
/// integers per second through vectorization, Software Practice & Experience 45 (1),
164-
/// 2015. http://arxiv.org/abs/1209.2137
165-
///
166-
/// TODO(xsimd) Tracking in https://github.com/xtensor-stack/xsimd/pull/1220
167-
/// When migrating, be sure to use batch_constant overload, and not the batch one.
168-
template <typename Arch, typename Int, Int... kShifts>
169-
ARROW_FORCE_INLINE auto left_shift(const xsimd::batch<Int, Arch>& batch,
170-
xsimd::batch_constant<Int, Arch, kShifts...> shifts)
171-
-> xsimd::batch<Int, Arch> {
172-
constexpr bool kIsSse2 = IsSse2<Arch>;
173-
constexpr bool kIsAvx2 = IsAvx2<Arch>;
174-
static_assert(
175-
!(kIsSse2 && kIsAvx2),
176-
"In xsimd, an x86 arch is either part of the SSE family or of the AVX family,"
177-
"not both. If this check fails, it means the assumptions made here to detect SSE "
178-
"and AVX are out of date.");
179-
180-
constexpr auto kMults = xsimd::make_batch_constant<Int, 1, Arch>() << shifts;
181-
182-
constexpr auto IntSize = sizeof(Int);
183-
184-
// Sizes and architecture for which there is no variable left shift and there is a
185-
// multiplication
186-
if constexpr ( //
187-
(kIsSse2 && (IntSize == sizeof(uint16_t) || IntSize == sizeof(uint32_t))) //
188-
|| (kIsAvx2 && (IntSize == sizeof(uint16_t))) //
189-
) {
190-
return batch * kMults;
191-
}
192-
193-
// Architecture for which there is no variable left shift on uint8_t but a fallback
194-
// exists for uint16_t.
195-
if constexpr ((kIsSse2 || kIsAvx2) && (IntSize == sizeof(uint8_t))) {
196-
const auto batch16 = xsimd::bitwise_cast<uint16_t>(batch);
197-
198-
constexpr auto kShifts0 = select_stride<uint16_t, 0>(shifts);
199-
const auto shifted0 = left_shift(batch16, kShifts0) & 0x00FF;
200-
201-
constexpr auto kShifts1 = select_stride<uint16_t, 1>(shifts);
202-
const auto shifted1 = left_shift(batch16 & 0xFF00, kShifts1);
203-
204-
return xsimd::bitwise_cast<Int>(shifted0 | shifted1);
205-
}
206-
207-
// TODO(xsimd) bug fixed in xsimd 14.1.0
208-
// https://github.com/xtensor-stack/xsimd/pull/1266
209-
#if XSIMD_VERSION_MAJOR < 14 || ((XSIMD_VERSION_MAJOR == 14) && XSIMD_VERSION_MINOR == 0)
210-
if constexpr (IsNeon<Arch>) {
211-
using SInt = std::make_signed_t<Int>;
212-
constexpr auto signed_shifts =
213-
xsimd::batch_constant<SInt, Arch, static_cast<SInt>(kShifts)...>();
214-
return xsimd::kernel::bitwise_lshift(batch, signed_shifts.as_batch(), Arch{});
215-
}
216-
#endif
217-
218-
return batch << shifts;
219-
}
220-
221154
/// Fallback for variable shift right.
222155
///
223156
/// 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(
243176

244177
constexpr auto IntSize = sizeof(Int);
245178

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

@@ -262,27 +194,17 @@ ARROW_FORCE_INLINE auto right_shift_by_excess(
262194
return xsimd::bitwise_cast<Int>(shifted0 | shifted1);
263195
}
264196

265-
// These conditions are the ones matched in `left_shift`, i.e. the ones where variable
266-
// shift right will not be available but a left shift (fallback) exists.
197+
// Architectures for which there is no variable right shift but a left shift exists
198+
// (possibly using the multiply trick inside of xsimd).
199+
// We use a variable left shift and fixed right shift.
267200
if constexpr (kIsSse2 && (IntSize != sizeof(uint64_t))) {
268201
constexpr Int kMaxRShift = max_value(std::array{kShifts...});
269202

270203
constexpr auto kLShifts =
271204
xsimd::make_batch_constant<Int, kMaxRShift, Arch>() - shifts;
272205

273-
return xsimd::bitwise_rshift<kMaxRShift>(left_shift(batch, kLShifts));
274-
}
275-
276-
// TODO(xsimd) bug fixed in xsimd 14.1.0
277-
// https://github.com/xtensor-stack/xsimd/pull/1266
278-
#if XSIMD_VERSION_MAJOR < 14 || ((XSIMD_VERSION_MAJOR == 14) && XSIMD_VERSION_MINOR == 0)
279-
if constexpr (IsNeon<Arch>) {
280-
using SInt = std::make_signed_t<Int>;
281-
constexpr auto signed_shifts =
282-
xsimd::batch_constant<SInt, Arch, static_cast<SInt>(kShifts)...>();
283-
return xsimd::kernel::bitwise_rshift(batch, signed_shifts.as_batch(), Arch{});
206+
return xsimd::bitwise_rshift<kMaxRShift>(batch << kLShifts);
284207
}
285-
#endif
286208

287209
return batch >> shifts;
288210
}
@@ -1040,7 +962,7 @@ struct LargeKernel {
1040962

1041963
const auto high_swizzled = xsimd::swizzle(bytes, kHighSwizzles);
1042964
const auto high_words = xsimd::bitwise_cast<unpacked_type>(high_swizzled);
1043-
const auto high_shifted = left_shift(high_words, kHighLShifts);
965+
const auto high_shifted = high_words << kHighLShifts;
1044966

1045967
// We can have a single mask and apply it after OR because the shifts will ensure that
1046968
// there are zeros where the high/low values are incomplete.

cpp/thirdparty/versions.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ ARROW_UTF8PROC_BUILD_SHA256_CHECKSUM=6f4f1b639daa6dca9f80bc5db1233e9cbaa31a67790
115115
# WIL (Windows Implementation Libraries) is required by Azure SDK on Windows for WinHTTP transport
116116
ARROW_WIL_BUILD_VERSION=v1.0.250325.1
117117
ARROW_WIL_BUILD_SHA256_CHECKSUM=c9e667d5f86ded43d17b5669d243e95ca7b437e3a167c170805ffd4aa8a9a786
118-
ARROW_XSIMD_BUILD_VERSION=14.0.0
119-
ARROW_XSIMD_BUILD_SHA256_CHECKSUM=17de0236954955c10c09d6938d4c5f3a3b92d31be5dadd1d5d09fc1b15490dce
118+
ARROW_XSIMD_BUILD_VERSION=14.2.0
119+
ARROW_XSIMD_BUILD_SHA256_CHECKSUM=21e841ab684b05331e81e7f782431753a029ef7b7d9d6d3ddab837e7782a40ee
120120
ARROW_ZLIB_BUILD_VERSION=1.3.1
121121
ARROW_ZLIB_BUILD_SHA256_CHECKSUM=9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23
122122
ARROW_ZSTD_BUILD_VERSION=1.5.7

cpp/vcpkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@
5757
"zstd"
5858
],
5959
"$comment": "We can update builtin-baseline by 'vcpkg x-update-baseline'",
60-
"builtin-baseline": "40c89449f0ccce12d21f8a906639f6c2c649b9e7"
60+
"builtin-baseline": "9b965a116838c6cdcd36bca60d1b81b030c8ab8d"
6161
}

0 commit comments

Comments
 (0)