Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
502f1a95
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,发现更多精彩内容 >>
提交
502f1a95
编写于
5月 31, 2019
作者:
X
xj.lin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MS-27 support gpu config
Former-commit-id: 08749b66413000571d733a28303eed3944220a9b
上级
84396d05
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
16 deletion
+47
-16
cpp/CHANGELOG.md
cpp/CHANGELOG.md
+1
-0
cpp/CMakeLists.txt
cpp/CMakeLists.txt
+4
-4
cpp/src/wrapper/IndexBuilder.cpp
cpp/src/wrapper/IndexBuilder.cpp
+34
-4
cpp/src/wrapper/IndexBuilder.h
cpp/src/wrapper/IndexBuilder.h
+8
-8
未找到文件。
cpp/CHANGELOG.md
浏览文件 @
502f1a95
...
@@ -17,6 +17,7 @@ Please mark all change in change log and use the ticket from JIRA.
...
@@ -17,6 +17,7 @@ Please mark all change in change log and use the ticket from JIRA.
-
MS-26 - cmake. Add thirdparty packages
-
MS-26 - cmake. Add thirdparty packages
-
MS-31 - cmake: add prometheus
-
MS-31 - cmake: add prometheus
-
MS-33 - cmake: add -j4 to make third party packages build faster
-
MS-33 - cmake: add -j4 to make third party packages build faster
-
MS-27 - support gpu config and disable license build config in cmake
### Task
### Task
...
...
cpp/CMakeLists.txt
浏览文件 @
502f1a95
...
@@ -58,10 +58,10 @@ endif()
...
@@ -58,10 +58,10 @@ endif()
if
(
CMAKE_BUILD_TYPE STREQUAL
"Release"
)
if
(
CMAKE_BUILD_TYPE STREQUAL
"Release"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-O3 -fPIC -DELPP_THREAD_SAFE -fopenmp"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-O3 -fPIC -DELPP_THREAD_SAFE -fopenmp"
)
if
(
GPU_VERSION STREQUAL
"ON"
)
#
if (GPU_VERSION STREQUAL "ON")
set
(
ENABLE_LICENSE
"ON"
)
#
set(ENABLE_LICENSE "ON")
add_definitions
(
"-DENABLE_LICENSE"
)
#
add_definitions("-DENABLE_LICENSE")
endif
()
#
endif ()
else
()
else
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-O0 -g -fPIC -DELPP_THREAD_SAFE -fopenmp"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-O0 -g -fPIC -DELPP_THREAD_SAFE -fopenmp"
)
endif
()
endif
()
...
...
cpp/src/wrapper/IndexBuilder.cpp
浏览文件 @
502f1a95
...
@@ -6,14 +6,19 @@
...
@@ -6,14 +6,19 @@
#include "mutex"
#include "mutex"
#ifdef GPU_VERSION
#ifdef GPU_VERSION
#include <faiss/gpu/StandardGpuResources.h>
#include <faiss/gpu/StandardGpuResources.h>
#include
"faiss/gpu/GpuIndexIVFFlat.h"
#include
<faiss/gpu/GpuIndexIVFFlat.h>
#include
"faiss/gpu/GpuAutoTune.h"
#include
<faiss/gpu/GpuAutoTune.h>
#endif
#endif
#include "faiss/IndexFlat.h"
#include <faiss/IndexFlat.h>
#include <easylogging++.h>
#include "server/ServerConfig.h"
#include "IndexBuilder.h"
#include "IndexBuilder.h"
...
@@ -21,6 +26,31 @@ namespace zilliz {
...
@@ -21,6 +26,31 @@ namespace zilliz {
namespace
vecwise
{
namespace
vecwise
{
namespace
engine
{
namespace
engine
{
class
GpuResources
{
public:
static
GpuResources
&
GetInstance
()
{
static
GpuResources
instance
;
return
instance
;
}
void
SelectGpu
()
{
using
namespace
zilliz
::
vecwise
::
server
;
ServerConfig
&
config
=
ServerConfig
::
GetInstance
();
ConfigNode
server_config
=
config
.
GetConfig
(
CONFIG_SERVER
);
gpu_num
=
server_config
.
GetInt32Value
(
"gpu_index"
,
0
);
}
int32_t
GetGpu
()
{
return
gpu_num
;
}
private:
GpuResources
()
:
gpu_num
(
0
)
{
SelectGpu
();
}
private:
int32_t
gpu_num
;
};
using
std
::
vector
;
using
std
::
vector
;
static
std
::
mutex
gpu_resource
;
static
std
::
mutex
gpu_resource
;
...
@@ -44,7 +74,7 @@ Index_ptr IndexBuilder::build_all(const long &nb,
...
@@ -44,7 +74,7 @@ Index_ptr IndexBuilder::build_all(const long &nb,
std
::
lock_guard
<
std
::
mutex
>
lk
(
gpu_resource
);
std
::
lock_guard
<
std
::
mutex
>
lk
(
gpu_resource
);
faiss
::
gpu
::
StandardGpuResources
res
;
faiss
::
gpu
::
StandardGpuResources
res
;
auto
device_index
=
faiss
::
gpu
::
index_cpu_to_gpu
(
&
res
,
0
,
ori_index
);
auto
device_index
=
faiss
::
gpu
::
index_cpu_to_gpu
(
&
res
,
GpuResources
::
GetInstance
().
GetGpu
()
,
ori_index
);
if
(
!
device_index
->
is_trained
)
{
if
(
!
device_index
->
is_trained
)
{
nt
==
0
||
xt
==
nullptr
?
device_index
->
train
(
nb
,
xb
)
nt
==
0
||
xt
==
nullptr
?
device_index
->
train
(
nb
,
xb
)
:
device_index
->
train
(
nt
,
xt
);
:
device_index
->
train
(
nt
,
xt
);
...
...
cpp/src/wrapper/IndexBuilder.h
浏览文件 @
502f1a95
...
@@ -32,14 +32,14 @@ class IndexBuilder {
...
@@ -32,14 +32,14 @@ class IndexBuilder {
const
long
&
nt
=
0
,
const
long
&
nt
=
0
,
const
std
::
vector
<
float
>
&
xt
=
std
::
vector
<
float
>
());
const
std
::
vector
<
float
>
&
xt
=
std
::
vector
<
float
>
());
void
train
(
const
long
&
nt
,
//
void train(const long &nt,
const
std
::
vector
<
float
>
&
xt
);
//
const std::vector<float> &xt);
//
Index_ptr
add
(
const
long
&
nb
,
//
Index_ptr add(const long &nb,
const
std
::
vector
<
float
>
&
xb
,
//
const std::vector<float> &xb,
const
std
::
vector
<
long
>
&
ids
);
//
const std::vector<long> &ids);
//
void
set_build_option
(
const
Operand_ptr
&
opd
);
//
void set_build_option(const Operand_ptr &opd);
protected:
protected:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录