Skip to content

Commit 0602b8c

Browse files
author
Raghuveer Devulapalli
committed
Add optimal AVX2/SSE reduction and refactor native SIMD code
* Replace icelake-server gcc target with skylake-avx512 in build script * Remove global mutable state: eliminate initialIndexRegister, indexIncrement, maskSeventhBit, maskEighthBit globals and their constructor initializer; move mask constants (maskSeventhBit, maskEighthBit) to local scope inside lookup_partial_sums * Add shared reduce_add_128_ps and reduce_add_256_ps helper functions using proper horizontal-add sequences instead of store-to-array loops * Remove redundant if (length >= N) guards in all SIMD kernels — the loop body already handles the zero-iteration case correctly * Replace store-to-aligned-array horizontal reduction pattern with the new helpers across all 128- and 256-bit dot product and euclidean distance functions * Remove preferred_size parameter from dot_product_f32 and euclidean_f32; always dispatch to AVX-512 when length >= 16 * Standardize inline annotations: replace __attribute__((always_inline)) inline with JV_FINLINE / JV_INLINE macros throughout
1 parent 18488b8 commit 0602b8c

3 files changed

Lines changed: 212 additions & 224 deletions

File tree

jvector-native/src/main/c/jextract_vector_simd.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ CURRENT_GCC_VERSION=$(gcc -dumpversion)
4949
# Check if the current GCC version is greater than or equal to the minimum required version
5050
if [ "$(printf '%s\n' "$MIN_GCC_VERSION" "$CURRENT_GCC_VERSION" | sort -V | head -n1)" = "$MIN_GCC_VERSION" ]; then
5151
rm -rf ../resources/libjvector.so
52-
gcc -fPIC -O3 -march=icelake-server -c jvector_simd.c -o jvector_simd.o
52+
gcc -fPIC -O3 -march=skylake-avx512 -c jvector_simd.c -o jvector_simd.o
5353
gcc -fPIC -O3 -march=x86-64 -c jvector_simd_check.c -o jvector_simd_check.o
5454
gcc -shared -o ../resources/libjvector.so jvector_simd_check.o jvector_simd.o
5555

@@ -77,4 +77,4 @@ jextract \
7777
jvector_simd.h
7878

7979
# Set critical linker option with heap-based segments for all generated methods
80-
sed -i 's/DESC)/DESC, Linker.Option.critical(true))/g' ../java/io/github/jbellis/jvector/vector/cnative/NativeSimdOps.java
80+
sed -i 's/DESC)/DESC, Linker.Option.critical(true))/g' ../java/io/github/jbellis/jvector/vector/cnative/NativeSimdOps.java

0 commit comments

Comments
 (0)