wide 1.6.1

A crate to help you go wide.
Documentation
name: Rust

on:
  push: {}
  pull_request: {}

jobs:
  build_test:
    runs-on: ${{ matrix.rust.os }}
    strategy:
      matrix:
        rust:
        # x86
        - { target: i686-pc-windows-msvc, toolchain: "1.89", os: windows-latest }
        - { target: i686-pc-windows-msvc, toolchain: stable, os: windows-latest }
        - { target: i686-pc-windows-msvc, toolchain: beta, os: windows-latest }
        - { target: i686-pc-windows-msvc, toolchain: nightly, os: windows-latest }
        # x86_64
        - { target: x86_64-unknown-linux-gnu, toolchain: "1.89", os: ubuntu-latest }
        - { target: x86_64-unknown-linux-gnu, toolchain: stable, os: ubuntu-latest }
        - { target: x86_64-unknown-linux-gnu, toolchain: beta, os: ubuntu-latest }
        - { target: x86_64-unknown-linux-gnu, toolchain: nightly, os: ubuntu-latest }
        # aarch64
        - { target: aarch64-apple-darwin, toolchain: "1.89", os: macos-latest }
        - { target: aarch64-apple-darwin, toolchain: stable, os: macos-latest }
        - { target: aarch64-apple-darwin, toolchain: beta, os: macos-latest }
        - { target: aarch64-apple-darwin, toolchain: nightly, os: macos-latest }
        # wasm32
        - { target: wasm32-wasip1, toolchain: "1.89", os: ubuntu-latest, wasmtime: v39.0.1 }
        - { target: wasm32-wasip1, toolchain: stable, os: ubuntu-latest, wasmtime: v39.0.1 }
        - { target: wasm32-wasip1, toolchain: beta, os: ubuntu-latest, wasmtime: v39.0.1 }
        - { target: wasm32-wasip1, toolchain: nightly, os: ubuntu-latest, wasmtime: v39.0.1 }
    steps:
    - uses: actions/checkout@v5
    - uses: dtolnay/rust-toolchain@master
      with:
        toolchain: ${{ matrix.rust.toolchain }}
        target:  ${{ matrix.rust.target }}

    - name: Install wasmtime
      if: matrix.rust.target == 'wasm32-wasip1'
      run: |
        curl https://wasmtime.dev/install.sh -sSf | bash -s -- --version ${{ matrix.rust.wasmtime }}
        echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH

    - name: Build the crate
      run: cargo build --target ${{ matrix.rust.target }}

    - name: Test with default CPU features + No Default Cargo Features
      env:
        CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime run --dir .
        CARGO_TARGET_WASM32_WASIP1_RUSTFLAGS: "-C target-feature=+simd128"
      run: cargo test --target ${{ matrix.rust.target }} --no-default-features

    - name: Test with default CPU features + All Cargo Features
      env:
        CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime run --dir .
        CARGO_TARGET_WASM32_WASIP1_RUSTFLAGS: "-C target-feature=+simd128"
      run: cargo test --target ${{ matrix.rust.target }} --all-features
    
    - name: Test the crate with SSE4.1 (the "native" of CI will be above this)
      if: matrix.rust.os == 'ubuntu-latest' && matrix.rust.target == 'x86_64-unknown-linux-gnu'
      run: RUSTFLAGS="-Ctarget-feature=+sse4.1" cargo test --target ${{ matrix.rust.target }} --all-features

    - name: Test the crate with SSE4.2 (the "native" of CI will be above this)
      if: matrix.rust.os == 'ubuntu-latest' && matrix.rust.target == 'x86_64-unknown-linux-gnu'
      run: RUSTFLAGS="-Ctarget-feature=+sse4.2" cargo test --target ${{ matrix.rust.target }} --all-features

    - name: Test the crate with SSSE3 (the "native" of CI will be above this)
      if: matrix.rust.os == 'ubuntu-latest' && matrix.rust.target == 'x86_64-unknown-linux-gnu'
      run: RUSTFLAGS="-Ctarget-feature=+ssse3" cargo test --target ${{ matrix.rust.target }} --all-features

    - name: switch over to native cpu features
      if: matrix.rust.target != 'wasm32-wasip1'
      run: mv .cargo-ci .cargo

    - name: Test with 'native' CPU features + No Default Cargo Features
      if: matrix.rust.target != 'wasm32-wasip1'
      run: cargo test --target ${{ matrix.rust.target }} --no-default-features

    - name: Test with 'native' CPU features + All Cargo Features 
      if: matrix.rust.target != 'wasm32-wasip1'
      run: cargo test --target ${{ matrix.rust.target }} --all-features
  
  build_check_only:
    runs-on: ${{ matrix.rust.os }}
    strategy:
      matrix:
        rust:
        - { target: x86_64-unknown-linux-gnu, toolchain: stable, os: ubuntu-latest }
    steps:
    - uses: actions/checkout@v5
    - uses: dtolnay/rust-toolchain@master
      with:
        toolchain: ${{ matrix.rust.toolchain }}
        target:  ${{ matrix.rust.target }}

    - name: Add targets via Rustup
      run: rustup target add riscv64gc-unknown-linux-gnu arm-unknown-linux-gnueabihf armv7-unknown-linux-gnueabihf wasm32-unknown-unknown

    - name: Check the crate risc
      run: cargo check --target riscv64gc-unknown-linux-gnu
    - name: Check the crate arm any
      run: cargo check --target arm-unknown-linux-gnueabihf
    - name: Check the crate arm v7
      run: cargo check --target armv7-unknown-linux-gnueabihf
    - name: Check the crate wasm simd
      run: RUSTFLAGS="-Ctarget-feature=+simd128" cargo check --target=wasm32-unknown-unknown
    - name: Check the crate (avx512f && !avx512dq)
      run: RUSTFLAGS="-C target-cpu=x86-64 -C target-feature=+avx512f,+avx512bw,+avx512vl" cargo check

  avx512_emulated_test:
    runs-on: ${{ matrix.rust.os }}
    strategy:
      matrix:
        rust:
          # `wide` is a CPU-arch math library, so emulating the AVX-512 tests on
          # a single OS is enough. See https://github.com/Lokathor/wide/issues/308
          - { target: x86_64-unknown-linux-gnu, toolchain: "1.89",  os: ubuntu-latest }
          - { target: x86_64-unknown-linux-gnu, toolchain: stable,  os: ubuntu-latest }
          - { target: x86_64-unknown-linux-gnu, toolchain: beta,    os: ubuntu-latest }
          - { target: x86_64-unknown-linux-gnu, toolchain: nightly, os: ubuntu-latest }
    env:
      RUSTFLAGS: "-C target-feature=+avx512f,+avx512dq,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi"
    steps:
      - uses: actions/checkout@v3

      - name: Install Rust toolchain & target
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.rust.toolchain }}
          target:    ${{ matrix.rust.target }}
          profile:   minimal
          default:   true

      # Cache the extracted Intel SDE so we don't re-download it on every run.
      - name: Cache Intel SDE
        id: cache-sde
        uses: actions/cache@v3
        with:
          path: sde-external-*
          key: sde-linux-9.58.0-2025-06-16

      - name: Install Intel SDE
        if: steps.cache-sde.outputs.cache-hit != 'true'
        run: |
          set -euo pipefail
          SDE_VERSION=9.58.0
          SDE_DATE=2025-06-16
          SDE_ID=859732
          SDE_FILENAME="sde-external-${SDE_VERSION}-${SDE_DATE}-lin.tar.xz"
          curl -fLO "https://downloadmirror.intel.com/${SDE_ID}/${SDE_FILENAME}"
          tar xf "$SDE_FILENAME"

      - name: Add Intel SDE to PATH and verify
        run: |
          set -euo pipefail
          SDE_DIR=$(find "$PWD" -maxdepth 1 -type d -name "sde-external-*" | head -n1)
          if [ -z "$SDE_DIR" ]; then
            echo "Error: SDE directory not found"
            exit 1
          fi
          echo "$SDE_DIR" >> "$GITHUB_PATH"
          "$SDE_DIR/sde64" --version | head -n1

      - name: Build tests with AVX512
        run: cargo test --target ${{ matrix.rust.target }} --tests --no-run

      # Cargo hands each test binary to the target runner, so we don't need to
      # know where the artifacts live: SDE emulates a Sapphire Rapids CPU.
      # `--tests` keeps the scope to the unit and integration test binaries
      # (matching the previous behaviour) and skips doctests, which the old
      # `--no-run` + manual-binary approach never ran.
      - name: Run tests under Intel SDE (Sapphire Rapids)
        env:
          CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: sde64 -spr --
        run: cargo test --target ${{ matrix.rust.target }} --tests