Skip to content

Commit 8d26349

Browse files
authored
Add SIMD optimizations for sparse inverted index IP metric (zilliztech#1414)
Signed-off-by: lyang24 <lanqingy93@gmail.com>
1 parent 91c3c20 commit 8d26349

File tree

9 files changed

+878
-12
lines changed

9 files changed

+878
-12
lines changed

benchmark/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,17 @@ benchmark_test(benchmark_simd_qps hdf5/benchmark_simd_qps.cpp)
5555

5656
benchmark_test(gen_hdf5_file hdf5/gen_hdf5_file.cpp)
5757
benchmark_test(gen_fbin_file hdf5/gen_fbin_file.cpp)
58+
59+
# Sparse SIMD benchmark (x86_64 only, standalone, no HDF5 required)
60+
# Only build on x86_64/AMD64, skip on ARM/aarch64/arm64
61+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64|X86_64)$")
62+
message(STATUS "Building sparse SIMD benchmark for ${CMAKE_SYSTEM_PROCESSOR}")
63+
add_executable(benchmark_sparse_simd benchmark_sparse_simd.cpp)
64+
target_link_libraries(benchmark_sparse_simd knowhere)
65+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
66+
target_compile_options(benchmark_sparse_simd PRIVATE -mavx512f -mavx512dq)
67+
endif()
68+
install(TARGETS benchmark_sparse_simd DESTINATION unittest)
69+
else()
70+
message(STATUS "Skipping sparse SIMD benchmark on ${CMAKE_SYSTEM_PROCESSOR} (x86_64 only)")
71+
endif()

benchmark/Makefile.sparse_simd

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Standalone Makefile for sparse SIMD benchmark
2+
# Usage: make -f Makefile.sparse_simd
3+
4+
CXX ?= g++
5+
CXXFLAGS = -std=c++17 -O3 -Wall -I../include -I.. -mavx512f -mavx512dq
6+
LDFLAGS = -pthread
7+
8+
# Detect build directory
9+
BUILD_DIR = ../build
10+
11+
BENCHMARK_BIN = benchmark_sparse_simd_standalone
12+
13+
all: $(BENCHMARK_BIN)
14+
15+
$(BENCHMARK_BIN): benchmark_sparse_simd.cpp
16+
$(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS)
17+
18+
run: $(BENCHMARK_BIN)
19+
@echo "Running sparse SIMD benchmark..."
20+
@./$(BENCHMARK_BIN)
21+
22+
clean:
23+
rm -f $(BENCHMARK_BIN)
24+
25+
.PHONY: all run clean

0 commit comments

Comments
 (0)