Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial ppc64le support #162

Merged
merged 1 commit into from
Dec 11, 2023
Merged
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
31 changes: 31 additions & 0 deletions cmake/libs/libfaiss.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ if(__AARCH64)
target_link_libraries(knowhere_utils PUBLIC glog::glog)
endif()

# ToDo: Add distances_vsx.cc for powerpc64 SIMD acceleration
if(__PPC64)
set(UTILS_SRC src/simd/hook.cc src/simd/distances_ref.cc)
add_library(knowhere_utils STATIC ${UTILS_SRC})
target_link_libraries(knowhere_utils PUBLIC glog::glog)
endif()

if(LINUX)
set(BLA_VENDOR OpenBLAS)
endif()
Expand Down Expand Up @@ -129,3 +136,27 @@ if(__AARCH64)
${LAPACK_LIBRARIES} knowhere_utils)
target_compile_definitions(faiss PRIVATE FINTEGER=int)
endif()

if(__PPC64)
knowhere_file_glob(GLOB FAISS_AVX_SRCS thirdparty/faiss/faiss/impl/*avx.cpp)

list(REMOVE_ITEM FAISS_SRCS ${FAISS_AVX_SRCS})
add_library(faiss STATIC ${FAISS_SRCS})

target_compile_options(
faiss
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:
-mcpu=native
-mvsx
-Wno-sign-compare
-Wno-unused-variable
-Wno-reorder
-Wno-unused-local-typedefs
-Wno-unused-function
-Wno-strict-aliasing>)

add_dependencies(faiss knowhere_utils)
target_link_libraries(faiss PUBLIC OpenMP::OpenMP_CXX ${BLAS_LIBRARIES}
${LAPACK_LIBRARIES} knowhere_utils)
target_compile_definitions(faiss PRIVATE FINTEGER=int)
endif()
5 changes: 3 additions & 2 deletions cmake/utils/platform_check.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ include(CheckSymbolExists)
macro(detect_target_arch)
check_symbol_exists(__aarch64__ "" __AARCH64)
check_symbol_exists(__x86_64__ "" __X86_64)
check_symbol_exists(__powerpc64__ "" __PPC64)

if(NOT __AARCH64 AND NOT __X86_64)
message(FATAL "knowhere only support amd64 and arm64.")
if(NOT __AARCH64 AND NOT __X86_64 AND NOT __PPC64)
message(FATAL "knowhere only support amd64, ppc64 and arm64 architecture.")
endif()
endmacro()

Expand Down
17 changes: 17 additions & 0 deletions src/simd/hook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,23 @@ fvec_hook(std::string& simd_type) {
support_pq_fast_scan = true;

#endif

// ToDo MG: include VSX intrinsics via distances_vsx once _ref tests succeed
#if defined(__powerpc64__)
fvec_inner_product = fvec_inner_product_ref;
fvec_L2sqr = fvec_L2sqr_ref;
fvec_L1 = fvec_L1_ref;
fvec_Linf = fvec_Linf_ref;

fvec_norm_L2sqr = fvec_norm_L2sqr_ref;
fvec_L2sqr_ny = fvec_L2sqr_ny_ref;
fvec_inner_products_ny = fvec_inner_products_ny_ref;
fvec_madd = fvec_madd_ref;
fvec_madd_and_argmin = fvec_madd_and_argmin_ref;

simd_type = "GENERIC";
support_pq_fast_scan = false;
#endif
}

static int init_hook_ = []() {
Expand Down
Loading