add cpu instruction sets check (#2055)

Signed-off-by: Yhz <yinghao.zou@zilliz.com>
pull/2125/head
BossZou 2020-04-26 00:59:25 +08:00 committed by GitHub
parent 7e771c5356
commit 8edb7b6a09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 101 additions and 1 deletions

View File

@ -16,6 +16,7 @@ Please mark all change in change log and use the issue from GitHub
- \#1752 Add api GetVectorsByID
- \#1962 Add api HasPartition
- \#1965 FAISS/NSG/HNSW/ANNOY use unified distance calculation algorithm
- \#2054 Check if CPU instruction sets are illegal
- \#2064 Warn when use SQLite as metadata management
## Improvement

View File

@ -77,11 +77,13 @@ set(thirdparty_files
)
aux_source_directory(${MILVUS_ENGINE_SRC}/server server_service_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/server/init server_init_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/server/delivery/request delivery_request_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/server/delivery/hybrid_request delivery_hybrid_request_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/server/delivery/strategy delivery_strategy_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/server/delivery delivery_files)
set(server_files
${server_init_files}
${server_service_files}
${delivery_request_files}
${delivery_hybrid_request_files}

View File

@ -19,6 +19,7 @@
#include "server/Server.h"
#include "src/version.h"
#include "utils/SignalUtil.h"
#include "utils/Status.h"
INITIALIZE_EASYLOGGINGPP

View File

@ -12,8 +12,8 @@
#include "server/Server.h"
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <cstring>
#include "config/Config.h"
#include "index/archive/KnowhereResource.h"
@ -21,6 +21,7 @@
#include "scheduler/SchedInst.h"
#include "server/DBWrapper.h"
#include "server/grpc_impl/GrpcServer.h"
#include "server/init/CpuChecker.h"
#include "server/web_impl/WebServer.h"
#include "src/version.h"
//#include "storage/s3/S3ClientWrapper.h"
@ -195,6 +196,10 @@ Server::Start() {
#else
LOG_SERVER_INFO_ << "CPU edition";
#endif
s = CpuChecker::CheckCpuInstructionSet();
if (!s.ok()) {
return s;
}
/* record config and hardware information into log */
LogConfigInFile(config_filename_);
LogCpuInfo();

View File

@ -0,0 +1,61 @@
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#include "server/init/CpuChecker.h"
#include <iostream>
#include <string>
#include <vector>
#include "faiss/FaissHook.h"
#include "faiss/utils/instruction_set.h"
#include "utils/Log.h"
#include "utils/StringHelpFunctions.h"
namespace milvus {
namespace server {
Status
CpuChecker::CheckCpuInstructionSet() {
std::vector<std::string> instruction_sets;
auto& instruction_set_inst = faiss::InstructionSet::GetInstance();
if (faiss::support_avx512()) {
instruction_sets.emplace_back("avx512");
}
if (instruction_set_inst.AVX2()) {
instruction_sets.emplace_back("avx2");
}
if (instruction_set_inst.SSE42()) {
instruction_sets.emplace_back("sse4_2");
}
if (instruction_sets.empty()) {
std::string msg =
"CPU instruction sets are not supported. Ensure the CPU supports at least one of the following instruction "
"sets: sse4_2, avx2, avx512";
LOG_SERVER_FATAL_ << msg;
std::cerr << msg << std::endl;
return Status(SERVER_UNEXPECTED_ERROR, msg);
}
std::string instruction_sets_msg;
StringHelpFunctions::MergeStringWithDelimeter(instruction_sets, ", ", instruction_sets_msg);
std::string msg = "Supported CPU instruction sets: " + instruction_sets_msg;
LOG_SERVER_INFO_ << msg;
LOG_ENGINE_DEBUG_ << msg;
std::cout << msg << std::endl;
return Status::OK();
}
} // namespace server
} // namespace milvus

View File

@ -0,0 +1,26 @@
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#pragma once
#include "utils/Status.h"
namespace milvus {
namespace server {
class CpuChecker {
public:
static Status
CheckCpuInstructionSet();
};
} // namespace server
} // namespace milvus

View File

@ -51,8 +51,10 @@ class CommonUtil {
static void
ConvertTime(tm time_struct, time_t& time_integer);
#ifdef MILVUS_ENABLE_PROFILING
static std::string
GetCurrentTimeStr();
#endif
static void
EraseFromCache(const std::string& item_key);

View File

@ -66,6 +66,7 @@ set(thirdparty_files
)
aux_source_directory(${MILVUS_ENGINE_SRC}/server server_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/server/init server_init_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/server/grpc_impl grpc_impl_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/server/grpc_impl/interceptor grpc_interceptor_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/server/context server_context_files)
@ -146,6 +147,7 @@ set(common_files
${wrapper_files}
${storage_files}
${helper_files}
${server_init_files}
${server_context_files}
${tracing_files}
${codecs_files}