From a023511f16ff11361d77815223a45d2acdb8a7ef Mon Sep 17 00:00:00 2001 From: "yudong.cai" Date: Fri, 29 Nov 2019 16:02:08 +0800 Subject: [PATCH] #611 remove MILVUS_CPU_VERSION --- CHANGELOG.md | 1 + core/CMakeLists.txt | 3 --- core/src/db/DBImpl.cpp | 6 +++--- core/src/db/engine/ExecutionEngineImpl.cpp | 18 +++++++++--------- core/src/main.cpp | 6 +++--- core/src/server/Server.cpp | 6 +++--- core/unittest/db/utils.cpp | 17 ++++++++--------- core/unittest/server/utils.cpp | 19 ++++++++----------- core/unittest/wrapper/utils.cpp | 17 ++++++++--------- 9 files changed, 43 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 594e886904..62addc6099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ Please mark all change in change log and use the ticket from JIRA. - \#449 - Add ShowPartitions example for C++ SDK - \#470 - Small raw files should not be build index - \#584 - Intergrate internal FAISS +- \#611 - Remove MILVUS_CPU_VERSION ## Task diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index cf022f94a2..dd482f6464 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -146,7 +146,6 @@ if (CUSTOMIZATION) add_compile_definitions(CUSTOMIZATION) endif () -set(MILVUS_CPU_VERSION false) if (MILVUS_GPU_VERSION) message(STATUS "Building Milvus GPU version") add_compile_definitions("MILVUS_GPU_VERSION") @@ -155,8 +154,6 @@ if (MILVUS_GPU_VERSION) set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler -fPIC -std=c++11 -D_FORCE_INLINES --expt-extended-lambda") else () message(STATUS "Building Milvus CPU version") - set(MILVUS_CPU_VERSION true) - add_compile_definitions("MILVUS_CPU_VERSION") endif () if (MILVUS_WITH_PROMETHEUS) diff --git a/core/src/db/DBImpl.cpp b/core/src/db/DBImpl.cpp index 8e08a850f8..51c7ea5383 100644 --- a/core/src/db/DBImpl.cpp +++ b/core/src/db/DBImpl.cpp @@ -1033,10 +1033,10 @@ DBImpl::BuildTableIndexRecursively(const std::string& table_id, const TableIndex if (!failed_files.empty()) { std::string msg = "Failed to build index for " + std::to_string(failed_files.size()) + ((failed_files.size() == 1) ? " file" : " files"); -#ifdef MILVUS_CPU_VERSION - msg += ", please double check index parameters."; -#else +#ifdef MILVUS_GPU_VERSION msg += ", file size is too large or gpu memory is not enough."; +#else + msg += ", please double check index parameters."; #endif return Status(DB_ERROR, msg); } diff --git a/core/src/db/engine/ExecutionEngineImpl.cpp b/core/src/db/engine/ExecutionEngineImpl.cpp index 5a3d6e5e2a..9c6a2a0f33 100644 --- a/core/src/db/engine/ExecutionEngineImpl.cpp +++ b/core/src/db/engine/ExecutionEngineImpl.cpp @@ -93,18 +93,18 @@ ExecutionEngineImpl::CreatetVecIndex(EngineType type) { break; } case EngineType::FAISS_IVFFLAT: { -#ifdef MILVUS_CPU_VERSION - index = GetVecIndexFactory(IndexType::FAISS_IVFFLAT_CPU); -#else +#ifdef MILVUS_GPU_VERSION index = GetVecIndexFactory(IndexType::FAISS_IVFFLAT_MIX); +#else + index = GetVecIndexFactory(IndexType::FAISS_IVFFLAT_CPU); #endif break; } case EngineType::FAISS_IVFSQ8: { -#ifdef MILVUS_CPU_VERSION - index = GetVecIndexFactory(IndexType::FAISS_IVFSQ8_CPU); -#else +#ifdef MILVUS_GPU_VERSION index = GetVecIndexFactory(IndexType::FAISS_IVFSQ8_MIX); +#else + index = GetVecIndexFactory(IndexType::FAISS_IVFSQ8_CPU); #endif break; } @@ -119,10 +119,10 @@ ExecutionEngineImpl::CreatetVecIndex(EngineType type) { } #endif case EngineType::FAISS_PQ: { -#ifdef MILVUS_CPU_VERSION - index = GetVecIndexFactory(IndexType::FAISS_IVFPQ_CPU); -#else +#ifdef MILVUS_GPU_VERSION index = GetVecIndexFactory(IndexType::FAISS_IVFPQ_MIX); +#else + index = GetVecIndexFactory(IndexType::FAISS_IVFPQ_CPU); #endif break; } diff --git a/core/src/main.cpp b/core/src/main.cpp index 5c97a061d2..670a992d29 100644 --- a/core/src/main.cpp +++ b/core/src/main.cpp @@ -58,10 +58,10 @@ print_banner() { << "OpenBLAS" #endif << " library." << std::endl; -#ifdef MILVUS_CPU_VERSION - std::cout << "You are using Milvus CPU edition" << std::endl; -#else +#ifdef MILVUS_GPU_VERSION std::cout << "You are using Milvus GPU edition" << std::endl; +#else + std::cout << "You are using Milvus CPU edition" << std::endl; #endif std::cout << std::endl; } diff --git a/core/src/server/Server.cpp b/core/src/server/Server.cpp index 169463080e..100db5d2ec 100644 --- a/core/src/server/Server.cpp +++ b/core/src/server/Server.cpp @@ -183,10 +183,10 @@ Server::Start() { // print version information SERVER_LOG_INFO << "Milvus " << BUILD_TYPE << " version: v" << MILVUS_VERSION << ", built at " << BUILD_TIME; -#ifdef MILVUS_CPU_VERSION - SERVER_LOG_INFO << "CPU edition"; -#else +#ifdef MILVUS_GPU_VERSION SERVER_LOG_INFO << "GPU edition"; +#else + SERVER_LOG_INFO << "CPU edition"; #endif server::Metrics::GetInstance().Init(); server::SystemInfo::GetInstance().Init(); diff --git a/core/unittest/db/utils.cpp b/core/unittest/db/utils.cpp index 293eeccc69..a57bae79b5 100644 --- a/core/unittest/db/utils.cpp +++ b/core/unittest/db/utils.cpp @@ -68,17 +68,16 @@ static const char* CONFIG_STR = "engine_config:\n" " use_blas_threshold: 20\n" "\n" - "resource_config:\n" -#ifdef MILVUS_CPU_VERSION - " search_resources:\n" - " - cpu\n" - " index_build_device: cpu # CPU used for building index"; -#else - " search_resources:\n" - " - cpu\n" +#ifdef MILVUS_GPU_VERSION + "gpu_resource_config:\n" + " enable: true # whether to enable GPU resources\n" + " cache_capacity: 4 # GB, size of GPU memory per card used for cache, must be a positive integer\n" + " search_resources: # define the GPU devices used for search computation, must be in format gpux\n" + " - gpu0\n" + " build_index_resources: # define the GPU devices used for index building, must be in format gpux\n" " - gpu0\n" - " index_build_device: gpu0 # GPU used for building index"; #endif + "\n"; void WriteToFile(const std::string& file_path, const char* content) { diff --git a/core/unittest/server/utils.cpp b/core/unittest/server/utils.cpp index 6fb424356d..c232b1185a 100644 --- a/core/unittest/server/utils.cpp +++ b/core/unittest/server/utils.cpp @@ -54,24 +54,21 @@ static const char* VALID_CONFIG_STR = "cache_config:\n" " cpu_cache_capacity: 16 # GB, CPU memory used for cache\n" " cpu_cache_threshold: 0.85 \n" - " gpu_cache_capacity: 4 # GB, GPU memory used for cache\n" - " gpu_cache_threshold: 0.85 \n" " cache_insert_data: false # whether to load inserted data into cache\n" "\n" "engine_config:\n" " use_blas_threshold: 20 \n" "\n" - "resource_config:\n" -#ifdef MILVUS_CPU_VERSION - " search_resources:\n" - " - cpu\n" - " index_build_device: cpu # CPU used for building index"; -#else - " search_resources:\n" - " - cpu\n" +#ifdef MILVUS_GPU_VERSION + "gpu_resource_config:\n" + " enable: true # whether to enable GPU resources\n" + " cache_capacity: 4 # GB, size of GPU memory per card used for cache, must be a positive integer\n" + " search_resources: # define the GPU devices used for search computation, must be in format gpux\n" + " - gpu0\n" + " build_index_resources: # define the GPU devices used for index building, must be in format gpux\n" " - gpu0\n" - " index_build_device: gpu0 # GPU used for building index"; #endif + "\n"; static const char* INVALID_CONFIG_STR = "*INVALID*"; diff --git a/core/unittest/wrapper/utils.cpp b/core/unittest/wrapper/utils.cpp index 96b9e643f5..a5f8e1b6b2 100644 --- a/core/unittest/wrapper/utils.cpp +++ b/core/unittest/wrapper/utils.cpp @@ -56,17 +56,16 @@ static const char* CONFIG_STR = "engine_config:\n" " blas_threshold: 20\n" "\n" - "resource_config:\n" -#ifdef MILVUS_CPU_VERSION - " search_resources:\n" - " - cpu\n" - " index_build_device: cpu # CPU used for building index"; -#else - " search_resources:\n" - " - cpu\n" +#ifdef MILVUS_GPU_VERSION + "gpu_resource_config:\n" + " enable: true # whether to enable GPU resources\n" + " cache_capacity: 4 # GB, size of GPU memory per card used for cache, must be a positive integer\n" + " search_resources: # define the GPU devices used for search computation, must be in format gpux\n" + " - gpu0\n" + " build_index_resources: # define the GPU devices used for index building, must be in format gpux\n" " - gpu0\n" - " index_build_device: gpu0 # GPU used for building index"; #endif + "\n"; void WriteToFile(const std::string& file_path, const char* content) {