Add ARM64 NEON and SVE acceleration for LSMT inner search - #452
youhangwang wants to merge 2 commits into
Conversation
Signed-off-by: youhwsh <youhangwang@foxmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
The added tests and capability checks contain a few concrete correctness/maintainability issues (doc reference to a missing file, potential key-generation overflow, and magic-number HWCAP bits) that should be addressed before merging.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds an aarch64 SIMD-accelerated inner-search path for LSMT’s linearized B+tree, analogous to the existing AVX-512 dispatch on x86_64, and introduces targeted tests plus build-time SVE enablement.
Changes:
- Add NEON inner-search implementation and aarch64 runtime dispatch (SVE → NEON → scalar) in the LSMT index.
- Add an optional, separately-compiled SVE TU with CMake toolchain probing and per-file
-march=armv8.2-a+sve. - Add aarch64 kernel-level tests that cross-validate NEON/SVE against an independent scalar reference.
File summaries
| File | Description |
|---|---|
| src/overlaybd/lsmt/index.cpp | Adds NEON implementation, SVE bridge hooks, and runtime dispatch for aarch64. |
| src/overlaybd/lsmt/index_sve.cpp | New SVE1 implementation TU for inner-search kernels and VL reporting. |
| src/overlaybd/lsmt/CMakeLists.txt | Conditionally builds SVE TU via toolchain probing and defines OVERLAYBD_ENABLE_SVE. |
| src/overlaybd/lsmt/test/inner_search_test.cpp | New tests to validate NEON/SVE kernels against an independent scalar reference. |
| src/overlaybd/lsmt/test/CMakeLists.txt | Adds the new test source to the lsmt_test target and sets C++17 for tests. |
Review details
Suppressed comments (5)
src/overlaybd/lsmt/test/inner_search_test.cpp:72
- The SVE capability check hard-codes the Linux HWCAP_SVE bit (1<<22). Using the named macro when available (and falling back) makes the intent clearer and reduces the risk of drift across libc/kernel headers.
bool sve_available() { return getauxval(AT_HWCAP) & (1UL << 22); }
src/overlaybd/lsmt/test/inner_search_test.cpp:69
- The BX64 constants use the UL suffix, but the width of unsigned long is platform-dependent in C++. Using UINT64_C(...) avoids relying on UL being 64-bit and keeps the constants unambiguous.
constexpr uint64_t BX64[] = {0, 1, 0x7fffffffffffffffUL, 0x8000000000000000UL,
UINT64_MAX};
src/overlaybd/lsmt/test/inner_search_test.cpp:82
- This test claims to generate ascending u32 nodes, but starting from an arbitrary uint32_t and adding up to ~16k can overflow and wrap, breaking the sorted-node assumption. Constraining the initial value avoids wrap-around and makes the test match its stated intent.
uint32_t v = (uint32_t)rng.next();
src/overlaybd/lsmt/test/inner_search_test.cpp:104
- This test claims to generate ascending u64 nodes; while overflow is unlikely, it’s still possible in principle if the initial value is near UINT64_MAX. Constraining the initial value removes that edge case and keeps the node generation strictly increasing.
uint64_t v = rng.next();
src/overlaybd/lsmt/index.cpp:87
- The SVE2 detection hard-codes the Linux HWCAP2_SVE2 bit (1<<1). Prefer using HWCAP2_SVE2 when available (with a fallback) to avoid magic numbers and keep the check aligned with system headers.
bool sve2_supported() {
#ifdef AT_HWCAP2
return getauxval(AT_HWCAP2) & (1UL << 1); // HWCAP2_SVE2
#else
return false;
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| bool sve_supported() { | ||
| return getauxval(AT_HWCAP) & (1UL << 22); // HWCAP_SVE | ||
| } |
|
@lihuiba please review |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: youhwsh <youhangwang@foxmail.com>
What this PR does / why we need it:
The LSMT linearized B+tree inner search has an AVX-512 accelerated path on x86_64, but on aarch64 it always fell back to the scalar loop. This PR adds SIMD acceleration for aarch64, mirroring the x86_64 design.
Measured with a single-thread microbenchmark (ns per inner_search, working sets from L1 to 256MB): the u32/16-key kernel improves ~1.9–2.7x with NEON and ~2.1–2.7x with SVE over the scalar loop; the u64/8-key kernel ~1.2–1.7x and ~1.5–1.7x respectively. The gain is stable across all working-set sizes.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Please check the following list: