Support building on ARM with NEON histogram intrinsics #4

Merged
andrew merged 5 commits from weaselbot/weaseldb:weaselbot/issue-3 into main 2026-06-26 16:13:08 +00:00
Member

Closes #3

The metrics histogram update code unconditionally included <immintrin.h> and used __attribute__((target("avx"))) SSE/AVX intrinsics, which only exist on x86-64. This prevented the project from compiling on ARM64.

  • Guard the x86-64 SIMD implementation and the <immintrin.h> include with an architecture check.
  • Add an AArch64 NEON implementation that processes two buckets per iteration, matching the AVX path.
  • Fix the AArch64 assembly .size directive in src/cpu_work.cpp so the project actually builds on ARM64 Linux.
  • Keep a portable scalar fallback for other architectures.

I verified the full project builds and the test suite passes on an aarch64 host.

Closes #3 The metrics histogram update code unconditionally included `<immintrin.h>` and used `__attribute__((target("avx")))` SSE/AVX intrinsics, which only exist on x86-64. This prevented the project from compiling on ARM64. - Guard the x86-64 SIMD implementation and the `<immintrin.h>` include with an architecture check. - Add an AArch64 NEON implementation that processes two buckets per iteration, matching the AVX path. - Fix the AArch64 assembly `.size` directive in `src/cpu_work.cpp` so the project actually builds on ARM64 Linux. - Keep a portable scalar fallback for other architectures. I verified the full project builds and the test suite passes on an aarch64 host.
weaselbot added 1 commit 2026-06-26 14:50:08 +00:00
The metrics histogram update code unconditionally included <immintrin.h>
and used __attribute__((target("avx"))) SSE/AVX intrinsics, which only
exist on x86-64. This prevented the project from compiling on ARM64.

Guard the x86-64 SIMD implementation and the <immintrin.h> include with
an architecture check, and add a portable scalar fallback for non-x86-64
platforms (e.g., ARM64). A thin wrapper function keeps the call sites
unchanged and preserves the AVX fast path on x86-64.

Closes #3
weaselbot requested review from andrew 2026-06-26 14:50:12 +00:00
andrew requested changes 2026-06-26 15:01:25 +00:00
Dismissed
andrew left a comment
Owner

You should have access to github now. Please write use simd intrinsics for arm implementation.

You should have access to github now. Please write use simd intrinsics for arm implementation.
weaselbot added 2 commits 2026-06-26 15:08:27 +00:00
Replace the scalar ARM fallback in update_histogram_buckets with a NEON
implementation that processes two buckets per iteration, matching the
existing AVX path.  The wrapper now dispatches to the SIMD path on both
x86-64 and AArch64 and falls back to scalar code on other architectures.
The GNU assembler expects `.size symbol, .-symbol`.  The previous
`.size spend_cpu_cycles, spend_cpu_cycles` expression is not a constant
and breaks compilation on AArch64 Linux.  Use the correct form so the
project builds on ARM64.
weaselbot changed title from Support building on ARM by providing scalar histogram fallback to Support building on ARM with NEON histogram intrinsics 2026-06-26 15:08:34 +00:00
weaselbot added 1 commit 2026-06-26 15:09:14 +00:00
Minor whitespace fix so the NEON function signature matches the existing
AVX function's indentation.
andrew requested changes 2026-06-26 15:11:19 +00:00
Dismissed
andrew left a comment
Owner

You should now have the pre-commit dependencies installed. Make sure the pre-commit passes

You should now have the pre-commit dependencies installed. Make sure the pre-commit passes
weaselbot added 1 commit 2026-06-26 15:15:22 +00:00
Pre-commit's clang-format hook reformatted the AArch64 NEON histogram
bucket updates so the project style checks pass. No functional change.
andrew approved these changes 2026-06-26 16:12:23 +00:00
andrew merged commit 273f288020 into main 2026-06-26 16:13:08 +00:00
andrew deleted branch weaselbot/issue-3 2026-06-26 16:13:08 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weaselab/weaseldb#4