Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jvector-native/src/main/c/jextract_vector_simd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CURRENT_GCC_VERSION=$(gcc -dumpversion)
# Check if the current GCC version is greater than or equal to the minimum required version
if [ "$(printf '%s\n' "$MIN_GCC_VERSION" "$CURRENT_GCC_VERSION" | sort -V | head -n1)" = "$MIN_GCC_VERSION" ]; then
rm -rf ../resources/libjvector.so
gcc -fPIC -O3 -march=icelake-server -c jvector_simd.c -o jvector_simd.o
gcc -fPIC -O3 -march=skylake-avx512 -c jvector_simd.c -o jvector_simd.o
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a strong reason to lower the target micro-architecture version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change addresses an actual bug in our build configuration. We currently compile targeting icelake-server, but at runtime we only check for skylake-avx512. This mismatch allows the compiler to emit Ice Lake–specific instructions that may be executed on a Skylake CPU, which can result in a SIGILL.

Targeting skylake-avx512 resolves this issue and is sufficient for the kernels we currently have; there’s no requirement for Ice Lake–specific features here.

gcc -fPIC -O3 -march=x86-64 -c jvector_simd_check.c -o jvector_simd_check.o
gcc -shared -o ../resources/libjvector.so jvector_simd_check.o jvector_simd.o

Expand Down Expand Up @@ -77,4 +77,4 @@ jextract \
jvector_simd.h

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