提交 37df2b6f 编写于 作者: Y yudong.cai

#346 rename gpu_resource_config.enable_gpu to gpu_resource_config.enable

上级 8c48d95f
...@@ -36,7 +36,7 @@ engine_config: ...@@ -36,7 +36,7 @@ engine_config:
gpu_search_threshold: 1000 # threshold beyond which the search computation is executed on GPUs only gpu_search_threshold: 1000 # threshold beyond which the search computation is executed on GPUs only
gpu_resource_config: gpu_resource_config:
enable_gpu: false # whether to enable GPU resources enable: false # whether to enable GPU resources
cache_capacity: 4 # GB, size of GPU memory per card used for cache, must be a positive integer cache_capacity: 4 # GB, size of GPU memory per card used for cache, must be a positive integer
search_resources: # define the GPU devices used for search computation, must be in format gpux search_resources: # define the GPU devices used for search computation, must be in format gpux
- gpu0 - gpu0
......
...@@ -36,7 +36,7 @@ engine_config: ...@@ -36,7 +36,7 @@ engine_config:
gpu_search_threshold: 1000 # threshold beyond which the search computation is executed on GPUs only gpu_search_threshold: 1000 # threshold beyond which the search computation is executed on GPUs only
gpu_resource_config: gpu_resource_config:
enable_gpu: true # whether to enable GPU resources enable: true # whether to enable GPU resources
cache_capacity: 4 # GB, size of GPU memory per card used for cache, must be a positive integer cache_capacity: 4 # GB, size of GPU memory per card used for cache, must be a positive integer
search_resources: # define the GPU devices used for search computation, must be in format gpux search_resources: # define the GPU devices used for search computation, must be in format gpux
- gpu0 - gpu0
......
...@@ -190,8 +190,8 @@ Config::ValidateConfig() { ...@@ -190,8 +190,8 @@ Config::ValidateConfig() {
/* gpu resource config */ /* gpu resource config */
#ifdef MILVUS_GPU_VERSION #ifdef MILVUS_GPU_VERSION
bool resource_enable_gpu; bool gpu_resource_enable;
s = GetGpuResourceConfigEnableGpu(resource_enable_gpu); s = GetGpuResourceConfigEnable(gpu_resource_enable);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }
...@@ -330,7 +330,7 @@ Config::ResetDefaultConfig() { ...@@ -330,7 +330,7 @@ Config::ResetDefaultConfig() {
/* gpu resource config */ /* gpu resource config */
#ifdef MILVUS_GPU_VERSION #ifdef MILVUS_GPU_VERSION
s = SetGpuResourceConfigEnableGpu(CONFIG_GPU_RESOURCE_ENABLE_GPU_DEFAULT); s = SetGpuResourceConfigEnable(CONFIG_GPU_RESOURCE_ENABLE_DEFAULT);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }
...@@ -641,10 +641,10 @@ Config::CheckEngineConfigGpuSearchThreshold(const std::string& value) { ...@@ -641,10 +641,10 @@ Config::CheckEngineConfigGpuSearchThreshold(const std::string& value) {
} }
Status Status
Config::CheckGpuResourceConfigEnableGpu(const std::string& value) { Config::CheckGpuResourceConfigEnable(const std::string& value) {
if (!ValidationUtil::ValidateStringIsBool(value).ok()) { if (!ValidationUtil::ValidateStringIsBool(value).ok()) {
std::string msg = "Invalid gpu resource config: " + value + std::string msg =
". Possible reason: gpu_resource_config.enable_gpu is not a boolean."; "Invalid gpu resource config: " + value + ". Possible reason: gpu_resource_config.enable is not a boolean.";
return Status(SERVER_INVALID_ARGUMENT, msg); return Status(SERVER_INVALID_ARGUMENT, msg);
} }
return Status::OK(); return Status::OK();
...@@ -992,10 +992,9 @@ Config::GetEngineConfigGpuSearchThreshold(int32_t& value) { ...@@ -992,10 +992,9 @@ Config::GetEngineConfigGpuSearchThreshold(int32_t& value) {
} }
Status Status
Config::GetGpuResourceConfigEnableGpu(bool& value) { Config::GetGpuResourceConfigEnable(bool& value) {
std::string str = std::string str = GetConfigStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_ENABLE, CONFIG_GPU_RESOURCE_ENABLE_DEFAULT);
GetConfigStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_ENABLE_GPU, CONFIG_GPU_RESOURCE_ENABLE_GPU_DEFAULT); Status s = CheckGpuResourceConfigEnable(str);
Status s = CheckGpuResourceConfigEnableGpu(str);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }
...@@ -1006,13 +1005,13 @@ Config::GetGpuResourceConfigEnableGpu(bool& value) { ...@@ -1006,13 +1005,13 @@ Config::GetGpuResourceConfigEnableGpu(bool& value) {
Status Status
Config::GetGpuResourceConfigCacheCapacity(int64_t& value) { Config::GetGpuResourceConfigCacheCapacity(int64_t& value) {
bool enable_gpu = false; bool gpu_resource_enable = false;
Status s = GetGpuResourceConfigEnableGpu(enable_gpu); Status s = GetGpuResourceConfigEnable(gpu_resource_enable);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }
if (!enable_gpu) { if (!gpu_resource_enable) {
std::string msg = "GPU not supported. Possible reason: gpu_resource_config.enable_gpu is set to false."; std::string msg = "GPU not supported. Possible reason: gpu_resource_config.enable is set to false.";
return Status(SERVER_UNSUPPORTED_ERROR, msg); return Status(SERVER_UNSUPPORTED_ERROR, msg);
} }
std::string str = GetConfigStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_CACHE_CAPACITY, std::string str = GetConfigStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_CACHE_CAPACITY,
...@@ -1027,13 +1026,13 @@ Config::GetGpuResourceConfigCacheCapacity(int64_t& value) { ...@@ -1027,13 +1026,13 @@ Config::GetGpuResourceConfigCacheCapacity(int64_t& value) {
Status Status
Config::GetGpuResourceConfigCacheThreshold(float& value) { Config::GetGpuResourceConfigCacheThreshold(float& value) {
bool enable_gpu = false; bool gpu_resource_enable = false;
Status s = GetGpuResourceConfigEnableGpu(enable_gpu); Status s = GetGpuResourceConfigEnable(gpu_resource_enable);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }
if (!enable_gpu) { if (!gpu_resource_enable) {
std::string msg = "GPU not supported. Possible reason: gpu_resource_config.enable_gpu is set to false."; std::string msg = "GPU not supported. Possible reason: gpu_resource_config.enable is set to false.";
return Status(SERVER_UNSUPPORTED_ERROR, msg); return Status(SERVER_UNSUPPORTED_ERROR, msg);
} }
std::string str = GetConfigStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_CACHE_THRESHOLD, std::string str = GetConfigStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_CACHE_THRESHOLD,
...@@ -1048,13 +1047,13 @@ Config::GetGpuResourceConfigCacheThreshold(float& value) { ...@@ -1048,13 +1047,13 @@ Config::GetGpuResourceConfigCacheThreshold(float& value) {
Status Status
Config::GetGpuResourceConfigSearchResources(std::vector<int32_t>& value) { Config::GetGpuResourceConfigSearchResources(std::vector<int32_t>& value) {
bool enable_gpu = false; bool gpu_resource_enable = false;
Status s = GetGpuResourceConfigEnableGpu(enable_gpu); Status s = GetGpuResourceConfigEnable(gpu_resource_enable);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }
if (!enable_gpu) { if (!gpu_resource_enable) {
std::string msg = "GPU not supported. Possible reason: gpu_resource_config.enable_gpu is set to false."; std::string msg = "GPU not supported. Possible reason: gpu_resource_config.enable is set to false.";
return Status(SERVER_UNSUPPORTED_ERROR, msg); return Status(SERVER_UNSUPPORTED_ERROR, msg);
} }
std::string str = GetConfigSequenceStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES, std::string str = GetConfigSequenceStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_SEARCH_RESOURCES,
...@@ -1073,13 +1072,13 @@ Config::GetGpuResourceConfigSearchResources(std::vector<int32_t>& value) { ...@@ -1073,13 +1072,13 @@ Config::GetGpuResourceConfigSearchResources(std::vector<int32_t>& value) {
Status Status
Config::GetGpuResourceConfigBuildIndexResources(std::vector<int32_t>& value) { Config::GetGpuResourceConfigBuildIndexResources(std::vector<int32_t>& value) {
bool enable_gpu = false; bool gpu_resource_enable = false;
Status s = GetGpuResourceConfigEnableGpu(enable_gpu); Status s = GetGpuResourceConfigEnable(gpu_resource_enable);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }
if (!enable_gpu) { if (!gpu_resource_enable) {
std::string msg = "GPU not supported. Possible reason: gpu_resource_config.enable_gpu is set to false."; std::string msg = "GPU not supported. Possible reason: gpu_resource_config.enable is set to false.";
return Status(SERVER_UNSUPPORTED_ERROR, msg); return Status(SERVER_UNSUPPORTED_ERROR, msg);
} }
std::string str = std::string str =
...@@ -1295,12 +1294,12 @@ Config::SetEngineConfigGpuSearchThreshold(const std::string& value) { ...@@ -1295,12 +1294,12 @@ Config::SetEngineConfigGpuSearchThreshold(const std::string& value) {
/* gpu resource config */ /* gpu resource config */
Status Status
Config::SetGpuResourceConfigEnableGpu(const std::string& value) { Config::SetGpuResourceConfigEnable(const std::string& value) {
Status s = CheckGpuResourceConfigEnableGpu(value); Status s = CheckGpuResourceConfigEnable(value);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }
SetConfigValueInMem(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_ENABLE_GPU, value); SetConfigValueInMem(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_ENABLE, value);
return Status::OK(); return Status::OK();
} }
......
...@@ -85,9 +85,9 @@ static const char* CONFIG_ENGINE_GPU_SEARCH_THRESHOLD_DEFAULT = "1000"; ...@@ -85,9 +85,9 @@ static const char* CONFIG_ENGINE_GPU_SEARCH_THRESHOLD_DEFAULT = "1000";
/* gpu resource config */ /* gpu resource config */
static const char* CONFIG_GPU_RESOURCE = "gpu_resource_config"; static const char* CONFIG_GPU_RESOURCE = "gpu_resource_config";
static const char* CONFIG_GPU_RESOURCE_ENABLE_GPU = "enable_gpu"; static const char* CONFIG_GPU_RESOURCE_ENABLE = "enable";
#ifdef MILVUS_GPU_VERSION #ifdef MILVUS_GPU_VERSION
static const char* CONFIG_GPU_RESOURCE_ENABLE_GPU_DEFAULT = "true"; static const char* CONFIG_GPU_RESOURCE_ENABLE_DEFAULT = "true";
#else #else
static const char* CONFIG_GPU_RESOURCE_ENABLE_GPU_DEFAULT = "false"; static const char* CONFIG_GPU_RESOURCE_ENABLE_GPU_DEFAULT = "false";
#endif #endif
...@@ -175,7 +175,7 @@ class Config { ...@@ -175,7 +175,7 @@ class Config {
/* gpu resource config */ /* gpu resource config */
Status Status
CheckGpuResourceConfigEnableGpu(const std::string& value); CheckGpuResourceConfigEnable(const std::string& value);
Status Status
CheckGpuResourceConfigCacheCapacity(const std::string& value); CheckGpuResourceConfigCacheCapacity(const std::string& value);
Status Status
...@@ -244,7 +244,7 @@ class Config { ...@@ -244,7 +244,7 @@ class Config {
/* gpu resource config */ /* gpu resource config */
Status Status
GetGpuResourceConfigEnableGpu(bool& value); GetGpuResourceConfigEnable(bool& value);
Status Status
GetGpuResourceConfigCacheCapacity(int64_t& value); GetGpuResourceConfigCacheCapacity(int64_t& value);
Status Status
...@@ -305,7 +305,7 @@ class Config { ...@@ -305,7 +305,7 @@ class Config {
/* gpu resource config */ /* gpu resource config */
Status Status
SetGpuResourceConfigEnableGpu(const std::string& value); SetGpuResourceConfigEnable(const std::string& value);
Status Status
SetGpuResourceConfigCacheCapacity(const std::string& value); SetGpuResourceConfigCacheCapacity(const std::string& value);
Status Status
......
...@@ -246,9 +246,9 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) { ...@@ -246,9 +246,9 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) {
/* gpu resource config */ /* gpu resource config */
bool resource_enable_gpu = true; bool resource_enable_gpu = true;
s = config.SetGpuResourceConfigEnableGpu(std::to_string(resource_enable_gpu)); s = config.SetGpuResourceConfigEnable(std::to_string(resource_enable_gpu));
ASSERT_TRUE(s.ok()); ASSERT_TRUE(s.ok());
s = config.GetGpuResourceConfigEnableGpu(bool_val); s = config.GetGpuResourceConfigEnable(bool_val);
ASSERT_TRUE(s.ok()); ASSERT_TRUE(s.ok());
ASSERT_TRUE(bool_val == resource_enable_gpu); ASSERT_TRUE(bool_val == resource_enable_gpu);
...@@ -394,7 +394,7 @@ TEST_F(ConfigTest, SERVER_CONFIG_INVALID_TEST) { ...@@ -394,7 +394,7 @@ TEST_F(ConfigTest, SERVER_CONFIG_INVALID_TEST) {
ASSERT_FALSE(s.ok()); ASSERT_FALSE(s.ok());
/* gpu resource config */ /* gpu resource config */
s = config.SetGpuResourceConfigEnableGpu("ok"); s = config.SetGpuResourceConfigEnable("ok");
ASSERT_FALSE(s.ok()); ASSERT_FALSE(s.ok());
#ifdef MILVUS_GPU_VERSION #ifdef MILVUS_GPU_VERSION
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册