From d460f48ce9d30ffcc09d17834272ce9855d9dadd Mon Sep 17 00:00:00 2001 From: Cai Yudong Date: Tue, 3 Mar 2020 13:55:27 +0800 Subject: [PATCH] #1480 add return code for AVX512 selection (#1482) Signed-off-by: yudong.cai --- CHANGELOG.md | 3 ++- core/src/index/thirdparty/faiss/FaissHook.cpp | 6 +++++- core/src/index/thirdparty/faiss/FaissHook.h | 3 ++- core/src/wrapper/KnowhereResource.cpp | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee28c7af32..6b3504adc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,8 +69,9 @@ Please mark all change in change log and use the issue from GitHub - \#1234 Do S3 server validation check when Milvus startup - \#1263 Allow system conf modifiable and some take effect directly - \#1320 Remove debug logging from faiss -- \#1426 - Support to configure whether to enabled autoflush and the autoflush interval +- \#1426 Support to configure whether to enabled autoflush and the autoflush interval - \#1444 Improve delete +- \#1480 Add return code for AVX512 selection ## Task diff --git a/core/src/index/thirdparty/faiss/FaissHook.cpp b/core/src/index/thirdparty/faiss/FaissHook.cpp index 543b4e3a52..0e462e4dd4 100644 --- a/core/src/index/thirdparty/faiss/FaissHook.cpp +++ b/core/src/index/thirdparty/faiss/FaissHook.cpp @@ -48,7 +48,7 @@ bool support_sse() { return (instruction_set_inst.SSE()); } -void hook_init() { +std::string hook_init() { static std::mutex hook_mutex; std::lock_guard lock(hook_mutex); @@ -65,6 +65,7 @@ void hook_init() { sq_sel_quantizer = sq_select_quantizer_avx512; std::cout << "FAISS hook AVX512" << std::endl; + return "AVX512"; } else if (support_avx()) { /* for IVFFLAT */ fvec_inner_product = fvec_inner_product_avx; @@ -78,6 +79,7 @@ void hook_init() { sq_sel_quantizer = sq_select_quantizer_avx; std::cout << "FAISS hook AVX" << std::endl; + return "AVX"; } else if (support_sse()) { /* for IVFFLAT */ fvec_inner_product = fvec_inner_product_sse; @@ -91,8 +93,10 @@ void hook_init() { sq_sel_quantizer = sq_select_quantizer_sse; std::cout << "FAISS hook SSE" << std::endl; + return "SSE"; } else { FAISS_ASSERT_MSG(false, "CPU not supported!"); + return "UNSUPPORTED"; } } diff --git a/core/src/index/thirdparty/faiss/FaissHook.h b/core/src/index/thirdparty/faiss/FaissHook.h index cdaa44ea39..11666f966f 100644 --- a/core/src/index/thirdparty/faiss/FaissHook.h +++ b/core/src/index/thirdparty/faiss/FaissHook.h @@ -5,6 +5,7 @@ #include #include +#include #include namespace faiss { @@ -28,6 +29,6 @@ extern sq_sel_func_ptr sq_sel_quantizer; extern bool support_avx512(); -extern void hook_init(); +extern std::string hook_init(); } // namespace faiss diff --git a/core/src/wrapper/KnowhereResource.cpp b/core/src/wrapper/KnowhereResource.cpp index 4fcabcb24d..7e046f34ab 100644 --- a/core/src/wrapper/KnowhereResource.cpp +++ b/core/src/wrapper/KnowhereResource.cpp @@ -17,6 +17,7 @@ #include "faiss/FaissHook.h" #include "scheduler/Utils.h" #include "server/Config.h" +#include "utils/Log.h" #include #include @@ -36,7 +37,8 @@ KnowhereResource::Initialize() { bool use_avx512 = true; CONFIG_CHECK(config.GetEngineConfigUseAVX512(use_avx512)); faiss::faiss_use_avx512 = use_avx512; - faiss::hook_init(); + std::string type = faiss::hook_init(); + ENGINE_LOG_DEBUG << "FAISS hook " << type; #ifdef MILVUS_GPU_VERSION bool enable_gpu = false;