Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
84498198
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
84498198
编写于
4月 28, 2020
作者:
B
baolei.an
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[LITE][BM] multi device ok,test=develop
上级
10ce7d3c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
21 addition
and
20 deletion
+21
-20
lite/backends/bm/target_wrapper.cc
lite/backends/bm/target_wrapper.cc
+7
-6
lite/backends/bm/target_wrapper.h
lite/backends/bm/target_wrapper.h
+1
-0
lite/core/context.h
lite/core/context.h
+13
-14
未找到文件。
lite/backends/bm/target_wrapper.cc
浏览文件 @
84498198
...
@@ -24,16 +24,17 @@ std::map<int, void*> TargetWrapperBM::bm_hds_;
...
@@ -24,16 +24,17 @@ std::map<int, void*> TargetWrapperBM::bm_hds_;
size_t
TargetWrapperBM
::
num_devices
()
{
size_t
TargetWrapperBM
::
num_devices
()
{
int
count
=
0
;
int
count
=
0
;
bm_dev_getcount
(
&
count
);
bm_status_t
ret
=
bm_dev_getcount
(
&
count
);
CHECK_EQ
(
ret
,
BM_SUCCESS
)
<<
"Failed with error code: "
<<
static_cast
<
int
>
(
ret
);
return
count
;
return
count
;
}
}
int
TargetWrapperBM
::
GetDevice
()
{
return
device_id_
;
}
void
TargetWrapperBM
::
SetDevice
(
int
id
)
{
void
TargetWrapperBM
::
SetDevice
(
int
id
)
{
/*
if
(
id
<
0
||
(
size_t
)
id
>=
num_devices
())
{
if
(
id
<
0
||
(
size_t
)
id
>=
num_devices
())
{
LOG
(
FATAL
)
<<
"Failed with invalid device id "
<<
id
;
LOG
(
FATAL
)
<<
"Failed with invalid device id "
<<
id
;
}
}
*/
device_id_
=
id
;
device_id_
=
id
;
if
(
bm_hds_
.
find
(
id
)
==
bm_hds_
.
end
())
{
if
(
bm_hds_
.
find
(
id
)
==
bm_hds_
.
end
())
{
bm_handle_t
bm_handle
;
bm_handle_t
bm_handle
;
...
...
lite/backends/bm/target_wrapper.h
浏览文件 @
84498198
...
@@ -31,6 +31,7 @@ class TargetWrapper<TARGET(kBM)> {
...
@@ -31,6 +31,7 @@ class TargetWrapper<TARGET(kBM)> {
static
size_t
maximum_stream
()
{
return
0
;
}
static
size_t
maximum_stream
()
{
return
0
;
}
static
void
SetDevice
(
int
id
);
static
void
SetDevice
(
int
id
);
static
int
GetDevice
();
static
void
CreateStream
(
stream_t
*
stream
)
{}
static
void
CreateStream
(
stream_t
*
stream
)
{}
static
void
DestroyStream
(
const
stream_t
&
stream
)
{}
static
void
DestroyStream
(
const
stream_t
&
stream
)
{}
...
...
lite/core/context.h
浏览文件 @
84498198
...
@@ -110,9 +110,8 @@ class Context<TargetType::kBM> {
...
@@ -110,9 +110,8 @@ class Context<TargetType::kBM> {
Context
()
{}
Context
()
{}
explicit
Context
(
const
BMContext
&
ctx
);
explicit
Context
(
const
BMContext
&
ctx
);
// NOTE: InitOnce should only be used by ContextScheduler
// NOTE: InitOnce should only be used by ContextScheduler
void
InitOnce
()
{
Init
(
0
);
}
void
InitOnce
()
{
TargetWrapperBM
::
SetDevice
(
TargetWrapperBM
::
GetDevice
()
);
}
void
Init
(
int
dev_id
)
{
TargetWrapperBM
::
SetDevice
(
dev_id
);
}
void
CopySharedTo
(
BMContext
*
ctx
)
{}
void
CopySharedTo
(
BMContext
*
ctx
)
{}
void
*
GetHandle
()
{
return
TargetWrapperBM
::
GetHandle
();
}
void
*
GetHandle
()
{
return
TargetWrapperBM
::
GetHandle
();
}
...
@@ -151,23 +150,14 @@ class Context<TargetType::kXPU> {
...
@@ -151,23 +150,14 @@ class Context<TargetType::kXPU> {
if
(
_tls_raw_ctx
==
nullptr
)
{
if
(
_tls_raw_ctx
==
nullptr
)
{
_tls_raw_ctx
=
xdnn
::
create_context
();
_tls_raw_ctx
=
xdnn
::
create_context
();
CHECK
(
_tls_raw_ctx
);
CHECK
(
_tls_raw_ctx
);
int
r
=
xdnn
::
set_workspace_l3_size
(
_tls_raw_ctx
,
_workspace_l3_size_per_thread
);
if
(
r
!=
0
)
{
LOG
(
WARNING
)
<<
"xdnn::set_workspace_l3_size() failed, r = "
<<
r
<<
", _workspace_l3_size_per_thread = "
<<
_workspace_l3_size_per_thread
;
}
}
}
return
_tls_raw_ctx
;
return
_tls_raw_ctx
;
}
}
static
void
SetWorkspaceL3Size
(
int
l3_size
=
0xfffc00
)
{
static
void
SetWorkspaceL3Size
(
int
l3_size
=
0xfffc00
)
{
_workspace_l3_size_per_thread
=
l3_size
;
xdnn
::
set_workspace_l3_size
(
GetRawContext
(),
l3_size
)
;
}
}
// **DEPRECATED**, use xpu_set_device() at the very beginning of each worker
// thread
static
void
SetDev
(
int
dev_no
=
0
)
{
static
void
SetDev
(
int
dev_no
=
0
)
{
const
char
*
dev_env
=
getenv
(
"LITE_XPU_DEV"
);
const
char
*
dev_env
=
getenv
(
"LITE_XPU_DEV"
);
if
(
dev_env
)
{
if
(
dev_env
)
{
...
@@ -182,7 +172,6 @@ class Context<TargetType::kXPU> {
...
@@ -182,7 +172,6 @@ class Context<TargetType::kXPU> {
private:
private:
static
thread_local
xdnn
::
Context
*
_tls_raw_ctx
;
static
thread_local
xdnn
::
Context
*
_tls_raw_ctx
;
static
int
_workspace_l3_size_per_thread
;
};
};
#endif
#endif
...
@@ -350,17 +339,27 @@ class Context<TargetType::kX86> {
...
@@ -350,17 +339,27 @@ class Context<TargetType::kX86> {
template
<
>
template
<
>
class
Context
<
TargetType
::
kOpenCL
>
{
class
Context
<
TargetType
::
kOpenCL
>
{
std
::
shared_ptr
<
CLContext
>
cl_context_
;
std
::
shared_ptr
<
CLContext
>
cl_context_
;
using
WaitListType
=
std
::
unordered_map
<
decltype
(
static_cast
<
const
void
*>
(
nullptr
)),
std
::
shared_ptr
<
cl
::
Event
>>
;
std
::
shared_ptr
<
WaitListType
>
cl_wait_list_
;
public:
public:
CLContext
*
cl_context
()
{
return
cl_context_
.
get
();
}
CLContext
*
cl_context
()
{
return
cl_context_
.
get
();
}
WaitListType
*
cl_wait_list
()
{
return
cl_wait_list_
.
get
();
}
void
InitOnce
()
{
void
InitOnce
()
{
// Init cl runtime.
// Init cl runtime.
CHECK
(
CLRuntime
::
Global
()
->
IsInitSuccess
())
<<
"OpenCL runtime init failed"
;
CHECK
(
CLRuntime
::
Global
()
->
IsInitSuccess
())
<<
"OpenCL runtime init failed"
;
cl_context_
=
std
::
make_shared
<
CLContext
>
();
cl_context_
=
std
::
make_shared
<
CLContext
>
();
cl_wait_list_
=
std
::
make_shared
<
WaitListType
>
();
}
}
void
CopySharedTo
(
OpenCLContext
*
ctx
)
{
ctx
->
cl_context_
=
cl_context_
;
}
void
CopySharedTo
(
OpenCLContext
*
ctx
)
{
ctx
->
cl_context_
=
cl_context_
;
ctx
->
cl_wait_list_
=
cl_wait_list_
;
}
};
};
#endif
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录