From 67292e0e51a901b72a397ff91cd25eb0a729b676 Mon Sep 17 00:00:00 2001 From: AntoinePrv Date: Wed, 13 May 2026 18:06:15 +0200 Subject: [PATCH 1/5] Fix linux CI and AVX512 --- .github/workflows/linux.yml | 6 +++--- include/xsimd/arch/xsimd_avx.hpp | 6 +++--- include/xsimd/arch/xsimd_avx512f.hpp | 4 ++-- include/xsimd/arch/xsimd_common_fwd.hpp | 4 ++++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 6fe7779a7..ed76832e7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -119,7 +119,7 @@ jobs: CMAKE_EXTRA_ARGS="$CMAKE_EXTRA_ARGS -DTARGET_ARCH=knm" fi if [[ '${{ matrix.sys.flags }}' == 'i386' ]]; then - CXX_FLAGS="$CXX_FLAGS -m32" + CXXFLAGS="$CXXFLAGS -m32" fi if [[ '${{ matrix.sys.flags }}' == 'force_no_instr_set' ]]; then : @@ -128,7 +128,7 @@ jobs: fi # Cheap way of spotting uninitialized read - CXX_FLAGS="$CXX_FLAGS -ftrivial-auto-var-init=pattern" + CXXFLAGS="$CXXFLAGS -ftrivial-auto-var-init=pattern" cmake -B _build \ -DBUILD_TESTS=ON \ @@ -138,7 +138,7 @@ jobs: -DCMAKE_C_COMPILER=$CC \ -DCMAKE_CXX_COMPILER=$CXX \ $CMAKE_EXTRA_ARGS \ - -DCMAKE_CXX_FLAGS='$CXX_FLAGS' \ + -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ -G Ninja - name: Build run: cmake --build _build diff --git a/include/xsimd/arch/xsimd_avx.hpp b/include/xsimd/arch/xsimd_avx.hpp index 84b1ba3a0..49bd12b90 100644 --- a/include/xsimd/arch/xsimd_avx.hpp +++ b/include/xsimd/arch/xsimd_avx.hpp @@ -1726,12 +1726,12 @@ namespace xsimd { return ssub(batch(s), batch(o)); }, self, other); } - else if (std::is_signed_v) + else if constexpr (std::is_signed_v) { - auto mask = (other >> (8 * sizeof(T) - 1)); + auto other_is_negative = other < batch(T(0)); auto self_overflow_branch = min(std::numeric_limits::max() + other, self); auto self_underflow_branch = max(std::numeric_limits::min() + other, self); - return select(batch_bool(mask.data), self_overflow_branch, self_underflow_branch) - other; + return select(other_is_negative, self_overflow_branch, self_underflow_branch) - other; } else { diff --git a/include/xsimd/arch/xsimd_avx512f.hpp b/include/xsimd/arch/xsimd_avx512f.hpp index 02934de8b..e5ab27813 100644 --- a/include/xsimd/arch/xsimd_avx512f.hpp +++ b/include/xsimd/arch/xsimd_avx512f.hpp @@ -1561,7 +1561,7 @@ namespace xsimd const uint32_t magic = (0x80 + 0x4000 + 0x200000 + 0x10000000); - unsigned char res = ((data * magic) >> 24) & 0xFF; + unsigned char res = (data * magic) >> 28; return res; } else if constexpr (N == 2) @@ -1571,7 +1571,7 @@ namespace xsimd const uint16_t magic = (0x80 + 0x4000); - unsigned char res = ((data * magic) >> 8) & 0xFF; + unsigned char res = (data * magic) >> 14; return res; } } diff --git a/include/xsimd/arch/xsimd_common_fwd.hpp b/include/xsimd/arch/xsimd_common_fwd.hpp index b247b2bd6..139b0b282 100644 --- a/include/xsimd/arch/xsimd_common_fwd.hpp +++ b/include/xsimd/arch/xsimd_common_fwd.hpp @@ -60,6 +60,10 @@ namespace xsimd XSIMD_INLINE batch bitwise_rshift(batch const& self, batch const& other, requires_arch) noexcept; template >> XSIMD_INLINE batch bitwise_rshift(batch const& self, requires_arch) noexcept; + template + XSIMD_INLINE batch decr_if(batch const& self, Mask const& mask, requires_arch) noexcept; + template + XSIMD_INLINE batch incr_if(batch const& self, Mask const& mask, requires_arch) noexcept; template XSIMD_INLINE batch_bool gt(batch const& self, batch const& other, requires_arch) noexcept; template >> From c617425a2d63e07af3947e842a67faabce11d2b6 Mon Sep 17 00:00:00 2001 From: AntoinePrv Date: Mon, 14 Sep 2026 12:22:37 +0200 Subject: [PATCH 2/5] Remove benchmark builds --- .github/workflows/linux.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index ed76832e7..447579c14 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -132,7 +132,6 @@ jobs: cmake -B _build \ -DBUILD_TESTS=ON \ - -DBUILD_BENCHMARK=ON \ -DBUILD_EXAMPLES=ON \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=$CC \ From a9d313aa85fca4174ad56419befdc86fbffc2558 Mon Sep 17 00:00:00 2001 From: AntoinePrv Date: Mon, 14 Sep 2026 12:58:34 +0200 Subject: [PATCH 3/5] Only use hardening when available --- .github/workflows/linux.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 447579c14..2aad122ed 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -128,7 +128,9 @@ jobs: fi # Cheap way of spotting uninitialized read - CXXFLAGS="$CXXFLAGS -ftrivial-auto-var-init=pattern" + if echo 'int main(){}' | $CXX -x c++ -ftrivial-auto-var-init=pattern -fsyntax-only - 2>/dev/null; then + CXXFLAGS="$CXXFLAGS -ftrivial-auto-var-init=pattern" + fi cmake -B _build \ -DBUILD_TESTS=ON \ From 9905ad5535ec16dff362fca96af4eb752355cbe6 Mon Sep 17 00:00:00 2001 From: AntoinePrv Date: Mon, 14 Sep 2026 14:00:54 +0200 Subject: [PATCH 4/5] Separate architecture tests --- .github/workflows/linux.yml | 30 ++++++++++++++++++++++++++++++ test/CMakeLists.txt | 5 ++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2aad122ed..2eb52de7e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -162,3 +162,33 @@ jobs: export XSIMD_TEST_CPU_ASSUME_MANUFACTURER="intel,amd" ./test_xsimd fi + + build-extra: + runs-on: ubuntu-latest + name: 'clang 18 - architectures and benchmark' + steps: + - name: Setup compiler + run: | + sudo apt-get update || exit 1 + sudo apt-get --no-install-suggests --no-install-recommends install clang-18 || exit 1 + echo "CC=clang-18" >> $GITHUB_ENV + echo "CXX=clang++-18" >> $GITHUB_ENV + - name: Checkout xsimd + uses: actions/checkout@v6 + - name: Install mamba + uses: mamba-org/setup-micromamba@v2 + with: + environment-file: environment.yml + - name: Configure build + run: | + cmake -B _build \ + -DBUILD_TESTS=ON \ + -DBUILD_ARCHITECTURE_TESTS=ON \ + -DBUILD_BENCHMARK=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DXSIMD_ENABLE_WERROR=ON \ + -G Ninja + - name: Build + run: cmake --build _build diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 003d31201..217243f0f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -218,7 +218,10 @@ if (XSIMD_ENABLE_WERROR) endif() add_subdirectory(doc) -add_subdirectory(architectures) +OPTION(BUILD_ARCHITECTURE_TESTS "xsimd compilation tests for various -march targets" OFF) +if(BUILD_ARCHITECTURE_TESTS) + add_subdirectory(architectures) +endif() if(EMULATED_COMPILE_FLAGS) message(STATUS ${EMULATED_COMPILE_FLAGS}) From fa9cd5700816557333a8fe0b7890ace89605a9aa Mon Sep 17 00:00:00 2001 From: AntoinePrv Date: Tue, 15 Sep 2026 09:52:55 +0200 Subject: [PATCH 5/5] Default to building architectures --- .github/workflows/linux.yml | 1 + test/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2eb52de7e..0940742df 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -135,6 +135,7 @@ jobs: cmake -B _build \ -DBUILD_TESTS=ON \ -DBUILD_EXAMPLES=ON \ + -DBUILD_ARCHITECTURE_TESTS=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=$CC \ -DCMAKE_CXX_COMPILER=$CXX \ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 217243f0f..fca96de7f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -218,7 +218,7 @@ if (XSIMD_ENABLE_WERROR) endif() add_subdirectory(doc) -OPTION(BUILD_ARCHITECTURE_TESTS "xsimd compilation tests for various -march targets" OFF) +OPTION(BUILD_ARCHITECTURE_TESTS "xsimd compilation tests for various -march targets" ON) if(BUILD_ARCHITECTURE_TESTS) add_subdirectory(architectures) endif()