This is an automated email from the ASF dual-hosted git repository. airborne pushed a commit to branch faiss in repository https://gitbox.apache.org/repos/asf/doris-thirdparty.git
The following commit(s) were added to refs/heads/faiss by this push: new b2b482fccec add compile options for faiss (#341) b2b482fccec is described below commit b2b482fccec9f488a0f5d90e415dec41a6ee6469 Author: zhiqiang <hezhiqi...@selectdb.com> AuthorDate: Fri Jul 25 22:55:36 2025 +0800 add compile options for faiss (#341) * cmake support openblas * add compile options --- CMakeLists.txt | 5 ++++- faiss/CMakeLists.txt | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a988c5d2bf..0d780b58ddb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,10 @@ option(FAISS_ENABLE_PYTHON "Build Python extension." ON) option(FAISS_ENABLE_C_API "Build C API." OFF) option(FAISS_ENABLE_EXTRAS "Build extras like benchmarks and demos" ON) option(FAISS_USE_LTO "Enable Link-Time optimization" OFF) - +# compile error: +# simdlib_avx2.h:695:25: error: always_inline function '_mm256_fmadd_ps' requires target feature 'fma', but would be inlined into function 'fmadd' that is compiled without support for 'fma' +# if fixed by -mfma +add_compile_options(-Wno-everything -mfma) if(FAISS_ENABLE_GPU) if(FAISS_ENABLE_ROCM) enable_language(HIP) diff --git a/faiss/CMakeLists.txt b/faiss/CMakeLists.txt index 91294683e47..fbf0419e2fd 100644 --- a/faiss/CMakeLists.txt +++ b/faiss/CMakeLists.txt @@ -391,6 +391,56 @@ if(MKL_FOUND) target_link_libraries(faiss_avx2 PRIVATE ${MKL_LIBRARIES}) target_link_libraries(faiss_avx512 PRIVATE ${MKL_LIBRARIES}) target_link_libraries(faiss_avx512_spr PRIVATE ${MKL_LIBRARIES}) +elseif(TARGET openblas) + # Use OpenBLAS target when it's available (built together) + message(STATUS "Using OpenBLAS target for linking") + + # Link OpenBLAS target to all faiss targets + target_link_libraries(faiss PRIVATE openblas) + target_link_libraries(faiss_avx2 PRIVATE openblas) + target_link_libraries(faiss_avx512 PRIVATE openblas) + target_link_libraries(faiss_avx512_spr PRIVATE openblas) + target_link_libraries(faiss_sve PRIVATE openblas) + + # Add dependency to ensure OpenBLAS is built before Faiss + add_dependencies(faiss openblas) + add_dependencies(faiss_avx2 openblas) + add_dependencies(faiss_avx512 openblas) + add_dependencies(faiss_avx512_spr openblas) + add_dependencies(faiss_sve openblas) +elseif(DEFINED OPENBLAS_PATH) + # Use pre-built OpenBLAS when OPENBLAS_PATH is set + message(STATUS "Using pre-built OpenBLAS from OPENBLAS_PATH: ${OPENBLAS_PATH}") + + # Find OpenBLAS library + find_library(OPENBLAS_LIBRARY + NAMES openblas + PATHS ${OPENBLAS_PATH}/lib ${OPENBLAS_PATH}/lib64 + NO_DEFAULT_PATH + ) + + if(OPENBLAS_LIBRARY) + # Set include directories + set(OPENBLAS_INCLUDE_DIRS ${OPENBLAS_PATH}/include) + + # Link OpenBLAS to all targets + target_link_libraries(faiss PRIVATE ${OPENBLAS_LIBRARY}) + target_link_libraries(faiss_avx2 PRIVATE ${OPENBLAS_LIBRARY}) + target_link_libraries(faiss_avx512 PRIVATE ${OPENBLAS_LIBRARY}) + target_link_libraries(faiss_avx512_spr PRIVATE ${OPENBLAS_LIBRARY}) + target_link_libraries(faiss_sve PRIVATE ${OPENBLAS_LIBRARY}) + + # Set include directories for all targets + target_include_directories(faiss PRIVATE ${OPENBLAS_INCLUDE_DIRS}) + target_include_directories(faiss_avx2 PRIVATE ${OPENBLAS_INCLUDE_DIRS}) + target_include_directories(faiss_avx512 PRIVATE ${OPENBLAS_INCLUDE_DIRS}) + target_link_libraries(faiss_avx512_spr PRIVATE ${OPENBLAS_LIBRARY}) + target_include_directories(faiss_sve PRIVATE ${OPENBLAS_INCLUDE_DIRS}) + + message(STATUS "Found OpenBLAS: ${OPENBLAS_LIBRARY}") + else() + message(FATAL_ERROR "OpenBLAS not found in ${OPENBLAS_PATH}") + endif() else() find_package(BLAS REQUIRED) target_link_libraries(faiss PRIVATE ${BLAS_LIBRARIES}) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org