Skip to content

Commit af2611d

Browse files
lyd1992yudong
andauthored
knowhere support riscv (zilliztech#1160)
Signed-off-by: yudong <yudong@njis.ac.cn> Co-authored-by: yudong <yudong@njis.ac.cn>
1 parent 56bd304 commit af2611d

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

cmake/libs/libfaiss.cmake

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ if(__AARCH64)
101101
target_link_libraries(knowhere_utils PUBLIC glog::glog)
102102
endif()
103103

104-
104+
if(__RISCV64)
105+
set(UTILS_SRC src/simd/hook.cc src/simd/distances_ref.cc)
106+
add_library(knowhere_utils STATIC ${UTILS_SRC})
107+
target_link_libraries(knowhere_utils PUBLIC glog::glog)
108+
endif()
105109

106110
# ToDo: Add distances_vsx.cc for powerpc64 SIMD acceleration
107111
if(__PPC64)
@@ -192,6 +196,28 @@ if(__AARCH64)
192196
target_compile_definitions(faiss PRIVATE FINTEGER=int)
193197
endif()
194198

199+
if(__RISCV64)
200+
knowhere_file_glob(GLOB FAISS_AVX_SRCS thirdparty/faiss/faiss/impl/*avx.cpp)
201+
202+
list(REMOVE_ITEM FAISS_SRCS ${FAISS_AVX_SRCS})
203+
add_library(faiss STATIC ${FAISS_SRCS})
204+
205+
target_compile_options(
206+
faiss
207+
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:
208+
-Wno-sign-compare
209+
-Wno-unused-variable
210+
-Wno-reorder
211+
-Wno-unused-local-typedefs
212+
-Wno-unused-function
213+
-Wno-strict-aliasing>)
214+
215+
add_dependencies(faiss knowhere_utils)
216+
target_link_libraries(faiss PUBLIC OpenMP::OpenMP_CXX ${BLAS_LIBRARIES}
217+
${LAPACK_LIBRARIES} knowhere_utils)
218+
target_compile_definitions(faiss PRIVATE FINTEGER=int)
219+
endif()
220+
195221
if(__PPC64)
196222
knowhere_file_glob(GLOB FAISS_AVX_SRCS thirdparty/faiss/faiss/impl/*avx.cpp)
197223
list(REMOVE_ITEM FAISS_SRCS ${FAISS_AVX_SRCS})

cmake/utils/platform_check.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ macro(detect_target_arch)
44
check_symbol_exists(__aarch64__ "" __AARCH64)
55
check_symbol_exists(__x86_64__ "" __X86_64)
66
check_symbol_exists(__powerpc64__ "" __PPC64)
7+
check_symbol_exists(__riscv "" __RISCV64)
78

89
if(NOT __AARCH64
910
AND NOT __X86_64
10-
AND NOT __PPC64)
11-
message(FATAL "knowhere only support amd64, ppc64 and arm64 architecture.")
11+
AND NOT __PPC64
12+
AND NOT __RISCV64)
13+
message(FATAL "knowhere only support amd64, ppc64, riscv64 and arm64 architecture.")
1214
endif()
1315
endmacro()
1416

0 commit comments

Comments
 (0)