未验证 提交 512fe623 编写于 作者: C Cai Yudong 提交者: GitHub

#1649 fix Milvus crash on old cpu (#1652)

* #1649 fix Milvus crash on old cpu
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* #1649 update debug log
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* retry CI
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>
上级 5f2f8bdc
......@@ -17,6 +17,7 @@ Please mark all change in change log and use the issue from GitHub
- \#1546 Move Config.cpp to config directory
- \#1547 Rename storage/file to storage/disk and rename classes
- \#1548 Move store/Directory to storage/Operation and add FSHandler
- \#1649 Fix Milvus crash on old CPU
## Task
......
......@@ -48,7 +48,7 @@ bool support_sse() {
return (instruction_set_inst.SSE());
}
std::string hook_init() {
bool hook_init(std::string& cpu_flag) {
static std::mutex hook_mutex;
std::lock_guard<std::mutex> lock(hook_mutex);
......@@ -64,8 +64,7 @@ std::string hook_init() {
sq_get_distance_computer_IP = sq_get_distance_computer_IP_avx512;
sq_sel_quantizer = sq_select_quantizer_avx512;
std::cout << "FAISS hook AVX512" << std::endl;
return "AVX512";
cpu_flag = "AVX512";
} else if (support_avx()) {
/* for IVFFLAT */
fvec_inner_product = fvec_inner_product_avx;
......@@ -78,8 +77,7 @@ std::string hook_init() {
sq_get_distance_computer_IP = sq_get_distance_computer_IP_avx;
sq_sel_quantizer = sq_select_quantizer_avx;
std::cout << "FAISS hook AVX" << std::endl;
return "AVX";
cpu_flag = "AVX";
} else if (support_sse()) {
/* for IVFFLAT */
fvec_inner_product = fvec_inner_product_sse;
......@@ -92,12 +90,13 @@ std::string hook_init() {
sq_get_distance_computer_IP = sq_get_distance_computer_IP_sse;
sq_sel_quantizer = sq_select_quantizer_sse;
std::cout << "FAISS hook SSE" << std::endl;
return "SSE";
cpu_flag = "SSE";
} else {
FAISS_ASSERT_MSG(false, "CPU not supported!");
return "UNSUPPORTED";
cpu_flag = "UNSUPPORTED";
return false;
}
return true;
}
} // namespace faiss
......@@ -29,6 +29,6 @@ extern sq_sel_func_ptr sq_sel_quantizer;
extern bool support_avx512();
extern std::string hook_init();
extern bool hook_init(std::string& cpu_flag);
} // namespace faiss
......@@ -17,6 +17,7 @@
#include "config/Config.h"
#include "faiss/FaissHook.h"
#include "scheduler/Utils.h"
#include "utils/Error.h"
#include "utils/Log.h"
#include <fiu-local.h>
......@@ -37,8 +38,12 @@ KnowhereResource::Initialize() {
bool use_avx512 = true;
CONFIG_CHECK(config.GetEngineConfigUseAVX512(use_avx512));
faiss::faiss_use_avx512 = use_avx512;
std::string type = faiss::hook_init();
ENGINE_LOG_DEBUG << "FAISS hook " << type;
std::string cpu_flag;
if (faiss::hook_init(cpu_flag)) {
ENGINE_LOG_DEBUG << "FAISS hook " << cpu_flag;
} else {
return Status(KNOWHERE_UNEXPECTED_ERROR, "FAISS hook fail, CPU not supported!");
}
#ifdef MILVUS_GPU_VERSION
bool enable_gpu = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册