Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
7f5c2fef
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7f5c2fef
编写于
11月 19, 2019
作者:
F
fishpenguin
浏览文件
操作
浏览文件
下载
差异文件
Remove OnlyGpuPass and add MILVUS_GPU_VERSION define
上级
0a858939
0d1923c6
变更
22
展开全部
隐藏空白更改
内联
并排
Showing
22 changed file
with
378 addition
and
601 deletion
+378
-601
core/conf/server_cpu_config.template
core/conf/server_cpu_config.template
+8
-7
core/conf/server_gpu_config.template
core/conf/server_gpu_config.template
+6
-8
core/src/cache/GpuCacheMgr.cpp
core/src/cache/GpuCacheMgr.cpp
+2
-2
core/src/db/engine/ExecutionEngineImpl.cpp
core/src/db/engine/ExecutionEngineImpl.cpp
+11
-2
core/src/scheduler/SchedInst.cpp
core/src/scheduler/SchedInst.cpp
+8
-11
core/src/scheduler/SchedInst.h
core/src/scheduler/SchedInst.h
+7
-16
core/src/scheduler/TaskCreator.cpp
core/src/scheduler/TaskCreator.cpp
+1
-2
core/src/scheduler/Utils.cpp
core/src/scheduler/Utils.cpp
+0
-76
core/src/scheduler/Utils.h
core/src/scheduler/Utils.h
+0
-6
core/src/scheduler/optimizer/BuildIndexPass.cpp
core/src/scheduler/optimizer/BuildIndexPass.cpp
+4
-10
core/src/scheduler/optimizer/BuildIndexPass.h
core/src/scheduler/optimizer/BuildIndexPass.h
+2
-2
core/src/scheduler/optimizer/LargeSQ8HPass.cpp
core/src/scheduler/optimizer/LargeSQ8HPass.cpp
+1
-1
core/src/scheduler/optimizer/LargeSQ8HPass.h
core/src/scheduler/optimizer/LargeSQ8HPass.h
+1
-0
core/src/scheduler/optimizer/OnlyCPUPass.cpp
core/src/scheduler/optimizer/OnlyCPUPass.cpp
+0
-4
core/src/scheduler/optimizer/OnlyGPUPass.cpp
core/src/scheduler/optimizer/OnlyGPUPass.cpp
+0
-54
core/src/scheduler/optimizer/OnlyGPUPass.h
core/src/scheduler/optimizer/OnlyGPUPass.h
+0
-51
core/src/server/Config.cpp
core/src/server/Config.cpp
+228
-229
core/src/server/Config.h
core/src/server/Config.h
+40
-45
core/src/wrapper/KnowhereResource.cpp
core/src/wrapper/KnowhereResource.cpp
+5
-12
core/unittest/db/utils.cpp
core/unittest/db/utils.cpp
+4
-0
core/unittest/server/test_config.cpp
core/unittest/server/test_config.cpp
+50
-62
core/unittest/server/test_rpc.cpp
core/unittest/server/test_rpc.cpp
+0
-1
未找到文件。
core/conf/server_cpu_config.template
浏览文件 @
7f5c2fef
...
@@ -27,8 +27,7 @@ metric_config:
...
@@ -27,8 +27,7 @@ metric_config:
port: 8080 # port prometheus uses to fetch metrics, must in range [1025, 65534]
port: 8080 # port prometheus uses to fetch metrics, must in range [1025, 65534]
cache_config:
cache_config:
cpu_cache_capacity: 16 # GB, CPU memory used for cache, must be a positive integer
cpu_cache_capacity: 16 # GB, size of CPU memory used for cache, must be a positive integer
cpu_cache_threshold: 0.85 # percentage of data that will be kept when cache cleanup is triggered, must be in range (0.0, 1.0]
cache_insert_data: false # whether to load inserted data into cache, must be a boolean
cache_insert_data: false # whether to load inserted data into cache, must be a boolean
engine_config:
engine_config:
...
@@ -36,8 +35,10 @@ engine_config:
...
@@ -36,8 +35,10 @@ engine_config:
# if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
# if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
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
resource_config:
gpu_resource_config:
search_resources: # define the devices used for search computation, must be in format: cpu or gpux
enable_gpu: false # whether to enable GPU resources
- cpu
cache_capacity: 4 # GB, size of GPU memory per card used for cache, must be a positive integer
index_build_resources: # define the devices used for index building, must be in format: cpu or gpux
search_resources: # define the GPU devices used for search computation, must be in format gpux
- cpu
- gpu0
build_index_resources: # define the GPU devices used for index building, must be in format gpux
- gpu0
core/conf/server_gpu_config.template
浏览文件 @
7f5c2fef
...
@@ -27,10 +27,7 @@ metric_config:
...
@@ -27,10 +27,7 @@ metric_config:
port: 8080 # port prometheus uses to fetch metrics, must in range [1025, 65534]
port: 8080 # port prometheus uses to fetch metrics, must in range [1025, 65534]
cache_config:
cache_config:
cpu_cache_capacity: 16 # GB, CPU memory used for cache, must be a positive integer
cpu_cache_capacity: 16 # GB, size of CPU memory used for cache, must be a positive integer
cpu_cache_threshold: 0.85 # percentage of data that will be kept when cache cleanup is triggered, must be in range (0.0, 1.0]
gpu_cache_capacity: 4 # GB, GPU memory used for cache, must be a positive integer
gpu_cache_threshold: 0.85 # percentage of data that will be kept when cache cleanup is triggered, must be in range (0.0, 1.0]
cache_insert_data: false # whether to load inserted data into cache, must be a boolean
cache_insert_data: false # whether to load inserted data into cache, must be a boolean
engine_config:
engine_config:
...
@@ -38,9 +35,10 @@ engine_config:
...
@@ -38,9 +35,10 @@ engine_config:
# if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
# if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
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
resource_config:
gpu_resource_config:
search_resources: # define the devices used for search computation, must be in format: cpu or gpux
enable_gpu: true # whether to enable GPU resources
- cpu
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
- gpu0
- gpu0
index_build_resources: # define the devices used for index building, must be in format: cpu or
gpux
build_index_resources: # define the GPU devices used for index building, must be in format
gpux
- gpu0
- gpu0
core/src/cache/GpuCacheMgr.cpp
浏览文件 @
7f5c2fef
...
@@ -37,7 +37,7 @@ GpuCacheMgr::GpuCacheMgr() {
...
@@ -37,7 +37,7 @@ GpuCacheMgr::GpuCacheMgr() {
Status
s
;
Status
s
;
int64_t
gpu_cache_cap
;
int64_t
gpu_cache_cap
;
s
=
config
.
Get
CacheConfigGpu
CacheCapacity
(
gpu_cache_cap
);
s
=
config
.
Get
GpuResourceConfig
CacheCapacity
(
gpu_cache_cap
);
if
(
!
s
.
ok
())
{
if
(
!
s
.
ok
())
{
SERVER_LOG_ERROR
<<
s
.
message
();
SERVER_LOG_ERROR
<<
s
.
message
();
}
}
...
@@ -45,7 +45,7 @@ GpuCacheMgr::GpuCacheMgr() {
...
@@ -45,7 +45,7 @@ GpuCacheMgr::GpuCacheMgr() {
cache_
=
std
::
make_shared
<
Cache
<
DataObjPtr
>>
(
cap
,
1UL
<<
32
);
cache_
=
std
::
make_shared
<
Cache
<
DataObjPtr
>>
(
cap
,
1UL
<<
32
);
float
gpu_mem_threshold
;
float
gpu_mem_threshold
;
s
=
config
.
Get
CacheConfigGpu
CacheThreshold
(
gpu_mem_threshold
);
s
=
config
.
Get
GpuResourceConfig
CacheThreshold
(
gpu_mem_threshold
);
if
(
!
s
.
ok
())
{
if
(
!
s
.
ok
())
{
SERVER_LOG_ERROR
<<
s
.
message
();
SERVER_LOG_ERROR
<<
s
.
message
();
}
}
...
...
core/src/db/engine/ExecutionEngineImpl.cpp
浏览文件 @
7f5c2fef
...
@@ -144,7 +144,14 @@ ExecutionEngineImpl::HybridLoad() const {
...
@@ -144,7 +144,14 @@ ExecutionEngineImpl::HybridLoad() const {
}
}
const
std
::
string
key
=
location_
+
".quantizer"
;
const
std
::
string
key
=
location_
+
".quantizer"
;
std
::
vector
<
uint64_t
>
gpus
=
scheduler
::
get_gpu_pool
();
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
std
::
vector
<
int32_t
>
gpus
;
Status
s
=
config
.
GetGpuResourceConfigSearchResources
(
gpus
);
if
(
!
s
.
ok
())
{
ENGINE_LOG_ERROR
<<
s
.
message
();
return
;
}
// cache hit
// cache hit
{
{
...
@@ -578,7 +585,9 @@ ExecutionEngineImpl::GpuCache(uint64_t gpu_id) {
...
@@ -578,7 +585,9 @@ ExecutionEngineImpl::GpuCache(uint64_t gpu_id) {
// TODO(linxj): remove.
// TODO(linxj): remove.
Status
Status
ExecutionEngineImpl
::
Init
()
{
ExecutionEngineImpl
::
Init
()
{
auto
gpu_ids
=
scheduler
::
get_build_resources
();
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
std
::
vector
<
int32_t
>
gpu_ids
;
Status
s
=
config
.
GetGpuResourceConfigBuildIndexResources
(
gpu_ids
);
for
(
auto
id
:
gpu_ids
)
{
for
(
auto
id
:
gpu_ids
)
{
if
(
gpu_num_
==
id
)
{
if
(
gpu_num_
==
id
)
{
return
Status
::
OK
();
return
Status
::
OK
();
...
...
core/src/scheduler/SchedInst.cpp
浏览文件 @
7f5c2fef
...
@@ -45,17 +45,6 @@ std::mutex BuildMgrInst::mutex_;
...
@@ -45,17 +45,6 @@ std::mutex BuildMgrInst::mutex_;
void
void
load_simple_config
()
{
load_simple_config
()
{
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
std
::
string
mode
;
config
.
GetResourceConfigMode
(
mode
);
std
::
vector
<
std
::
string
>
pool
;
config
.
GetResourceConfigSearchResources
(
pool
);
// get resources
auto
gpu_ids
=
get_gpu_pool
();
auto
build_gpu_ids
=
get_build_resources
();
// create and connect
// create and connect
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
"disk"
,
"DISK"
,
0
,
true
,
false
));
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
"disk"
,
"DISK"
,
0
,
true
,
false
));
...
@@ -63,6 +52,13 @@ load_simple_config() {
...
@@ -63,6 +52,13 @@ load_simple_config() {
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
"cpu"
,
"CPU"
,
0
,
true
,
true
));
ResMgrInst
::
GetInstance
()
->
Add
(
ResourceFactory
::
Create
(
"cpu"
,
"CPU"
,
0
,
true
,
true
));
ResMgrInst
::
GetInstance
()
->
Connect
(
"disk"
,
"cpu"
,
io
);
ResMgrInst
::
GetInstance
()
->
Connect
(
"disk"
,
"cpu"
,
io
);
// get resources
#ifdef MILVUS_GPU_VERSION
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
std
::
vector
<
int32_t
>
gpu_ids
;
config
.
GetGpuResourceConfigSearchResources
(
gpu_ids
);
std
::
vector
<
int32_t
>
build_gpu_ids
;
config
.
GetGpuResourceConfigBuildIndexResources
(
build_gpu_ids
);
auto
pcie
=
Connection
(
"pcie"
,
12000
);
auto
pcie
=
Connection
(
"pcie"
,
12000
);
std
::
vector
<
int64_t
>
not_find_build_ids
;
std
::
vector
<
int64_t
>
not_find_build_ids
;
...
@@ -89,6 +85,7 @@ load_simple_config() {
...
@@ -89,6 +85,7 @@ load_simple_config() {
ResourceFactory
::
Create
(
std
::
to_string
(
not_find_id
),
"GPU"
,
not_find_id
,
true
,
true
));
ResourceFactory
::
Create
(
std
::
to_string
(
not_find_id
),
"GPU"
,
not_find_id
,
true
,
true
));
ResMgrInst
::
GetInstance
()
->
Connect
(
"cpu"
,
std
::
to_string
(
not_find_id
),
pcie
);
ResMgrInst
::
GetInstance
()
->
Connect
(
"cpu"
,
std
::
to_string
(
not_find_id
),
pcie
);
}
}
#endif
}
}
void
void
...
...
core/src/scheduler/SchedInst.h
浏览文件 @
7f5c2fef
...
@@ -21,14 +21,13 @@
...
@@ -21,14 +21,13 @@
#include "JobMgr.h"
#include "JobMgr.h"
#include "ResourceMgr.h"
#include "ResourceMgr.h"
#include "Scheduler.h"
#include "Scheduler.h"
#include "Utils.h"
#include "optimizer/BuildIndexPass.h"
#include "optimizer/BuildIndexPass.h"
#include "optimizer/HybridPass.h"
#include "optimizer/HybridPass.h"
#include "optimizer/LargeSQ8HPass.h"
#include "optimizer/LargeSQ8HPass.h"
#include "optimizer/OnlyCPUPass.h"
#include "optimizer/OnlyCPUPass.h"
#include "optimizer/OnlyGPUPass.h"
#include "optimizer/Optimizer.h"
#include "optimizer/Optimizer.h"
#include "server/Config.h"
#include "server/Config.h"
#include "Utils.h"
#include <memory>
#include <memory>
#include <mutex>
#include <mutex>
...
@@ -99,25 +98,17 @@ class OptimizerInst {
...
@@ -99,25 +98,17 @@ class OptimizerInst {
if
(
instance
==
nullptr
)
{
if
(
instance
==
nullptr
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
if
(
instance
==
nullptr
)
{
if
(
instance
==
nullptr
)
{
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
std
::
vector
<
std
::
string
>
search_resources
;
bool
has_cpu
=
false
;
config
.
GetResourceConfigSearchResources
(
search_resources
);
for
(
auto
&
resource
:
search_resources
)
{
if
(
resource
==
"cpu"
)
{
has_cpu
=
true
;
}
}
auto
build_resources
=
get_build_resources
();
std
::
vector
<
PassPtr
>
pass_list
;
std
::
vector
<
PassPtr
>
pass_list
;
pass_list
.
push_back
(
std
::
make_shared
<
LargeSQ8HPass
>
());
pass_list
.
push_back
(
std
::
make_shared
<
LargeSQ8HPass
>
());
pass_list
.
push_back
(
std
::
make_shared
<
HybridPass
>
());
pass_list
.
push_back
(
std
::
make_shared
<
HybridPass
>
());
#ifdef MILVUS_CPU_VERSION
pass_list
.
push_back
(
std
::
make_shared
<
OnlyCPUPass
>
());
pass_list
.
push_back
(
std
::
make_shared
<
OnlyCPUPass
>
());
pass_list
.
push_back
(
std
::
make_shared
<
OnlyGPUPass
>
(
has_cpu
));
#else
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
std
::
vector
<
int32_t
>
build_resources
;
config
.
GetGpuResourceConfigBuildIndexResources
(
build_resources
);
pass_list
.
push_back
(
std
::
make_shared
<
BuildIndexPass
>
(
build_resources
));
pass_list
.
push_back
(
std
::
make_shared
<
BuildIndexPass
>
(
build_resources
));
#endif
instance
=
std
::
make_shared
<
Optimizer
>
(
pass_list
);
instance
=
std
::
make_shared
<
Optimizer
>
(
pass_list
);
}
}
}
}
...
...
core/src/scheduler/TaskCreator.cpp
浏览文件 @
7f5c2fef
...
@@ -70,8 +70,7 @@ TaskCreator::Create(const DeleteJobPtr& job) {
...
@@ -70,8 +70,7 @@ TaskCreator::Create(const DeleteJobPtr& job) {
std
::
vector
<
TaskPtr
>
std
::
vector
<
TaskPtr
>
TaskCreator
::
Create
(
const
BuildIndexJobPtr
&
job
)
{
TaskCreator
::
Create
(
const
BuildIndexJobPtr
&
job
)
{
std
::
vector
<
TaskPtr
>
tasks
;
std
::
vector
<
TaskPtr
>
tasks
;
// TODO(yukun): remove "disk" hardcode here
ResourcePtr
res_ptr
=
ResMgrInst
::
GetInstance
()
->
GetResource
(
"cpu"
);
ResourcePtr
res_ptr
=
ResMgrInst
::
GetInstance
()
->
GetResource
(
"disk"
);
for
(
auto
&
to_index_file
:
job
->
to_index_files
())
{
for
(
auto
&
to_index_file
:
job
->
to_index_files
())
{
auto
label
=
std
::
make_shared
<
SpecResLabel
>
(
std
::
weak_ptr
<
Resource
>
(
res_ptr
));
auto
label
=
std
::
make_shared
<
SpecResLabel
>
(
std
::
weak_ptr
<
Resource
>
(
res_ptr
));
...
...
core/src/scheduler/Utils.cpp
浏览文件 @
7f5c2fef
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
#include "scheduler/Utils.h"
#include "scheduler/Utils.h"
#include "server/Config.h"
#include "server/Config.h"
#include "utils/Log.h"
#ifdef MILVUS_GPU_VERSION
#ifdef MILVUS_GPU_VERSION
#include <cuda_runtime.h>
#include <cuda_runtime.h>
...
@@ -46,80 +45,5 @@ get_num_gpu() {
...
@@ -46,80 +45,5 @@ get_num_gpu() {
return
n_devices
;
return
n_devices
;
}
}
std
::
vector
<
uint64_t
>
get_gpu_pool
()
{
std
::
vector
<
uint64_t
>
gpu_pool
;
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
std
::
vector
<
std
::
string
>
pool
;
Status
s
=
config
.
GetResourceConfigSearchResources
(
pool
);
if
(
!
s
.
ok
())
{
SERVER_LOG_ERROR
<<
s
.
message
();
}
std
::
set
<
uint64_t
>
gpu_ids
;
for
(
auto
&
resource
:
pool
)
{
if
(
resource
==
"cpu"
)
{
continue
;
}
else
{
if
(
resource
.
length
()
<
4
||
resource
.
substr
(
0
,
3
)
!=
"gpu"
)
{
// error
exit
(
-
1
);
}
auto
gpu_id
=
std
::
stoi
(
resource
.
substr
(
3
));
if
(
gpu_id
>=
scheduler
::
get_num_gpu
())
{
// error
exit
(
-
1
);
}
gpu_ids
.
insert
(
gpu_id
);
}
}
for
(
auto
&
gpu_id
:
gpu_ids
)
{
gpu_pool
.
push_back
(
gpu_id
);
}
return
gpu_pool
;
}
std
::
vector
<
int64_t
>
get_build_resources
()
{
std
::
vector
<
int64_t
>
gpu_pool
;
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
std
::
vector
<
std
::
string
>
pool
;
Status
s
=
config
.
GetResourceConfigIndexBuildResources
(
pool
);
if
(
!
s
.
ok
())
{
SERVER_LOG_ERROR
<<
s
.
message
();
}
std
::
set
<
uint64_t
>
gpu_ids
;
for
(
auto
&
resource
:
pool
)
{
if
(
resource
==
"cpu"
)
{
gpu_pool
.
push_back
(
server
::
CPU_DEVICE_ID
);
continue
;
}
else
{
if
(
resource
.
length
()
<
4
||
resource
.
substr
(
0
,
3
)
!=
"gpu"
)
{
// error
exit
(
-
1
);
}
auto
gpu_id
=
std
::
stoi
(
resource
.
substr
(
3
));
if
(
gpu_id
>=
scheduler
::
get_num_gpu
())
{
// error
exit
(
-
1
);
}
gpu_ids
.
insert
(
gpu_id
);
}
}
for
(
auto
&
gpu_id
:
gpu_ids
)
{
gpu_pool
.
push_back
(
gpu_id
);
}
return
gpu_pool
;
}
}
// namespace scheduler
}
// namespace scheduler
}
// namespace milvus
}
// namespace milvus
core/src/scheduler/Utils.h
浏览文件 @
7f5c2fef
...
@@ -27,11 +27,5 @@ get_current_timestamp();
...
@@ -27,11 +27,5 @@ get_current_timestamp();
uint64_t
uint64_t
get_num_gpu
();
get_num_gpu
();
std
::
vector
<
uint64_t
>
get_gpu_pool
();
std
::
vector
<
int64_t
>
get_build_resources
();
}
// namespace scheduler
}
// namespace scheduler
}
// namespace milvus
}
// namespace milvus
core/src/scheduler/optimizer/BuildIndexPass.cpp
浏览文件 @
7f5c2fef
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
namespace
milvus
{
namespace
milvus
{
namespace
scheduler
{
namespace
scheduler
{
BuildIndexPass
::
BuildIndexPass
(
std
::
vector
<
int
64
_t
>&
build_gpu_ids
)
:
build_gpu_ids_
(
build_gpu_ids
)
{
BuildIndexPass
::
BuildIndexPass
(
std
::
vector
<
int
32
_t
>&
build_gpu_ids
)
:
build_gpu_ids_
(
build_gpu_ids
)
{
}
}
bool
bool
...
@@ -35,15 +35,9 @@ BuildIndexPass::Run(const TaskPtr& task) {
...
@@ -35,15 +35,9 @@ BuildIndexPass::Run(const TaskPtr& task) {
return
false
;
return
false
;
ResourcePtr
res_ptr
;
ResourcePtr
res_ptr
;
if
(
build_gpu_ids_
[
0
]
==
server
::
CPU_DEVICE_ID
)
{
res_ptr
=
ResMgrInst
::
GetInstance
()
->
GetResource
(
ResourceType
::
GPU
,
build_gpu_ids_
[
specified_gpu_id_
]);
res_ptr
=
ResMgrInst
::
GetInstance
()
->
GetResource
(
"cpu"
);
auto
label
=
std
::
make_shared
<
SpecResLabel
>
(
std
::
weak_ptr
<
Resource
>
(
res_ptr
));
auto
label
=
std
::
make_shared
<
SpecResLabel
>
(
std
::
weak_ptr
<
Resource
>
(
res_ptr
));
task
->
label
()
=
label
;
task
->
label
()
=
label
;
}
else
{
res_ptr
=
ResMgrInst
::
GetInstance
()
->
GetResource
(
ResourceType
::
GPU
,
build_gpu_ids_
[
specified_gpu_id_
]);
auto
label
=
std
::
make_shared
<
SpecResLabel
>
(
std
::
weak_ptr
<
Resource
>
(
res_ptr
));
task
->
label
()
=
label
;
}
specified_gpu_id_
=
(
specified_gpu_id_
+
1
)
%
build_gpu_ids_
.
size
();
specified_gpu_id_
=
(
specified_gpu_id_
+
1
)
%
build_gpu_ids_
.
size
();
return
true
;
return
true
;
...
...
core/src/scheduler/optimizer/BuildIndexPass.h
浏览文件 @
7f5c2fef
...
@@ -34,7 +34,7 @@ namespace scheduler {
...
@@ -34,7 +34,7 @@ namespace scheduler {
class
BuildIndexPass
:
public
Pass
{
class
BuildIndexPass
:
public
Pass
{
public:
public:
explicit
BuildIndexPass
(
std
::
vector
<
int
64
_t
>&
build_gpu_id
);
explicit
BuildIndexPass
(
std
::
vector
<
int
32
_t
>&
build_gpu_id
);
public:
public:
bool
bool
...
@@ -42,7 +42,7 @@ class BuildIndexPass : public Pass {
...
@@ -42,7 +42,7 @@ class BuildIndexPass : public Pass {
private:
private:
uint64_t
specified_gpu_id_
=
0
;
uint64_t
specified_gpu_id_
=
0
;
std
::
vector
<
int
64
_t
>
build_gpu_ids_
;
std
::
vector
<
int
32
_t
>
build_gpu_ids_
;
};
};
using
BuildIndexPassPtr
=
std
::
shared_ptr
<
BuildIndexPass
>
;
using
BuildIndexPassPtr
=
std
::
shared_ptr
<
BuildIndexPass
>
;
...
...
core/src/scheduler/optimizer/LargeSQ8HPass.cpp
浏览文件 @
7f5c2fef
...
@@ -33,6 +33,7 @@ LargeSQ8HPass::LargeSQ8HPass() {
...
@@ -33,6 +33,7 @@ LargeSQ8HPass::LargeSQ8HPass() {
if
(
!
s
.
ok
())
{
if
(
!
s
.
ok
())
{
threshold_
=
std
::
numeric_limits
<
int32_t
>::
max
();
threshold_
=
std
::
numeric_limits
<
int32_t
>::
max
();
}
}
s
=
config
.
GetGpuResourceConfigSearchResources
(
gpus
);
}
}
bool
bool
...
@@ -54,7 +55,6 @@ LargeSQ8HPass::Run(const TaskPtr& task) {
...
@@ -54,7 +55,6 @@ LargeSQ8HPass::Run(const TaskPtr& task) {
return
false
;
return
false
;
}
}
std
::
vector
<
uint64_t
>
gpus
=
scheduler
::
get_gpu_pool
();
// std::vector<int64_t> all_free_mem;
// std::vector<int64_t> all_free_mem;
// for (auto& gpu : gpus) {
// for (auto& gpu : gpus) {
// auto cache = cache::GpuCacheMgr::GetInstance(gpu);
// auto cache = cache::GpuCacheMgr::GetInstance(gpu);
...
...
core/src/scheduler/optimizer/LargeSQ8HPass.h
浏览文件 @
7f5c2fef
...
@@ -44,6 +44,7 @@ class LargeSQ8HPass : public Pass {
...
@@ -44,6 +44,7 @@ class LargeSQ8HPass : public Pass {
private:
private:
int32_t
threshold_
=
std
::
numeric_limits
<
int32_t
>::
max
();
int32_t
threshold_
=
std
::
numeric_limits
<
int32_t
>::
max
();
int64_t
count_
=
0
;
int64_t
count_
=
0
;
std
::
vector
<
int32_t
>
gpus
;
};
};
using
LargeSQ8HPassPtr
=
std
::
shared_ptr
<
LargeSQ8HPass
>
;
using
LargeSQ8HPassPtr
=
std
::
shared_ptr
<
LargeSQ8HPass
>
;
...
...
core/src/scheduler/optimizer/OnlyCPUPass.cpp
浏览文件 @
7f5c2fef
...
@@ -34,10 +34,6 @@ OnlyCPUPass::Run(const TaskPtr& task) {
...
@@ -34,10 +34,6 @@ OnlyCPUPass::Run(const TaskPtr& task) {
return
false
;
return
false
;
}
}
auto
gpu_id
=
get_gpu_pool
();
if
(
not
gpu_id
.
empty
())
return
false
;
ResourcePtr
res_ptr
=
ResMgrInst
::
GetInstance
()
->
GetResource
(
"cpu"
);
ResourcePtr
res_ptr
=
ResMgrInst
::
GetInstance
()
->
GetResource
(
"cpu"
);
auto
label
=
std
::
make_shared
<
SpecResLabel
>
(
std
::
weak_ptr
<
Resource
>
(
res_ptr
));
auto
label
=
std
::
make_shared
<
SpecResLabel
>
(
std
::
weak_ptr
<
Resource
>
(
res_ptr
));
task
->
label
()
=
label
;
task
->
label
()
=
label
;
...
...
core/src/scheduler/optimizer/OnlyGPUPass.cpp
已删除
100644 → 0
浏览文件 @
0a858939
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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 "scheduler/optimizer/OnlyGPUPass.h"
#include "scheduler/SchedInst.h"
#include "scheduler/Utils.h"
#include "scheduler/task/SearchTask.h"
#include "scheduler/tasklabel/SpecResLabel.h"
namespace
milvus
{
namespace
scheduler
{
OnlyGPUPass
::
OnlyGPUPass
(
bool
has_cpu
)
:
has_cpu_
(
has_cpu
)
{
}
bool
OnlyGPUPass
::
Run
(
const
TaskPtr
&
task
)
{
if
(
task
->
Type
()
!=
TaskType
::
SearchTask
||
has_cpu_
)
return
false
;
auto
search_task
=
std
::
static_pointer_cast
<
XSearchTask
>
(
task
);
if
(
search_task
->
file_
->
engine_type_
!=
(
int
)
engine
::
EngineType
::
FAISS_IVFSQ8
&&
search_task
->
file_
->
engine_type_
!=
(
int
)
engine
::
EngineType
::
FAISS_IVFFLAT
&&
search_task
->
file_
->
engine_type_
!=
(
int
)
engine
::
EngineType
::
FAISS_IDMAP
)
{
return
false
;
}
auto
gpu_id
=
get_gpu_pool
();
if
(
gpu_id
.
empty
())
return
false
;
ResourcePtr
res_ptr
=
ResMgrInst
::
GetInstance
()
->
GetResource
(
ResourceType
::
GPU
,
gpu_id
[
specified_gpu_id_
]);
auto
label
=
std
::
make_shared
<
SpecResLabel
>
(
std
::
weak_ptr
<
Resource
>
(
res_ptr
));
task
->
label
()
=
label
;
specified_gpu_id_
=
(
specified_gpu_id_
+
1
)
%
gpu_id
.
size
();
return
true
;
}
}
// namespace scheduler
}
// namespace milvus
core/src/scheduler/optimizer/OnlyGPUPass.h
已删除
100644 → 0
浏览文件 @
0a858939
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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 <condition_variable>
#include <deque>
#include <list>
#include <memory>
#include <mutex>
#include <queue>
#include <string>
#include <thread>
#include <unordered_map>
#include <vector>
#include "Pass.h"
namespace
milvus
{
namespace
scheduler
{
class
OnlyGPUPass
:
public
Pass
{
public:
explicit
OnlyGPUPass
(
bool
has_cpu
);
public:
bool
Run
(
const
TaskPtr
&
task
)
override
;
private:
uint64_t
specified_gpu_id_
=
0
;
bool
has_cpu_
=
false
;
};
using
OnlyGPUPassPtr
=
std
::
shared_ptr
<
OnlyGPUPass
>
;
}
// namespace scheduler
}
// namespace milvus
core/src/server/Config.cpp
浏览文件 @
7f5c2fef
此差异已折叠。
点击以展开。
core/src/server/Config.h
浏览文件 @
7f5c2fef
...
@@ -59,12 +59,8 @@ static const char* CONFIG_DB_PRELOAD_TABLE = "preload_table";
...
@@ -59,12 +59,8 @@ static const char* CONFIG_DB_PRELOAD_TABLE = "preload_table";
static
const
char
*
CONFIG_CACHE
=
"cache_config"
;
static
const
char
*
CONFIG_CACHE
=
"cache_config"
;
static
const
char
*
CONFIG_CACHE_CPU_CACHE_CAPACITY
=
"cpu_cache_capacity"
;
static
const
char
*
CONFIG_CACHE_CPU_CACHE_CAPACITY
=
"cpu_cache_capacity"
;
static
const
char
*
CONFIG_CACHE_CPU_CACHE_CAPACITY_DEFAULT
=
"16"
;
static
const
char
*
CONFIG_CACHE_CPU_CACHE_CAPACITY_DEFAULT
=
"16"
;
static
const
char
*
CONFIG_CACHE_GPU_CACHE_CAPACITY
=
"gpu_cache_capacity"
;
static
const
char
*
CONFIG_CACHE_CPU_CACHE_THRESHOLD
=
"cpu_cache_threshold"
;
static
const
char
*
CONFIG_CACHE_GPU_CACHE_CAPACITY_DEFAULT
=
"4"
;
static
const
char
*
CONFIG_CACHE_CPU_CACHE_THRESHOLD
=
"cpu_mem_threshold"
;
static
const
char
*
CONFIG_CACHE_CPU_CACHE_THRESHOLD_DEFAULT
=
"0.85"
;
static
const
char
*
CONFIG_CACHE_CPU_CACHE_THRESHOLD_DEFAULT
=
"0.85"
;
static
const
char
*
CONFIG_CACHE_GPU_CACHE_THRESHOLD
=
"gpu_mem_threshold"
;
static
const
char
*
CONFIG_CACHE_GPU_CACHE_THRESHOLD_DEFAULT
=
"0.85"
;
static
const
char
*
CONFIG_CACHE_CACHE_INSERT_DATA
=
"cache_insert_data"
;
static
const
char
*
CONFIG_CACHE_CACHE_INSERT_DATA
=
"cache_insert_data"
;
static
const
char
*
CONFIG_CACHE_CACHE_INSERT_DATA_DEFAULT
=
"false"
;
static
const
char
*
CONFIG_CACHE_CACHE_INSERT_DATA_DEFAULT
=
"false"
;
...
@@ -87,24 +83,23 @@ static const char* CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT = "0";
...
@@ -87,24 +83,23 @@ static const char* CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT = "0";
static
const
char
*
CONFIG_ENGINE_GPU_SEARCH_THRESHOLD
=
"gpu_search_threshold"
;
static
const
char
*
CONFIG_ENGINE_GPU_SEARCH_THRESHOLD
=
"gpu_search_threshold"
;
static
const
char
*
CONFIG_ENGINE_GPU_SEARCH_THRESHOLD_DEFAULT
=
"1000"
;
static
const
char
*
CONFIG_ENGINE_GPU_SEARCH_THRESHOLD_DEFAULT
=
"1000"
;
/* resource config */
/* gpu resource config */
static
const
char
*
CONFIG_RESOURCE
=
"resource_config"
;
static
const
char
*
CONFIG_GPU_RESOURCE
=
"gpu_resource_config"
;
static
const
char
*
CONFIG_RESOURCE_MODE
=
"mode"
;
static
const
char
*
CONFIG_GPU_RESOURCE_ENABLE_GPU
=
"enable_gpu"
;
static
const
char
*
CONFIG_RESOURCE_MODE_DEFAULT
=
"simple"
;
#ifdef MILVUS_GPU_VERSION
static
const
char
*
CONFIG_RESOURCE_RESOURCES_DELIMITER
=
","
;
static
const
char
*
CONFIG_GPU_RESOURCE_ENABLE_GPU_DEFAULT
=
"true"
;
static
const
char
*
CONFIG_RESOURCE_SEARCH_RESOURCES
=
"search_resources"
;
#ifdef MILVUS_CPU_VERSION
static
const
char
*
CONFIG_RESOURCE_SEARCH_RESOURCES_DEFAULT
=
"cpu"
;
#else
#else
static
const
char
*
CONFIG_
RESOURCE_SEARCH_RESOURCES_DEFAULT
=
"cpu,gpu0
"
;
static
const
char
*
CONFIG_
GPU_RESOURCE_ENABLE_GPU_DEFAULT
=
"false
"
;
#endif
#endif
static
const
char
*
CONFIG_RESOURCE_INDEX_BUILD_RESOURCES
=
"index_build_resources"
;
static
const
char
*
CONFIG_GPU_RESOURCE_CACHE_CAPACITY
=
"cache_capacity"
;
#ifdef MILVUS_CPU_VERSION
static
const
char
*
CONFIG_GPU_RESOURCE_CACHE_CAPACITY_DEFAULT
=
"4"
;
static
const
char
*
CONFIG_RESOURCE_INDEX_BUILD_RESOURCES_DEFAULT
=
"cpu"
;
static
const
char
*
CONFIG_GPU_RESOURCE_CACHE_THRESHOLD
=
"cache_threshold"
;
#else
static
const
char
*
CONFIG_GPU_RESOURCE_CACHE_THRESHOLD_DEFAULT
=
"0.85"
;
static
const
char
*
CONFIG_RESOURCE_INDEX_BUILD_RESOURCES_DEFAULT
=
"gpu0"
;
static
const
char
*
CONFIG_GPU_RESOURCE_DELIMITER
=
","
;
#endif
static
const
char
*
CONFIG_GPU_RESOURCE_SEARCH_RESOURCES
=
"search_resources"
;
const
int32_t
CPU_DEVICE_ID
=
-
1
;
static
const
char
*
CONFIG_GPU_RESOURCE_SEARCH_RESOURCES_DEFAULT
=
"gpu0"
;
static
const
char
*
CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES
=
"build_index_resources"
;
static
const
char
*
CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES_DEFAULT
=
"gpu0"
;
class
Config
{
class
Config
{
public:
public:
...
@@ -168,10 +163,6 @@ class Config {
...
@@ -168,10 +163,6 @@ class Config {
Status
Status
CheckCacheConfigCpuCacheThreshold
(
const
std
::
string
&
value
);
CheckCacheConfigCpuCacheThreshold
(
const
std
::
string
&
value
);
Status
Status
CheckCacheConfigGpuCacheCapacity
(
const
std
::
string
&
value
);
Status
CheckCacheConfigGpuCacheThreshold
(
const
std
::
string
&
value
);
Status
CheckCacheConfigCacheInsertData
(
const
std
::
string
&
value
);
CheckCacheConfigCacheInsertData
(
const
std
::
string
&
value
);
/* engine config */
/* engine config */
...
@@ -182,13 +173,17 @@ class Config {
...
@@ -182,13 +173,17 @@ class Config {
Status
Status
CheckEngineConfigGpuSearchThreshold
(
const
std
::
string
&
value
);
CheckEngineConfigGpuSearchThreshold
(
const
std
::
string
&
value
);
/* resource config */
/*
gpu
resource config */
Status
Status
Check
ResourceConfigMode
(
const
std
::
string
&
value
);
Check
GpuResourceConfigEnableGpu
(
const
std
::
string
&
value
);
Status
Status
Check
ResourceConfigSearchResources
(
const
std
::
vector
<
std
::
string
>
&
value
);
Check
GpuResourceConfigCacheCapacity
(
const
std
::
string
&
value
);
Status
Status
CheckResourceConfigIndexBuildResources
(
const
std
::
vector
<
std
::
string
>&
value
);
CheckGpuResourceConfigCacheThreshold
(
const
std
::
string
&
value
);
Status
CheckGpuResourceConfigSearchResources
(
const
std
::
vector
<
std
::
string
>&
value
);
Status
CheckGpuResourceConfigBuildIndexResources
(
const
std
::
vector
<
std
::
string
>&
value
);
std
::
string
std
::
string
GetConfigStr
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
const
std
::
string
&
default_value
=
""
);
GetConfigStr
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
const
std
::
string
&
default_value
=
""
);
...
@@ -237,10 +232,6 @@ class Config {
...
@@ -237,10 +232,6 @@ class Config {
Status
Status
GetCacheConfigCpuCacheThreshold
(
float
&
value
);
GetCacheConfigCpuCacheThreshold
(
float
&
value
);
Status
Status
GetCacheConfigGpuCacheCapacity
(
int64_t
&
value
);
Status
GetCacheConfigGpuCacheThreshold
(
float
&
value
);
Status
GetCacheConfigCacheInsertData
(
bool
&
value
);
GetCacheConfigCacheInsertData
(
bool
&
value
);
/* engine config */
/* engine config */
...
@@ -251,13 +242,17 @@ class Config {
...
@@ -251,13 +242,17 @@ class Config {
Status
Status
GetEngineConfigGpuSearchThreshold
(
int32_t
&
value
);
GetEngineConfigGpuSearchThreshold
(
int32_t
&
value
);
/* resource config */
/* gpu resource config */
Status
GetGpuResourceConfigEnableGpu
(
bool
&
value
);
Status
Status
Get
ResourceConfigMode
(
std
::
string
&
value
);
Get
GpuResourceConfigCacheCapacity
(
int64_t
&
value
);
Status
Status
Get
ResourceConfigSearchResources
(
std
::
vector
<
std
::
string
>
&
value
);
Get
GpuResourceConfigCacheThreshold
(
float
&
value
);
Status
Status
GetResourceConfigIndexBuildResources
(
std
::
vector
<
std
::
string
>&
value
);
GetGpuResourceConfigSearchResources
(
std
::
vector
<
int32_t
>&
value
);
Status
GetGpuResourceConfigBuildIndexResources
(
std
::
vector
<
int32_t
>&
value
);
public:
public:
/* server config */
/* server config */
...
@@ -298,10 +293,6 @@ class Config {
...
@@ -298,10 +293,6 @@ class Config {
Status
Status
SetCacheConfigCpuCacheThreshold
(
const
std
::
string
&
value
);
SetCacheConfigCpuCacheThreshold
(
const
std
::
string
&
value
);
Status
Status
SetCacheConfigGpuCacheCapacity
(
const
std
::
string
&
value
);
Status
SetCacheConfigGpuCacheThreshold
(
const
std
::
string
&
value
);
Status
SetCacheConfigCacheInsertData
(
const
std
::
string
&
value
);
SetCacheConfigCacheInsertData
(
const
std
::
string
&
value
);
/* engine config */
/* engine config */
...
@@ -312,13 +303,17 @@ class Config {
...
@@ -312,13 +303,17 @@ class Config {
Status
Status
SetEngineConfigGpuSearchThreshold
(
const
std
::
string
&
value
);
SetEngineConfigGpuSearchThreshold
(
const
std
::
string
&
value
);
/* resource config */
/* gpu resource config */
Status
SetGpuResourceConfigEnableGpu
(
const
std
::
string
&
value
);
Status
SetGpuResourceConfigCacheCapacity
(
const
std
::
string
&
value
);
Status
Status
Set
ResourceConfigMode
(
const
std
::
string
&
value
);
Set
GpuResourceConfigCacheThreshold
(
const
std
::
string
&
value
);
Status
Status
SetResourceConfigSearchResources
(
const
std
::
string
&
value
);
Set
Gpu
ResourceConfigSearchResources
(
const
std
::
string
&
value
);
Status
Status
Set
ResourceConfigIndexBuild
Resources
(
const
std
::
string
&
value
);
Set
GpuResourceConfigBuildIndex
Resources
(
const
std
::
string
&
value
);
private:
private:
std
::
unordered_map
<
std
::
string
,
std
::
unordered_map
<
std
::
string
,
std
::
string
>>
config_map_
;
std
::
unordered_map
<
std
::
string
,
std
::
unordered_map
<
std
::
string
,
std
::
string
>>
config_map_
;
...
...
core/src/wrapper/KnowhereResource.cpp
浏览文件 @
7f5c2fef
...
@@ -37,7 +37,6 @@ constexpr int64_t M_BYTE = 1024 * 1024;
...
@@ -37,7 +37,6 @@ constexpr int64_t M_BYTE = 1024 * 1024;
Status
Status
KnowhereResource
::
Initialize
()
{
KnowhereResource
::
Initialize
()
{
#ifdef MILVUS_GPU_VERSION
#ifdef MILVUS_GPU_VERSION
struct
GpuResourceSetting
{
struct
GpuResourceSetting
{
int64_t
pinned_memory
=
300
*
M_BYTE
;
int64_t
pinned_memory
=
300
*
M_BYTE
;
int64_t
temp_memory
=
300
*
M_BYTE
;
int64_t
temp_memory
=
300
*
M_BYTE
;
...
@@ -49,8 +48,8 @@ KnowhereResource::Initialize() {
...
@@ -49,8 +48,8 @@ KnowhereResource::Initialize() {
// get build index gpu resource
// get build index gpu resource
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
std
::
vector
<
int32_t
>
build_index_gpus
;
auto
build_index_gpus
=
scheduler
::
get_build_resources
(
);
s
=
config
.
GetGpuResourceConfigBuildIndexResources
(
build_index_gpus
);
if
(
!
s
.
ok
())
if
(
!
s
.
ok
())
return
s
;
return
s
;
...
@@ -59,18 +58,12 @@ KnowhereResource::Initialize() {
...
@@ -59,18 +58,12 @@ KnowhereResource::Initialize() {
}
}
// get search gpu resource
// get search gpu resource
std
::
vector
<
std
::
string
>
pool
;
std
::
vector
<
int32_t
>
search_gpus
;
s
=
config
.
Get
ResourceConfigSearchResources
(
pool
);
s
=
config
.
Get
GpuResourceConfigSearchResources
(
search_gpus
);
if
(
!
s
.
ok
())
if
(
!
s
.
ok
())
return
s
;
return
s
;
std
::
set
<
uint64_t
>
gpu_ids
;
for
(
auto
&
gpu_id
:
search_gpus
)
{
for
(
auto
&
resource
:
pool
)
{
if
(
resource
.
length
()
<
4
||
resource
.
substr
(
0
,
3
)
!=
"gpu"
)
{
// invalid
continue
;
}
auto
gpu_id
=
std
::
stoi
(
resource
.
substr
(
3
));
gpu_resources
.
insert
(
std
::
make_pair
(
gpu_id
,
GpuResourceSetting
()));
gpu_resources
.
insert
(
std
::
make_pair
(
gpu_id
,
GpuResourceSetting
()));
}
}
...
...
core/unittest/db/utils.cpp
浏览文件 @
7f5c2fef
...
@@ -159,6 +159,10 @@ DBTest::SetUp() {
...
@@ -159,6 +159,10 @@ DBTest::SetUp() {
auto
default_conn
=
milvus
::
scheduler
::
Connection
(
"IO"
,
500.0
);
auto
default_conn
=
milvus
::
scheduler
::
Connection
(
"IO"
,
500.0
);
auto
PCIE
=
milvus
::
scheduler
::
Connection
(
"IO"
,
11000.0
);
auto
PCIE
=
milvus
::
scheduler
::
Connection
(
"IO"
,
11000.0
);
res_mgr
->
Connect
(
"disk"
,
"cpu"
,
default_conn
);
res_mgr
->
Connect
(
"disk"
,
"cpu"
,
default_conn
);
#ifdef MILVUS_GPU_VERSION
res_mgr
->
Add
(
milvus
::
scheduler
::
ResourceFactory
::
Create
(
"0"
,
"GPU"
,
0
,
true
,
true
));
res_mgr
->
Connect
(
"cpu"
,
"0"
,
PCIE
);
#endif
res_mgr
->
Start
();
res_mgr
->
Start
();
milvus
::
scheduler
::
SchedInst
::
GetInstance
()
->
Start
();
milvus
::
scheduler
::
SchedInst
::
GetInstance
()
->
Start
();
...
...
core/unittest/server/test_config.cpp
浏览文件 @
7f5c2fef
...
@@ -216,21 +216,6 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) {
...
@@ -216,21 +216,6 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) {
s
=
config
.
GetCacheConfigCpuCacheThreshold
(
float_val
);
s
=
config
.
GetCacheConfigCpuCacheThreshold
(
float_val
);
ASSERT_TRUE
(
float_val
==
cache_cpu_cache_threshold
);
ASSERT_TRUE
(
float_val
==
cache_cpu_cache_threshold
);
#ifdef MILVUS_GPU_VERSION
int64_t
cache_gpu_cache_capacity
=
1
;
s
=
config
.
SetCacheConfigGpuCacheCapacity
(
std
::
to_string
(
cache_gpu_cache_capacity
));
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
GetCacheConfigGpuCacheCapacity
(
int64_val
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
int64_val
==
cache_gpu_cache_capacity
);
float
cache_gpu_cache_threshold
=
0.2
;
s
=
config
.
SetCacheConfigGpuCacheThreshold
(
std
::
to_string
(
cache_gpu_cache_threshold
));
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
GetCacheConfigGpuCacheThreshold
(
float_val
);
ASSERT_TRUE
(
float_val
==
cache_gpu_cache_threshold
);
#endif
bool
cache_insert_data
=
true
;
bool
cache_insert_data
=
true
;
s
=
config
.
SetCacheConfigCacheInsertData
(
std
::
to_string
(
cache_insert_data
));
s
=
config
.
SetCacheConfigCacheInsertData
(
std
::
to_string
(
cache_insert_data
));
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
s
.
ok
());
...
@@ -259,47 +244,54 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) {
...
@@ -259,47 +244,54 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) {
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
int32_val
==
engine_gpu_search_threshold
);
ASSERT_TRUE
(
int32_val
==
engine_gpu_search_threshold
);
/* resource config */
/*
gpu
resource config */
std
::
string
resource_mode
=
"simple"
;
bool
resource_enable_gpu
=
true
;
s
=
config
.
Set
ResourceConfigMode
(
resource_mode
);
s
=
config
.
Set
GpuResourceConfigEnableGpu
(
std
::
to_string
(
resource_enable_gpu
)
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Get
ResourceConfigMode
(
str
_val
);
s
=
config
.
Get
GpuResourceConfigEnableGpu
(
bool
_val
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
str_val
==
resource_mode
);
ASSERT_TRUE
(
bool_val
==
resource_enable_gpu
);
#ifdef MILVUS_CPU_VERSION
#ifdef MILVUS_GPU_VERSION
std
::
vector
<
std
::
string
>
search_resources
=
{
"cpu"
};
int64_t
gpu_cache_capacity
=
1
;
#else
s
=
config
.
SetGpuResourceConfigCacheCapacity
(
std
::
to_string
(
gpu_cache_capacity
));
std
::
vector
<
std
::
string
>
search_resources
=
{
"cpu"
,
"gpu0"
};
ASSERT_TRUE
(
s
.
ok
());
#endif
s
=
config
.
GetGpuResourceConfigCacheCapacity
(
int64_val
);
std
::
vector
<
std
::
string
>
search_res_vec
;
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
int64_val
==
gpu_cache_capacity
);
float
gpu_cache_threshold
=
0.2
;
s
=
config
.
SetGpuResourceConfigCacheThreshold
(
std
::
to_string
(
gpu_cache_threshold
));
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
GetGpuResourceConfigCacheThreshold
(
float_val
);
ASSERT_TRUE
(
float_val
==
gpu_cache_threshold
);
std
::
vector
<
std
::
string
>
search_resources
=
{
"gpu0"
};
std
::
vector
<
int32_t
>
search_res_vec
;
std
::
string
search_res_str
;
std
::
string
search_res_str
;
milvus
::
server
::
StringHelpFunctions
::
MergeStringWithDelimeter
(
milvus
::
server
::
StringHelpFunctions
::
MergeStringWithDelimeter
(
search_resources
,
milvus
::
server
::
CONFIG_
RESOURCE_RESOURCES
_DELIMITER
,
search_res_str
);
search_resources
,
milvus
::
server
::
CONFIG_
GPU_RESOURCE
_DELIMITER
,
search_res_str
);
s
=
config
.
SetResourceConfigSearchResources
(
search_res_str
);
s
=
config
.
Set
Gpu
ResourceConfigSearchResources
(
search_res_str
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
GetResourceConfigSearchResources
(
search_res_vec
);
s
=
config
.
Get
Gpu
ResourceConfigSearchResources
(
search_res_vec
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
s
.
ok
());
for
(
size_t
i
=
0
;
i
<
search_resources
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
search_resources
.
size
();
i
++
)
{
ASSERT_TRUE
(
s
earch_resources
[
i
]
==
search_res_vec
[
i
]);
ASSERT_TRUE
(
s
td
::
stoi
(
search_resources
[
i
].
substr
(
3
))
==
search_res_vec
[
i
]);
}
}
#ifdef MILVUS_CPU_VERSION
std
::
vector
<
std
::
string
>
build_index_resources
=
{
"gpu0"
};
std
::
vector
<
std
::
string
>
index_build_resources
=
{
"cpu"
};
std
::
vector
<
int32_t
>
build_index_res_vec
;
#else
std
::
string
build_index_res_str
;
std
::
vector
<
std
::
string
>
index_build_resources
=
{
"gpu0"
,
"gpu1"
};
#endif
std
::
vector
<
std
::
string
>
index_build_res_vec
;
std
::
string
index_build_res_str
;
milvus
::
server
::
StringHelpFunctions
::
MergeStringWithDelimeter
(
milvus
::
server
::
StringHelpFunctions
::
MergeStringWithDelimeter
(
index_build_resources
,
milvus
::
server
::
CONFIG_RESOURCE_RESOURCES_DELIMITER
,
index_build
_res_str
);
build_index_resources
,
milvus
::
server
::
CONFIG_GPU_RESOURCE_DELIMITER
,
build_index
_res_str
);
s
=
config
.
Set
ResourceConfigIndexBuildResources
(
index_build
_res_str
);
s
=
config
.
Set
GpuResourceConfigBuildIndexResources
(
build_index
_res_str
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Get
ResourceConfigIndexBuildResources
(
index_build
_res_vec
);
s
=
config
.
Get
GpuResourceConfigBuildIndexResources
(
build_index
_res_vec
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
s
.
ok
());
for
(
size_t
i
=
0
;
i
<
index_build
_resources
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
build_index
_resources
.
size
();
i
++
)
{
ASSERT_TRUE
(
index_build_resources
[
i
]
==
index_build
_res_vec
[
i
]);
ASSERT_TRUE
(
std
::
stoi
(
build_index_resources
[
i
].
substr
(
3
))
==
build_index
_res_vec
[
i
]);
}
}
#endif
}
}
TEST_F
(
ConfigTest
,
SERVER_CONFIG_INVALID_TEST
)
{
TEST_F
(
ConfigTest
,
SERVER_CONFIG_INVALID_TEST
)
{
...
@@ -386,18 +378,6 @@ TEST_F(ConfigTest, SERVER_CONFIG_INVALID_TEST) {
...
@@ -386,18 +378,6 @@ TEST_F(ConfigTest, SERVER_CONFIG_INVALID_TEST) {
s
=
config
.
SetCacheConfigCpuCacheThreshold
(
"1.0"
);
s
=
config
.
SetCacheConfigCpuCacheThreshold
(
"1.0"
);
ASSERT_FALSE
(
s
.
ok
());
ASSERT_FALSE
(
s
.
ok
());
#ifdef MILVUS_GPU_VERSION
s
=
config
.
SetCacheConfigGpuCacheCapacity
(
"a"
);
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
SetCacheConfigGpuCacheCapacity
(
"128"
);
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
SetCacheConfigGpuCacheThreshold
(
"a"
);
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
SetCacheConfigGpuCacheThreshold
(
"1.0"
);
ASSERT_FALSE
(
s
.
ok
());
#endif
s
=
config
.
SetCacheConfigCacheInsertData
(
"N"
);
s
=
config
.
SetCacheConfigCacheInsertData
(
"N"
);
ASSERT_FALSE
(
s
.
ok
());
ASSERT_FALSE
(
s
.
ok
());
...
@@ -413,20 +393,29 @@ TEST_F(ConfigTest, SERVER_CONFIG_INVALID_TEST) {
...
@@ -413,20 +393,29 @@ TEST_F(ConfigTest, SERVER_CONFIG_INVALID_TEST) {
s
=
config
.
SetEngineConfigGpuSearchThreshold
(
"-1"
);
s
=
config
.
SetEngineConfigGpuSearchThreshold
(
"-1"
);
ASSERT_FALSE
(
s
.
ok
());
ASSERT_FALSE
(
s
.
ok
());
/* resource config */
/* gpu resource config */
s
=
config
.
SetResourceConfigMode
(
"default"
);
s
=
config
.
SetGpuResourceConfigEnableGpu
(
"ok"
);
ASSERT_FALSE
(
s
.
ok
());
#ifdef MILVUS_GPU_VERSION
s
=
config
.
SetGpuResourceConfigCacheCapacity
(
"a"
);
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
SetGpuResourceConfigCacheCapacity
(
"128"
);
ASSERT_FALSE
(
s
.
ok
());
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
SetResourceConfigSearchResources
(
"gpu10"
);
s
=
config
.
SetGpuResourceConfigCacheThreshold
(
"a"
);
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
SetGpuResourceConfigCacheThreshold
(
"1.0"
);
ASSERT_FALSE
(
s
.
ok
());
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
Set
ResourceConfigSearchResources
(
"cpu
"
);
s
=
config
.
Set
GpuResourceConfigSearchResources
(
"gpu10
"
);
ASSERT_
TRU
E
(
s
.
ok
());
ASSERT_
FALS
E
(
s
.
ok
());
s
=
config
.
Set
ResourceConfigIndexBuild
Resources
(
"gup2"
);
s
=
config
.
Set
GpuResourceConfigBuildIndex
Resources
(
"gup2"
);
ASSERT_FALSE
(
s
.
ok
());
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
Set
ResourceConfigIndexBuild
Resources
(
"gpu16"
);
s
=
config
.
Set
GpuResourceConfigBuildIndex
Resources
(
"gpu16"
);
ASSERT_FALSE
(
s
.
ok
());
ASSERT_FALSE
(
s
.
ok
());
#endif
}
}
TEST_F
(
ConfigTest
,
SERVER_CONFIG_TEST
)
{
TEST_F
(
ConfigTest
,
SERVER_CONFIG_TEST
)
{
...
@@ -443,4 +432,3 @@ TEST_F(ConfigTest, SERVER_CONFIG_TEST) {
...
@@ -443,4 +432,3 @@ TEST_F(ConfigTest, SERVER_CONFIG_TEST) {
s
=
config
.
ResetDefaultConfig
();
s
=
config
.
ResetDefaultConfig
();
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
s
.
ok
());
}
}
core/unittest/server/test_rpc.cpp
浏览文件 @
7f5c2fef
...
@@ -85,7 +85,6 @@ class RpcHandlerTest : public testing::Test {
...
@@ -85,7 +85,6 @@ class RpcHandlerTest : public testing::Test {
// DBWrapper::GetInstance().GetInstance().StartService();
// DBWrapper::GetInstance().GetInstance().StartService();
// DBWrapper::GetInstance().GetInstance().StopService();
// DBWrapper::GetInstance().GetInstance().StopService();
milvus
::
server
::
Config
::
GetInstance
().
SetResourceConfigMode
(
"single"
);
milvus
::
server
::
DBWrapper
::
GetInstance
().
StartService
();
milvus
::
server
::
DBWrapper
::
GetInstance
().
StartService
();
// initialize handler, create table
// initialize handler, create table
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录