提交 ec2bf996 编写于 作者: S starlord

Merge remote-tracking branch 'source/branch-0.4.0' into branch-0.4.0


Former-commit-id: 7186924615af54c6b5f478c32cb839ace35b607a
...@@ -28,6 +28,7 @@ Please mark all change in change log and use the ticket from JIRA. ...@@ -28,6 +28,7 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-471 - code coverage run failed - MS-471 - code coverage run failed
- MS-492 - Drop index failed if index have been created with index_type: FLAT - MS-492 - Drop index failed if index have been created with index_type: FLAT
- MS-493 - Knowhere unittest crash - MS-493 - Knowhere unittest crash
- MS-453 - GPU search error when nprobe set more than 1024
## Improvement ## Improvement
- MS-327 - Clean code for milvus - MS-327 - Clean code for milvus
...@@ -90,6 +91,7 @@ Please mark all change in change log and use the ticket from JIRA. ...@@ -90,6 +91,7 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-482 - Change search stream transport to unary in grpc - MS-482 - Change search stream transport to unary in grpc
- MS-487 - Define metric type in CreateTable - MS-487 - Define metric type in CreateTable
- MS-488 - Improve code format in scheduler - MS-488 - Improve code format in scheduler
- MS-495 - cmake: integrated knowhere
## New Feature ## New Feature
- MS-343 - Implement ResourceMgr - MS-343 - Implement ResourceMgr
......
...@@ -31,6 +31,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release") ...@@ -31,6 +31,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(BUILD_TYPE "release") set(BUILD_TYPE "release")
else() else()
set(BUILD_TYPE "debug") set(BUILD_TYPE "debug")
SET(CMAKE_VERBOSE_MAKEFILE on)
endif() endif()
message(STATUS "Build type = ${BUILD_TYPE}") message(STATUS "Build type = ${BUILD_TYPE}")
...@@ -70,21 +71,21 @@ set(MILVUS_BINARY_DIR ${PROJECT_BINARY_DIR}) ...@@ -70,21 +71,21 @@ set(MILVUS_BINARY_DIR ${PROJECT_BINARY_DIR})
find_package(CUDA) find_package(CUDA)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler -fPIC -std=c++11 -D_FORCE_INLINES -arch sm_60 --expt-extended-lambda") set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler -fPIC -std=c++11 -D_FORCE_INLINES -arch sm_60 --expt-extended-lambda")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -O0 -g") set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -O0 -g")
message("CUDA_TOOLKIT_ROOT_DIR=${CUDA_TOOLKIT_ROOT_DIR}") message(STATUS "CUDA_TOOLKIT_ROOT_DIR=${CUDA_TOOLKIT_ROOT_DIR}")
message("CUDA_NVCC_FLAGS=${CUDA_NVCC_FLAGS}") message(STATUS "CUDA_NVCC_FLAGS=${CUDA_NVCC_FLAGS}")
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED on) set(CMAKE_CXX_STANDARD_REQUIRED on)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
message("building milvus_engine on x86 architecture") message(STATUS "building milvus_engine on x86 architecture")
set(MILVUS_BUILD_ARCH x86_64) set(MILVUS_BUILD_ARCH x86_64)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(ppc)") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(ppc)")
message("building milvus_engine on ppc architecture") message(STATUS "building milvus_engine on ppc architecture")
set(MILVUS_BUILD_ARCH ppc64le) set(MILVUS_BUILD_ARCH ppc64le)
else() else()
message("unknown processor type") message(WARNING "unknown processor type")
message("CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") message(WARNING "CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}")
set(MILVUS_BUILD_ARCH unknown) set(MILVUS_BUILD_ARCH unknown)
endif() endif()
...@@ -94,6 +95,8 @@ else() ...@@ -94,6 +95,8 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -fPIC -DELPP_THREAD_SAFE -fopenmp") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -fPIC -DELPP_THREAD_SAFE -fopenmp")
endif() endif()
set(ALLOW_DUPLICATE_CUSTOM_TARGETS TRUE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(ExternalProject) include(ExternalProject)
...@@ -104,14 +107,6 @@ include(ThirdPartyPackages) ...@@ -104,14 +107,6 @@ include(ThirdPartyPackages)
include_directories(${MILVUS_SOURCE_DIR}) include_directories(${MILVUS_SOURCE_DIR})
link_directories(${MILVUS_BINARY_DIR}) link_directories(${MILVUS_BINARY_DIR})
if (NOT DEFINED KNOWHERE_BUILD_DIR)
message(FATAL_ERROR "You must set environment variable KNOWHERE_BUILD_DIR")
endif()
message(STATUS "Build with ${KNOWHERE_BUILD_DIR}")
include_directories(${KNOWHERE_BUILD_DIR}/include)
include_directories(${KNOWHERE_BUILD_DIR}/include/SPTAG/AnnService)
link_directories(${KNOWHERE_BUILD_DIR}/lib)
## Following should be check ## Following should be check
set(MILVUS_ENGINE_INCLUDE ${PROJECT_SOURCE_DIR}/include) set(MILVUS_ENGINE_INCLUDE ${PROJECT_SOURCE_DIR}/include)
...@@ -119,7 +114,7 @@ set(MILVUS_ENGINE_SRC ${PROJECT_SOURCE_DIR}/src) ...@@ -119,7 +114,7 @@ set(MILVUS_ENGINE_SRC ${PROJECT_SOURCE_DIR}/src)
add_compile_definitions(PROFILER=${PROFILER}) add_compile_definitions(PROFILER=${PROFILER})
message("MILVUS_ENABLE_PROFILING = ${MILVUS_ENABLE_PROFILING}") message(STATUS "MILVUS_ENABLE_PROFILING = ${MILVUS_ENABLE_PROFILING}")
if (MILVUS_ENABLE_PROFILING STREQUAL "ON") if (MILVUS_ENABLE_PROFILING STREQUAL "ON")
ADD_DEFINITIONS(-DMILVUS_ENABLE_PROFILING) ADD_DEFINITIONS(-DMILVUS_ENABLE_PROFILING)
endif() endif()
......
...@@ -83,10 +83,6 @@ if [[ ! -d cmake_build ]]; then ...@@ -83,10 +83,6 @@ if [[ ! -d cmake_build ]]; then
MAKE_CLEAN="ON" MAKE_CLEAN="ON"
fi fi
pushd `pwd`/src/core
./build.sh ${KNOWHERE_OPTIONS}
popd
cd cmake_build cd cmake_build
CUDA_COMPILER=/usr/local/cuda/bin/nvcc CUDA_COMPILER=/usr/local/cuda/bin/nvcc
......
...@@ -4,6 +4,13 @@ ...@@ -4,6 +4,13 @@
# Proprietary and confidential. # Proprietary and confidential.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
add_subdirectory(core)
set(CORE_INCLUDE_DIRS ${CORE_INCLUDE_DIRS} PARENT_SCOPE)
foreach(dir ${CORE_INCLUDE_DIRS})
include_directories(${dir})
endforeach()
aux_source_directory(cache cache_files) aux_source_directory(cache cache_files)
aux_source_directory(config config_files) aux_source_directory(config config_files)
aux_source_directory(server server_files) aux_source_directory(server server_files)
...@@ -87,12 +94,6 @@ set(client_grpc_lib ...@@ -87,12 +94,6 @@ set(client_grpc_lib
set(third_party_libs set(third_party_libs
knowhere knowhere
SPTAGLibStatic
arrow
jemalloc_pic
faiss
openblas
lapack
easyloggingpp easyloggingpp
sqlite sqlite
${client_grpc_lib} ${client_grpc_lib}
...@@ -115,15 +116,6 @@ set(third_party_libs ...@@ -115,15 +116,6 @@ set(third_party_libs
cudart cudart
) )
if(${BUILD_FAISS_WITH_MKL} STREQUAL "ON")
set(third_party_libs ${third_party_libs}
${MKL_LIBS})
else()
set(third_party_libs ${third_party_libs}
lapack
openblas)
endif()
if (MILVUS_ENABLE_PROFILING STREQUAL "ON") if (MILVUS_ENABLE_PROFILING STREQUAL "ON")
set(third_party_libs ${third_party_libs} set(third_party_libs ${third_party_libs}
gperftools gperftools
...@@ -171,13 +163,6 @@ set(server_libs ...@@ -171,13 +163,6 @@ set(server_libs
set(knowhere_libs set(knowhere_libs
knowhere knowhere
SPTAGLibStatic
arrow
jemalloc_pic
faiss
openblas
lapack
tbb
) )
add_executable(milvus_server add_executable(milvus_server
...@@ -195,8 +180,8 @@ target_link_libraries(milvus_server ${server_libs} ${knowhere_libs} ${third_part ...@@ -195,8 +180,8 @@ target_link_libraries(milvus_server ${server_libs} ${knowhere_libs} ${third_part
install(TARGETS milvus_server DESTINATION bin) install(TARGETS milvus_server DESTINATION bin)
install(FILES install(FILES
${KNOWHERE_BUILD_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}tbb${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_SOURCE_DIR}/src/core/thirdparty/tbb/${CMAKE_SHARED_LIBRARY_PREFIX}tbb${CMAKE_SHARED_LIBRARY_SUFFIX}
${KNOWHERE_BUILD_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}tbb${CMAKE_SHARED_LIBRARY_SUFFIX}.2 ${CMAKE_SOURCE_DIR}/src/core/thirdparty/tbb/${CMAKE_SHARED_LIBRARY_PREFIX}tbb${CMAKE_SHARED_LIBRARY_SUFFIX}.2
${CMAKE_BINARY_DIR}/mysqlpp_ep-prefix/src/mysqlpp_ep/lib/${CMAKE_SHARED_LIBRARY_PREFIX}mysqlpp${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/mysqlpp_ep-prefix/src/mysqlpp_ep/lib/${CMAKE_SHARED_LIBRARY_PREFIX}mysqlpp${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/mysqlpp_ep-prefix/src/mysqlpp_ep/lib/${CMAKE_SHARED_LIBRARY_PREFIX}mysqlpp${CMAKE_SHARED_LIBRARY_SUFFIX}.3 ${CMAKE_BINARY_DIR}/mysqlpp_ep-prefix/src/mysqlpp_ep/lib/${CMAKE_SHARED_LIBRARY_PREFIX}mysqlpp${CMAKE_SHARED_LIBRARY_SUFFIX}.3
${CMAKE_BINARY_DIR}/mysqlpp_ep-prefix/src/mysqlpp_ep/lib/${CMAKE_SHARED_LIBRARY_PREFIX}mysqlpp${CMAKE_SHARED_LIBRARY_SUFFIX}.3.2.4 ${CMAKE_BINARY_DIR}/mysqlpp_ep-prefix/src/mysqlpp_ep/lib/${CMAKE_SHARED_LIBRARY_PREFIX}mysqlpp${CMAKE_SHARED_LIBRARY_SUFFIX}.3.2.4
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.14) cmake_minimum_required(VERSION 3.14)
message(STATUS "---------------core--------------")
message(STATUS "Building using CMake version: ${CMAKE_VERSION}") message(STATUS "Building using CMake version: ${CMAKE_VERSION}")
set(KNOWHERE_VERSION "0.1.0") set(KNOWHERE_VERSION "0.1.0")
...@@ -38,18 +39,16 @@ endif() ...@@ -38,18 +39,16 @@ endif()
MESSAGE(STATUS "CMAKE_CXX_FLAGS" ${CMAKE_CXX_FLAGS}) MESSAGE(STATUS "CMAKE_CXX_FLAGS" ${CMAKE_CXX_FLAGS})
find_package(CUDA) find_package(CUDA)
#set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler -fPIC -std=c++11 -D_FORCE_INLINES --expt-extended-lambda")
#set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -O0 -g")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
message("building milvus_engine on x86 architecture") message(STATUS "building milvus_engine on x86 architecture")
set(KNOWHERE_BUILD_ARCH x86_64) set(KNOWHERE_BUILD_ARCH x86_64)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(ppc)") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(ppc)")
message("building milvus_engine on ppc architecture") message(STATUS "building milvus_engine on ppc architecture")
set(KNOWHERE_BUILD_ARCH ppc64le) set(KNOWHERE_BUILD_ARCH ppc64le)
else() else()
message("unknown processor type") message(WARNING "unknown processor type")
message("CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") message(WARNING "CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}")
set(KNOWHERE_BUILD_ARCH unknown) set(KNOWHERE_BUILD_ARCH unknown)
endif() endif()
...@@ -60,14 +59,21 @@ else() ...@@ -60,14 +59,21 @@ else()
endif() endif()
message(STATUS "Build type = ${BUILD_TYPE}") message(STATUS "Build type = ${BUILD_TYPE}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CORE_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(CORE_BINARY_DIR ${PROJECT_BINARY_DIR})
message(STATUS "Core source dir: ${PROJECT_SOURCE_DIR}")
message(STATUS "Core binary dir: ${PROJECT_BINARY_DIR}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CORE_SOURCE_DIR}/cmake")
include(ExternalProject) include(ExternalProject)
include(DefineOptions) include(DefineOptionsCore)
include(BuildUtils) include(BuildUtilsCore)
include(ThirdPartyPackages) include(ThirdPartyPackagesCore)
add_subdirectory(src) add_subdirectory(src)
set(CORE_INCLUDE_DIRS ${CORE_INCLUDE_DIRS} PARENT_SCOPE)
if(BUILD_UNIT_TEST STREQUAL "ON") if(BUILD_UNIT_TEST STREQUAL "ON")
add_subdirectory(test) add_subdirectory(test)
endif() endif()
......
...@@ -75,7 +75,7 @@ function(ExternalProject_Use_Cache project_name package_file install_path) ...@@ -75,7 +75,7 @@ function(ExternalProject_Use_Cache project_name package_file install_path)
"Extracting ${package_file} to ${install_path}" "Extracting ${package_file} to ${install_path}"
COMMAND COMMAND
${CMAKE_COMMAND} -E tar xzvf ${package_file} ${install_path} ${CMAKE_COMMAND} -E tar xzvf ${package_file} ${install_path}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CORE_BINARY_DIR}
) )
ExternalProject_Add_StepTargets(${project_name} extract) ExternalProject_Add_StepTargets(${project_name} extract)
......
...@@ -104,7 +104,7 @@ macro(config_summary) ...@@ -104,7 +104,7 @@ macro(config_summary)
message(STATUS " Source directory: ${CMAKE_CURRENT_SOURCE_DIR}") message(STATUS " Source directory: ${CMAKE_CURRENT_SOURCE_DIR}")
if(${CMAKE_EXPORT_COMPILE_COMMANDS}) if(${CMAKE_EXPORT_COMPILE_COMMANDS})
message( message(
STATUS " Compile commands: ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json") STATUS " Compile commands: ${CORE_BINARY_DIR}/compile_commands.json")
endif() endif()
foreach(category ${KNOWHERE_OPTION_CATEGORIES}) foreach(category ${KNOWHERE_OPTION_CATEGORIES})
......
set(TBB_DIR ${CMAKE_SOURCE_DIR}/thirdparty/tbb) set(TBB_DIR ${CORE_SOURCE_DIR}/thirdparty/tbb)
set(TBB_LIBRARIES ${TBB_DIR}/libtbb.so) set(TBB_LIBRARIES ${TBB_DIR}/libtbb.so)
include_directories(${TBB_DIR}/include) include_directories(${TBB_DIR}/include)
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib64) link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib64)
include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CORE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/thirdparty) include_directories(${CORE_SOURCE_DIR}/thirdparty)
include_directories(${CMAKE_SOURCE_DIR}/thirdparty/SPTAG/AnnService) include_directories(${CORE_SOURCE_DIR}/thirdparty/SPTAG/AnnService)
include_directories(${CMAKE_SOURCE_DIR}/thirdparty/jsoncons-0.126.0/include) include_directories(${CORE_SOURCE_DIR}/thirdparty/jsoncons-0.126.0/include)
set(SPTAG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/SPTAG) set(SPTAG_SOURCE_DIR ${CORE_SOURCE_DIR}/thirdparty/SPTAG)
file(GLOB HDR_FILES file(GLOB HDR_FILES
${SPTAG_SOURCE_DIR}/AnnService/inc/Core/*.h ${SPTAG_SOURCE_DIR}/AnnService/inc/Core/*.h
${SPTAG_SOURCE_DIR}/AnnService/inc/Core/Common/*.h ${SPTAG_SOURCE_DIR}/AnnService/inc/Core/Common/*.h
...@@ -24,9 +24,9 @@ file(GLOB SRC_FILES ...@@ -24,9 +24,9 @@ file(GLOB SRC_FILES
${SPTAG_SOURCE_DIR}/AnnService/src/Core/KDT/*.cpp ${SPTAG_SOURCE_DIR}/AnnService/src/Core/KDT/*.cpp
${SPTAG_SOURCE_DIR}/AnnService/src/Helper/*.cpp) ${SPTAG_SOURCE_DIR}/AnnService/src/Helper/*.cpp)
#add_library(SPTAGLib SHARED ${SRC_FILES} ${HDR_FILES}) if(NOT TARGET SPTAGLibStatic)
#target_link_libraries(SPTAGLib ${TBB_LIBRARIES}) add_library(SPTAGLibStatic STATIC ${SRC_FILES} ${HDR_FILES})
add_library(SPTAGLibStatic STATIC ${SRC_FILES} ${HDR_FILES}) endif()
set(external_srcs set(external_srcs
knowhere/adapter/sptag.cpp knowhere/adapter/sptag.cpp
...@@ -51,14 +51,13 @@ set(index_srcs ...@@ -51,14 +51,13 @@ set(index_srcs
) )
set(depend_libs set(depend_libs
# libtcmalloc.a
SPTAGLibStatic SPTAGLibStatic
${TBB_LIBRARIES} ${TBB_LIBRARIES}
faiss faiss
openblas openblas
lapack lapack
arrow arrow
jemalloc_pic ${ARROW_PREFIX}/lib/libjemalloc_pic.a
cudart cudart
cublas cublas
gomp gomp
...@@ -66,30 +65,19 @@ set(depend_libs ...@@ -66,30 +65,19 @@ set(depend_libs
pthread pthread
) )
add_library( if(NOT TARGET knowhere)
knowhere STATIC add_library(
${external_srcs} knowhere STATIC
${index_srcs} ${external_srcs}
) ${index_srcs}
#target_compile_options(knowhere PUBLIC "-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free") )
endif()
target_link_libraries( target_link_libraries(
knowhere knowhere
${depend_libs} ${depend_libs}
) )
#add_library(
# knowhereS SHARED
# ${external_srcs}
# ${index_srcs}
#)
#
#target_link_libraries(
# knowhereS
## ${TBB_LIBRARIES}
# ${depend_libs}
#)
INSTALL(TARGETS INSTALL(TARGETS
knowhere knowhere
SPTAGLibStatic SPTAGLibStatic
...@@ -98,7 +86,6 @@ INSTALL(TARGETS ...@@ -98,7 +86,6 @@ INSTALL(TARGETS
INSTALL(FILES INSTALL(FILES
${ARROW_STATIC_LIB} ${ARROW_STATIC_LIB}
# ${PARQUET_STATIC_LIB}
${ARROW_PREFIX}/lib/libjemalloc_pic.a ${ARROW_PREFIX}/lib/libjemalloc_pic.a
${FAISS_STATIC_LIB} ${FAISS_STATIC_LIB}
${LAPACK_STATIC_LIB} ${LAPACK_STATIC_LIB}
...@@ -112,24 +99,35 @@ INSTALL(FILES ${OPENBLAS_REAL_STATIC_LIB} ...@@ -112,24 +99,35 @@ INSTALL(FILES ${OPENBLAS_REAL_STATIC_LIB}
DESTINATION lib DESTINATION lib
) )
INSTALL(FILES ${CMAKE_SOURCE_DIR}/thirdparty/tbb/libtbb.so.2 INSTALL(FILES ${CORE_SOURCE_DIR}/thirdparty/tbb/libtbb.so.2
# RENAME "libtbb.so.2"
DESTINATION lib DESTINATION lib
) )
INSTALL(FILES ${CMAKE_SOURCE_DIR}/thirdparty/tbb/libtbb.so INSTALL(FILES ${CORE_SOURCE_DIR}/thirdparty/tbb/libtbb.so
# RENAME "libtbb.so"
DESTINATION lib DESTINATION lib
) )
set(CORE_INCLUDE_DIRS
${CORE_SOURCE_DIR}/include
${CORE_SOURCE_DIR}/thirdparty
${CORE_SOURCE_DIR}/thirdparty/SPTAG/AnnService
${CORE_SOURCE_DIR}/thirdparty/jsoncons-0.126.0/include
${ARROW_INCLUDE_DIR}
${FAISS_INCLUDE_DIR}
${OPENBLAS_INCLUDE_DIR}
${LAPACK_INCLUDE_DIR}
${CORE_SOURCE_DIR}/thirdparty/tbb/include
)
set(CORE_INCLUDE_DIRS ${CORE_INCLUDE_DIRS} PARENT_SCOPE)
INSTALL(DIRECTORY INSTALL(DIRECTORY
${CMAKE_SOURCE_DIR}/include/knowhere ${CORE_SOURCE_DIR}/include/knowhere
${CMAKE_SOURCE_DIR}/thirdparty/jsoncons-0.126.0/include/jsoncons ${CORE_SOURCE_DIR}/thirdparty/jsoncons-0.126.0/include/jsoncons
${CMAKE_SOURCE_DIR}/thirdparty/jsoncons-0.126.0/include/jsoncons_ext ${CORE_SOURCE_DIR}/thirdparty/jsoncons-0.126.0/include/jsoncons_ext
${ARROW_INCLUDE_DIR}/arrow ${ARROW_INCLUDE_DIR}/arrow
# ${ARROW_INCLUDE_DIR}/parquet
${FAISS_PREFIX}/include/faiss ${FAISS_PREFIX}/include/faiss
${OPENBLAS_INCLUDE_DIR}/ ${OPENBLAS_INCLUDE_DIR}/
${CMAKE_SOURCE_DIR}/thirdparty/tbb/include/tbb ${CORE_SOURCE_DIR}/thirdparty/tbb/include/tbb
DESTINATION DESTINATION
include) include)
......
include_directories(${CMAKE_SOURCE_DIR}/thirdparty) include_directories(${CORE_SOURCE_DIR}/thirdparty)
include_directories(${CMAKE_SOURCE_DIR}/thirdparty/SPTAG/AnnService) include_directories(${CORE_SOURCE_DIR}/thirdparty/SPTAG/AnnService)
include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CORE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/thirdparty/jsoncons-0.126.0/include) include_directories(${CORE_SOURCE_DIR}/thirdparty/jsoncons-0.126.0/include)
include_directories(/usr/local/cuda/include) include_directories(/usr/local/cuda/include)
link_directories(/usr/local/cuda/lib64) link_directories(/usr/local/cuda/lib64)
link_directories(${CMAKE_SOURCE_DIR}/thirdparty/tbb) link_directories(${CORE_SOURCE_DIR}/thirdparty/tbb)
set(unittest_libs set(unittest_libs
gtest gmock gtest_main gmock_main) gtest gmock gtest_main gmock_main)
message(STATUS "arrow prefix: ${ARROW_PREFIX}")
message(STATUS "libjemalloc_pic path: ${ARROW_PREFIX}/lib/libjemalloc_pic.a")
set(depend_libs set(depend_libs
faiss openblas lapack faiss openblas lapack
arrow jemalloc_pic arrow "${ARROW_PREFIX}/lib/libjemalloc_pic.a"
tbb tbb
) )
...@@ -22,57 +24,55 @@ set(basic_libs ...@@ -22,57 +24,55 @@ set(basic_libs
#<IVF-TEST> #<IVF-TEST>
#<<<<<<<<<<
set(ivf_srcs set(ivf_srcs
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/ivf.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/ivf.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/gpu_ivf.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/gpu_ivf.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/cloner.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/cloner.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/idmap.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/idmap.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/adapter/structure.cpp ${CORE_SOURCE_DIR}/src/knowhere/adapter/structure.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/common/exception.cpp ${CORE_SOURCE_DIR}/src/knowhere/common/exception.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/common/timer.cpp ${CORE_SOURCE_DIR}/src/knowhere/common/timer.cpp
utils.cpp utils.cpp
) )
add_executable(test_ivf test_ivf.cpp ${ivf_srcs}) if(NOT TARGET test_ivf)
add_executable(test_ivf test_ivf.cpp ${ivf_srcs})
endif()
target_link_libraries(test_ivf ${depend_libs} ${unittest_libs} ${basic_libs}) target_link_libraries(test_ivf ${depend_libs} ${unittest_libs} ${basic_libs})
#<<<<<<<<<<
#<IDMAP-TEST> #<IDMAP-TEST>
#<<<<<<<<<<
set(idmap_srcs set(idmap_srcs
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/idmap.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/idmap.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/ivf.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/ivf.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/cloner.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/cloner.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/gpu_ivf.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/gpu_ivf.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/adapter/structure.cpp ${CORE_SOURCE_DIR}/src/knowhere/adapter/structure.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/common/exception.cpp ${CORE_SOURCE_DIR}/src/knowhere/common/exception.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/common/timer.cpp ${CORE_SOURCE_DIR}/src/knowhere/common/timer.cpp
utils.cpp utils.cpp
) )
add_executable(test_idmap test_idmap.cpp ${idmap_srcs}) if(NOT TARGET test_idmap)
add_executable(test_idmap test_idmap.cpp ${idmap_srcs})
endif()
target_link_libraries(test_idmap ${depend_libs} ${unittest_libs} ${basic_libs}) target_link_libraries(test_idmap ${depend_libs} ${unittest_libs} ${basic_libs})
#<<<<<<<<<<
#<KDT-TEST> #<KDT-TEST>
#<<<<<<<<<<
set(kdt_srcs set(kdt_srcs
${CMAKE_SOURCE_DIR}/src/knowhere/index/preprocessor/normalize.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/preprocessor/normalize.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/kdt_parameters.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/kdt_parameters.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/cpu_kdt_rng.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/cpu_kdt_rng.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/adapter/structure.cpp ${CORE_SOURCE_DIR}/src/knowhere/adapter/structure.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/adapter/sptag.cpp ${CORE_SOURCE_DIR}/src/knowhere/adapter/sptag.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/common/exception.cpp ${CORE_SOURCE_DIR}/src/knowhere/common/exception.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/adapter/arrow.cpp ${CORE_SOURCE_DIR}/src/knowhere/adapter/arrow.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/common/timer.cpp ${CORE_SOURCE_DIR}/src/knowhere/common/timer.cpp
utils.cpp utils.cpp
) )
add_executable(test_kdt test_kdt.cpp ${kdt_srcs}) if(NOT TARGET test_kdt)
add_executable(test_kdt test_kdt.cpp ${kdt_srcs})
endif()
target_link_libraries(test_kdt target_link_libraries(test_kdt
SPTAGLibStatic SPTAGLibStatic
${depend_libs} ${unittest_libs} ${basic_libs}) ${depend_libs} ${unittest_libs} ${basic_libs})
#<<<<<<<<<<
add_subdirectory(faiss_ori) add_subdirectory(faiss_ori)
add_subdirectory(test_nsg) add_subdirectory(test_nsg)
......
include_directories(${CMAKE_SOURCE_DIR}/thirdparty) include_directories(${CORE_SOURCE_DIR}/thirdparty)
include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CORE_SOURCE_DIR}/include)
include_directories(/usr/local/cuda/include) include_directories(/usr/local/cuda/include)
link_directories(/usr/local/cuda/lib64) link_directories(/usr/local/cuda/lib64)
link_directories(${CMAKE_SOURCE_DIR}/thirdparty/tbb) link_directories(${CORE_SOURCE_DIR}/thirdparty/tbb)
set(unittest_libs set(unittest_libs
gtest gmock gtest_main gmock_main) gtest gmock gtest_main gmock_main)
set(depend_libs set(depend_libs
faiss openblas lapack faiss openblas lapack
arrow jemalloc_pic arrow ${ARROW_PREFIX}/lib/libjemalloc_pic.a
tbb tbb
) )
...@@ -20,7 +20,7 @@ set(basic_libs ...@@ -20,7 +20,7 @@ set(basic_libs
#<GPU-TEST> #<GPU-TEST>
#<<<<<<<<<< if(NOT TARGET test_gpu)
add_executable(test_gpu gpuresource_test.cpp) add_executable(test_gpu gpuresource_test.cpp)
endif()
target_link_libraries(test_gpu ${depend_libs} ${unittest_libs} ${basic_libs}) target_link_libraries(test_gpu ${depend_libs} ${unittest_libs} ${basic_libs})
#<<<<<<<<<<
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
include_directories(/usr/local/include/gperftools) include_directories(/usr/local/include/gperftools)
link_directories(/usr/local/lib) link_directories(/usr/local/lib)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free")
add_definitions(-std=c++11 -O3 -lboost -march=native -Wall -DINFO) add_definitions(-std=c++11 -O3 -lboost -march=native -Wall -DINFO)
find_package(OpenMP) find_package(OpenMP)
...@@ -14,37 +13,29 @@ else () ...@@ -14,37 +13,29 @@ else ()
endif () endif ()
message(${OpenMP_CXX_FLAGS}) message(${OpenMP_CXX_FLAGS})
include_directories(${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/nsg) include_directories(${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/nsg)
#include_directories(/home/zilliz/opt/app/pyenv/versions/3.6.8/include/python3.6m)
#include_directories(/home/zilliz/opt/app/pyenv/versions/3.6.8/envs/megasearch_testframework_dev/lib/python3.6/site-packages/numpy/core/include)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/nsg nsg_src) aux_source_directory(${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/nsg nsg_src)
#add_library(nsg_raw SHARED ${nsg_src})
#target_link_libraries(nsg_raw
# gomp)
set(interface_src set(interface_src
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/ivf.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/ivf.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/gpu_ivf.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/gpu_ivf.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/cloner.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/cloner.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/idmap.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/idmap.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/index/vector_index/nsg_index.cpp ${CORE_SOURCE_DIR}/src/knowhere/index/vector_index/nsg_index.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/adapter/structure.cpp ${CORE_SOURCE_DIR}/src/knowhere/adapter/structure.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/common/exception.cpp ${CORE_SOURCE_DIR}/src/knowhere/common/exception.cpp
${CMAKE_SOURCE_DIR}/src/knowhere/common/timer.cpp ${CORE_SOURCE_DIR}/src/knowhere/common/timer.cpp
../utils.cpp ../utils.cpp
) )
add_executable(test_nsg if(NOT TARGET test_nsg)
test_nsg.cpp add_executable(test_nsg
${interface_src} test_nsg.cpp
${nsg_src} ${interface_src}
) ${nsg_src}
#target_link_libraries(test_nsg )
# # libprofiler.so endif()
## -ltcmalloc
## gomp
# )
target_link_libraries(test_nsg ${depend_libs} ${unittest_libs} ${basic_libs}) target_link_libraries(test_nsg ${depend_libs} ${unittest_libs} ${basic_libs})
############################## ##############################
\ No newline at end of file
...@@ -72,8 +72,11 @@ ErrorCode VecIndexImpl::Search(const long &nq, const float *xq, float *dist, lon ...@@ -72,8 +72,11 @@ ErrorCode VecIndexImpl::Search(const long &nq, const float *xq, float *dist, lon
auto k = cfg["k"].as<int>(); auto k = cfg["k"].as<int>();
auto dataset = GenDataset(nq, dim, xq); auto dataset = GenDataset(nq, dim, xq);
Config search_cfg; Config search_cfg = cfg;
auto res = index_->Search(dataset, cfg);
ParameterValidation(type, search_cfg);
auto res = index_->Search(dataset, search_cfg);
auto ids_array = res->array()[0]; auto ids_array = res->array()[0];
auto dis_array = res->array()[1]; auto dis_array = res->array()[1];
......
...@@ -71,7 +71,7 @@ size_t FileIOWriter::operator()(void *ptr, size_t size) { ...@@ -71,7 +71,7 @@ size_t FileIOWriter::operator()(void *ptr, size_t size) {
} }
VecIndexPtr GetVecIndexFactory(const IndexType &type, const Config& cfg) { VecIndexPtr GetVecIndexFactory(const IndexType &type, const Config &cfg) {
std::shared_ptr<zilliz::knowhere::VectorIndex> index; std::shared_ptr<zilliz::knowhere::VectorIndex> index;
auto gpu_device = cfg.get_with_default("gpu_id", 0); auto gpu_device = cfg.get_with_default("gpu_id", 0);
switch (type) { switch (type) {
...@@ -235,6 +235,31 @@ void AutoGenParams(const IndexType &type, const long &size, zilliz::knowhere::Co ...@@ -235,6 +235,31 @@ void AutoGenParams(const IndexType &type, const long &size, zilliz::knowhere::Co
} }
} }
#if CUDA_VERSION > 9000
#define GPU_MAX_NRPOBE 2048
#else
#define GPU_MAX_NRPOBE 1024
#endif
void ParameterValidation(const IndexType &type, Config &cfg) {
switch (type) {
case IndexType::FAISS_IVFSQ8_GPU:
case IndexType::FAISS_IVFFLAT_GPU:
case IndexType::FAISS_IVFPQ_GPU: {
if (cfg.get_with_default("nprobe", 0) != 0) {
auto nprobe = cfg["nprobe"].as<int>();
if (nprobe > GPU_MAX_NRPOBE) {
WRAPPER_LOG_WARNING << "When search with GPU, nprobe shoud be no more than " << GPU_MAX_NRPOBE << ", but you passed " << nprobe
<< ". Search with " << GPU_MAX_NRPOBE << " instead";
cfg.insert_or_assign("nprobe", GPU_MAX_NRPOBE);
}
}
break;
}
default:break;
}
}
IndexType ConvertToCpuIndexType(const IndexType &type) { IndexType ConvertToCpuIndexType(const IndexType &type) {
// TODO(linxj): add IDMAP // TODO(linxj): add IDMAP
switch (type) { switch (type) {
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "knowhere/common/config.h" #include "knowhere/common/config.h"
#include "knowhere/common/binary_set.h" #include "knowhere/common/binary_set.h"
#include "cuda.h"
namespace zilliz { namespace zilliz {
namespace milvus { namespace milvus {
...@@ -90,6 +92,8 @@ extern VecIndexPtr LoadVecIndex(const IndexType &index_type, const zilliz::knowh ...@@ -90,6 +92,8 @@ extern VecIndexPtr LoadVecIndex(const IndexType &index_type, const zilliz::knowh
extern void AutoGenParams(const IndexType& type, const long& size, Config& cfg); extern void AutoGenParams(const IndexType& type, const long& size, Config& cfg);
extern void ParameterValidation(const IndexType& type, Config& cfg);
extern IndexType ConvertToCpuIndexType(const IndexType& type); extern IndexType ConvertToCpuIndexType(const IndexType& type);
extern IndexType ConvertToGpuIndexType(const IndexType& type); extern IndexType ConvertToGpuIndexType(const IndexType& type);
......
...@@ -38,6 +38,10 @@ set(unittest_libs ...@@ -38,6 +38,10 @@ set(unittest_libs
cudart cudart
) )
foreach(dir ${CORE_INCLUDE_DIRS})
include_directories(${dir})
endforeach()
add_subdirectory(server) add_subdirectory(server)
add_subdirectory(db) add_subdirectory(db)
add_subdirectory(knowhere) add_subdirectory(knowhere)
......
...@@ -35,8 +35,6 @@ link_directories("/usr/local/cuda/lib64") ...@@ -35,8 +35,6 @@ link_directories("/usr/local/cuda/lib64")
include_directories(/usr/include/mysql) include_directories(/usr/include/mysql)
#add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
set(db_test_src set(db_test_src
${config_files} ${config_files}
${cache_srcs} ${cache_srcs}
...@@ -69,25 +67,10 @@ set(db_libs ...@@ -69,25 +67,10 @@ set(db_libs
set(knowhere_libs set(knowhere_libs
knowhere knowhere
SPTAGLibStatic
arrow
jemalloc_pic
faiss
openblas
lapack
tbb
cudart cudart
cublas cublas
) )
if(${BUILD_FAISS_WITH_MKL} STREQUAL "ON")
set(db_libs ${db_libs} ${MKL_LIBS} ${MKL_LIBS})
else()
set(db_libs ${db_libs}
lapack
openblas)
endif()
target_link_libraries(db_test ${db_libs} ${knowhere_libs} ${unittest_libs}) target_link_libraries(db_test ${db_libs} ${knowhere_libs} ${unittest_libs})
install(TARGETS db_test DESTINATION unittest) install(TARGETS db_test DESTINATION unittest)
......
...@@ -8,13 +8,6 @@ set(helper ...@@ -8,13 +8,6 @@ set(helper
set(knowhere_libs set(knowhere_libs
knowhere knowhere
SPTAGLibStatic
arrow
jemalloc_pic
faiss
openblas
lapack
tbb
cudart cudart
cublas cublas
) )
......
#set(CURL_LIBRARY "-lcurl")
#find_package(CURL REQUIRED)
#INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
#
#INCLUDE_DIRECTORIES(~/development/lib/usr/local/include)
#LINK_DIRECTORIES(~/development/lib/usr/local/lib)
include_directories(../../src) include_directories(../../src)
...@@ -72,13 +62,6 @@ add_executable(metrics_test ${count_test_src} ${require_files} ) ...@@ -72,13 +62,6 @@ add_executable(metrics_test ${count_test_src} ${require_files} )
set(knowhere_libs set(knowhere_libs
knowhere knowhere
SPTAGLibStatic
arrow
jemalloc_pic
faiss
openblas
lapack
tbb
) )
target_link_libraries(metrics_test target_link_libraries(metrics_test
...@@ -96,12 +79,5 @@ target_link_libraries(metrics_test ...@@ -96,12 +79,5 @@ target_link_libraries(metrics_test
mysqlpp mysqlpp
${unittest_libs} ${unittest_libs}
) )
if(${BUILD_FAISS_WITH_MKL} STREQUAL "ON")
target_link_libraries(metrics_test ${MKL_LIBS} ${MKL_LIBS})
else()
target_link_libraries(metrics_test
lapack
openblas)
endif()
install(TARGETS metrics_test DESTINATION unittest) install(TARGETS metrics_test DESTINATION unittest)
\ No newline at end of file
...@@ -33,8 +33,6 @@ link_directories("/usr/local/cuda/lib64") ...@@ -33,8 +33,6 @@ link_directories("/usr/local/cuda/lib64")
include_directories(/usr/include/mysql) include_directories(/usr/include/mysql)
#add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
set(scheduler_test_src set(scheduler_test_src
${unittest_srcs} ${unittest_srcs}
${test_srcs} ${test_srcs}
...@@ -69,25 +67,10 @@ set(scheduler_libs ...@@ -69,25 +67,10 @@ set(scheduler_libs
set(knowhere_libs set(knowhere_libs
knowhere knowhere
SPTAGLibStatic
arrow
jemalloc_pic
faiss
openblas
lapack
tbb
cudart cudart
cublas cublas
) )
if (${BUILD_FAISS_WITH_MKL} STREQUAL "ON")
set(db_libs ${db_libs} ${MKL_LIBS} ${MKL_LIBS})
else ()
set(db_libs ${db_libs}
lapack
openblas)
endif ()
target_link_libraries(scheduler_test ${scheduler_libs} ${knowhere_libs} ${unittest_libs}) target_link_libraries(scheduler_test ${scheduler_libs} ${knowhere_libs} ${unittest_libs})
......
...@@ -34,9 +34,6 @@ cuda_add_executable(server_test ...@@ -34,9 +34,6 @@ cuda_add_executable(server_test
set(require_libs set(require_libs
knowhere knowhere
faiss
openblas
lapack
stdc++ stdc++
cudart cudart
cublas cublas
...@@ -51,14 +48,6 @@ set(require_libs ...@@ -51,14 +48,6 @@ set(require_libs
pthread pthread
) )
if(${BUILD_FAISS_WITH_MKL} STREQUAL "ON")
set(require_libs ${require_libs} ${MKL_LIBS} ${MKL_LIBS})
else()
set(require_libs ${require_libs}
lapack
openblas)
endif()
target_link_libraries(server_test target_link_libraries(server_test
${require_libs} ${require_libs}
${cuda_library} ${cuda_library}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册