Skip to content

[Perf][C++] SIMD bit-unpack kernels run as portable fallbacks in default builds; add runtime AVX2 dispatch #1073

Closed

Description

@ColinLeeo

Problem

ENABLE_SIMD only defines -DENABLE_SIMD. The library targets the portable x86-64 baseline (SSE2) and never compiles with -mavx2/-mssse3, so simde's AVX2/SSSE3 intrinsics (vpgatherqq, vpshufb, ...) compile to simde's portable fallback.

Micro-benchmark of the RLE bit-unpack (same header, only difference is -mavx2):

  • width 14: 99 → 644 M values/s (6.5×)
  • width 20: 99 → 612 M values/s (6.2×)

So the SIMD paths added in #823 / #898 (PLAIN, GORILLA, TS_2DIFF) and the RLE packers were not running real AVX2 in shipped builds.

Proposed changes

  • Add common/simd_dispatch.h with cpu_has_avx2() (__builtin_cpu_supports("avx2"), GCC/Clang on x86 only).
  • Add __attribute__((target("avx2"))) intrinsic twins of the bit-unpack kernels, dispatched at runtime; keep the simde path as the portable fallback.

Implemented for RLE and TS_2DIFF in #1072. PLAIN / GORILLA kernels can follow the same pattern.

Related: #1072

Activity

  1. added this to the 2.5.1 milestone on Nov 5, 2026
  2. ColinLeeo commented on Nov 16, 2026

    @ColinLeeo
    ContributorAuthor

    Resolved by #1078 (commit 1848341). The RLE bit-unpack kernels now dispatch to native AVX2 intrinsics at runtime: cpp/src/common/simd_dispatch.h exposes common::cpu_has_avx2() (__builtin_cpu_supports("avx2")) and int32_packer.h / int64_packer.h pick the native kernel per packer instance instead of relying on the translation unit being compiled with -mavx2. The widths that can cross a ninth byte (59/61/62/63) keep the 128-bit buffered scalar fallback, and the simde path remains for CPUs without AVX2.

    Closing as completed in develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions