Skip to content
/ server Public

Comments

MDEV-34804: mhnsw: compiler-independent choice of CPU-specific optimizations#4671

Draft
hadeer-r wants to merge 1 commit intoMariaDB:mainfrom
hadeer-r:MDEV-34804
Draft

MDEV-34804: mhnsw: compiler-independent choice of CPU-specific optimizations#4671
hadeer-r wants to merge 1 commit intoMariaDB:mainfrom
hadeer-r:MDEV-34804

Conversation

@hadeer-r
Copy link

Issue: MDEV-34804

Description

In this draft PR I test different approaches for compiler-independent CPU-specific optimization dispatching in MHNSW. Results and comparison will follow.

Progress

Function pointer:

  • refactor detection for avx2 & avx215 and seperate it in vector_mhnsw_x86.cc
  • refactor detection for arm
  • refactor detection for neon

Benchmark: (1M iterations, 1024 dimensions, AVX512)

Total time in seconds: 0.039602 s
Total time in microseconds: 39602 us
Average time per call: 0.039602 us

Replace GCC function multiversioning (__attribute__((target(...)))) with
runtime CPU detection using function pointers. At startup, cpuid selects
the optimal SIMD implementation (AVX512, AVX2) via a Vector_ops struct.

Move x86 CPU detection into a separate vector_mhnsw_x86.cc, compiled
with appropriate -mavx2/-mavx512 flags.

This makes the dispatching work with musl libc and MSVC, which do not
support GCC function multiversioning.

Benchmark (1M iterations, 1024 dimensions, AVX512):
   0.039602 s total, 0.039602 us per call
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

2 participants