mirror of https://github.com/milvus-io/milvus.git
Rename simd configuration valid values for better readability (#11410)
Signed-off-by: yudong.cai <yudong.cai@zilliz.com>pull/11469/head
parent
caf3a2405d
commit
14c37058e3
|
@ -10,11 +10,13 @@
|
|||
// or implied. See the License for the specific language governing permissions and limitations under the License
|
||||
|
||||
#include <mutex>
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "knowhere/archive/KnowhereConfig.h"
|
||||
#include "easyloggingpp/easylogging++.h"
|
||||
|
||||
#include "ConfigKnowhere.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "easyloggingpp/easylogging++.h"
|
||||
#include "faiss/FaissHook.h"
|
||||
#include "log/Log.h"
|
||||
#include "knowhere/archive/KnowhereConfig.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace config {
|
||||
|
@ -46,12 +48,17 @@ KnowhereSetSimdType(const char* value) {
|
|||
simd_type = milvus::engine::KnowhereConfig::SimdType::AVX512;
|
||||
} else if (strcmp(value, "avx2") == 0) {
|
||||
simd_type = milvus::engine::KnowhereConfig::SimdType::AVX2;
|
||||
} else if (strcmp(value, "sse") == 0) {
|
||||
simd_type = milvus::engine::KnowhereConfig::SimdType::SSE;
|
||||
} else if (strcmp(value, "avx") == 0 || strcmp(value, "sse4_2") == 0) {
|
||||
simd_type = milvus::engine::KnowhereConfig::SimdType::SSE4_2;
|
||||
} else {
|
||||
PanicInfo("invalid SIMD type: " + std::string(value));
|
||||
}
|
||||
return milvus::engine::KnowhereConfig::SetSimdType(simd_type);
|
||||
try {
|
||||
return milvus::engine::KnowhereConfig::SetSimdType(simd_type);
|
||||
} catch (std::exception& e) {
|
||||
LOG_SERVER_ERROR_ << e.what();
|
||||
PanicInfo(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace config
|
||||
|
|
|
@ -32,22 +32,26 @@ constexpr int64_t M_BYTE = 1024 * 1024;
|
|||
|
||||
std::string
|
||||
KnowhereConfig::SetSimdType(const SimdType simd_type) {
|
||||
if (simd_type == SimdType::AVX512) {
|
||||
if (simd_type == SimdType::AUTO) {
|
||||
faiss::faiss_use_avx512 = true;
|
||||
faiss::faiss_use_avx2 = false;
|
||||
faiss::faiss_use_sse = false;
|
||||
faiss::faiss_use_avx2 = true;
|
||||
faiss::faiss_use_sse4_2 = true;
|
||||
LOG_KNOWHERE_DEBUG_ << "FAISS expect simdType::AUTO";
|
||||
} else if (simd_type == SimdType::AVX512) {
|
||||
faiss::faiss_use_avx512 = true;
|
||||
faiss::faiss_use_avx2 = true;
|
||||
faiss::faiss_use_sse4_2 = true;
|
||||
LOG_KNOWHERE_DEBUG_ << "FAISS expect simdType::AVX512";
|
||||
} else if (simd_type == SimdType::AVX2) {
|
||||
faiss::faiss_use_avx512 = false;
|
||||
faiss::faiss_use_avx2 = true;
|
||||
faiss::faiss_use_sse = false;
|
||||
} else if (simd_type == SimdType::SSE) {
|
||||
faiss::faiss_use_sse4_2 = true;
|
||||
LOG_KNOWHERE_DEBUG_ << "FAISS expect simdType::AVX2";
|
||||
} else if (simd_type == SimdType::SSE4_2) {
|
||||
faiss::faiss_use_avx512 = false;
|
||||
faiss::faiss_use_avx2 = false;
|
||||
faiss::faiss_use_sse = true;
|
||||
} else {
|
||||
faiss::faiss_use_avx512 = true;
|
||||
faiss::faiss_use_avx2 = true;
|
||||
faiss::faiss_use_sse = true;
|
||||
faiss::faiss_use_sse4_2 = true;
|
||||
LOG_KNOWHERE_DEBUG_ << "FAISS expect simdType::SSE4_2";
|
||||
}
|
||||
|
||||
std::string cpu_flag;
|
||||
|
|
|
@ -26,7 +26,7 @@ class KnowhereConfig {
|
|||
*/
|
||||
enum SimdType {
|
||||
AUTO = 0, // enable all and depend on the system
|
||||
SSE, // only enable SSE
|
||||
SSE4_2, // only enable SSE4_2
|
||||
AVX2, // only enable AVX2
|
||||
AVX512, // only enable AVX512
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace faiss {
|
|||
|
||||
bool faiss_use_avx512 = true;
|
||||
bool faiss_use_avx2 = true;
|
||||
bool faiss_use_sse = true;
|
||||
bool faiss_use_sse4_2 = true;
|
||||
|
||||
/* set default to AVX */
|
||||
fvec_func_ptr fvec_inner_product = fvec_inner_product_avx;
|
||||
|
@ -48,8 +48,8 @@ bool support_avx2() {
|
|||
return (instruction_set_inst.AVX2());
|
||||
}
|
||||
|
||||
bool support_sse() {
|
||||
if (!faiss_use_sse) return false;
|
||||
bool support_sse4_2() {
|
||||
if (!faiss_use_sse4_2) return false;
|
||||
|
||||
InstructionSet& instruction_set_inst = InstructionSet::GetInstance();
|
||||
return (instruction_set_inst.SSE42());
|
||||
|
@ -85,7 +85,7 @@ bool hook_init(std::string& cpu_flag) {
|
|||
sq_sel_inv_list_scanner = sq_select_inverted_list_scanner_avx;
|
||||
|
||||
cpu_flag = "AVX2";
|
||||
} else if (support_sse()) {
|
||||
} else if (support_sse4_2()) {
|
||||
/* for IVFFLAT */
|
||||
fvec_inner_product = fvec_inner_product_sse;
|
||||
fvec_L2sqr = fvec_L2sqr_sse;
|
||||
|
@ -97,7 +97,7 @@ bool hook_init(std::string& cpu_flag) {
|
|||
sq_sel_quantizer = sq_select_quantizer_ref;
|
||||
sq_sel_inv_list_scanner = sq_select_inverted_list_scanner_ref;
|
||||
|
||||
cpu_flag = "SSE42";
|
||||
cpu_flag = "SSE4_2";
|
||||
} else {
|
||||
cpu_flag = "UNSUPPORTED";
|
||||
return false;
|
||||
|
|
|
@ -20,7 +20,7 @@ typedef InvertedListScanner* (*sq_sel_inv_list_scanner_func_ptr)(MetricType, con
|
|||
|
||||
extern bool faiss_use_avx512;
|
||||
extern bool faiss_use_avx2;
|
||||
extern bool faiss_use_sse;
|
||||
extern bool faiss_use_sse4_2;
|
||||
|
||||
extern fvec_func_ptr fvec_inner_product;
|
||||
extern fvec_func_ptr fvec_L2sqr;
|
||||
|
@ -33,7 +33,7 @@ extern sq_sel_inv_list_scanner_func_ptr sq_sel_inv_list_scanner;
|
|||
|
||||
extern bool support_avx512();
|
||||
extern bool support_avx2();
|
||||
extern bool support_sse();
|
||||
extern bool support_sse4_2();
|
||||
|
||||
extern bool hook_init(std::string& cpu_flag);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ TEST_F(KnowhereTest, KNOWHERE_RESOURCE_TEST) {
|
|||
ASSERT_TRUE(s.ok());
|
||||
|
||||
KnowhereConfig::SetSimdType(KnowhereConfig::SimdType::AUTO);
|
||||
KnowhereConfig::SetSimdType(KnowhereConfig::SimdType::SSE);
|
||||
KnowhereConfig::SetSimdType(KnowhereConfig::SimdType::SSE4_2);
|
||||
KnowhereConfig::SetSimdType(KnowhereConfig::SimdType::AVX2);
|
||||
KnowhereConfig::SetSimdType(KnowhereConfig::SimdType::AVX512);
|
||||
|
||||
|
|
|
@ -33,14 +33,14 @@ const valueEnum ClusterRoleMap{
|
|||
|
||||
enum SimdType {
|
||||
AUTO = 1,
|
||||
SSE,
|
||||
SSE4_2,
|
||||
AVX2,
|
||||
AVX512,
|
||||
};
|
||||
|
||||
const valueEnum SimdMap{
|
||||
{"auto", SimdType::AUTO},
|
||||
{"sse", SimdType::SSE},
|
||||
{"sse4_2", SimdType::SSE4_2},
|
||||
{"avx2", SimdType::AVX2},
|
||||
{"avx512", SimdType::AVX512},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue