Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
10106341
MegEngine
项目概览
MegEngine 天元
/
MegEngine
大约 1 年 前同步成功
通知
399
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
10106341
编写于
9月 24, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mgb/opr): fix take CpuDispatchableBase::EventImpl as CpuEventImpl
GitOrigin-RevId: 07aa8508374747b920721e88b6e246ca047d5fc0
上级
b2f9efb8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
24 deletion
+49
-24
src/core/impl/comp_node/cpu/comp_node.cpp
src/core/impl/comp_node/cpu/comp_node.cpp
+38
-11
src/core/impl/comp_node/cpu/comp_node.h
src/core/impl/comp_node/cpu/comp_node.h
+11
-13
未找到文件。
src/core/impl/comp_node/cpu/comp_node.cpp
浏览文件 @
10106341
...
...
@@ -351,6 +351,7 @@ class CpuCompNode::CompNodeImpl final: public CpuDispatchableBase {
//! used during comp node seq rec
class
CompSeqRecEventImpl
;
class
CpuEventImpl
;
SeqRecorderImpl
*
m_cur_recorder
=
nullptr
;
std
::
mutex
m_cur_recorder_mtx
;
...
...
@@ -633,6 +634,42 @@ public:
using
EventImpl
::
EventImpl
;
};
class
CpuCompNodeImpl
::
CpuEventImpl
final
:
public
CpuDispatchableBase
::
EventImpl
{
#if MGB_HAVE_THREAD
void
host_wait_cv
()
override
{
for
(
size_t
i
=
0
,
it
=
SCQueueSynchronizer
::
max_spin
()
/
20
;
i
<
it
;
++
i
)
{
if
(
finished
())
{
auto
thread_pool
=
static_cast
<
CpuCompNodeImpl
*>
(
m_comp_node_impl
)
->
get_thread_pool
();
if
(
thread_pool
)
{
thread_pool
->
deactive
();
}
return
;
}
}
m_dev_wait_nr_waiter
.
fetch_add
(
1
,
std
::
memory_order_release
);
for
(;;)
{
std
::
unique_lock
<
std
::
mutex
>
lock
{
m_dev_wait_mtx
};
if
(
finished
())
{
break
;
}
m_dev_wait_cv
.
wait
(
lock
);
}
m_dev_wait_nr_waiter
.
fetch_sub
(
1
,
std
::
memory_order_release
);
auto
thread_pool
=
static_cast
<
CpuCompNodeImpl
*>
(
m_comp_node_impl
)
->
get_thread_pool
();
if
(
thread_pool
)
{
thread_pool
->
deactive
();
}
}
#endif
public:
using
EventImpl
::
EventImpl
;
};
std
::
unique_ptr
<
CompNode
::
Event
>
CpuCompNodeImpl
::
create_event
(
size_t
flags
)
{
if
(
m_worker_queue
)
{
m_worker_queue
->
check_exception
();
...
...
@@ -640,7 +677,7 @@ std::unique_ptr<CompNode::Event> CpuCompNodeImpl::create_event(size_t flags) {
if
(
m_cur_recorder
)
{
return
std
::
make_unique
<
CompSeqRecEventImpl
>
(
this
,
flags
);
}
else
{
return
std
::
make_unique
<
EventImpl
>
(
this
,
flags
);
return
std
::
make_unique
<
Cpu
EventImpl
>
(
this
,
flags
);
}
}
...
...
@@ -921,11 +958,6 @@ bool CpuCompNode::CpuDispatchableBase::EventImpl::do_finished() {
void
CpuCompNode
::
CpuDispatchableBase
::
EventImpl
::
host_wait_cv
()
{
for
(
size_t
i
=
0
,
it
=
SCQueueSynchronizer
::
max_spin
()
/
20
;
i
<
it
;
++
i
)
{
if
(
finished
())
{
auto
thread_pool
=
static_cast
<
CpuCompNodeImpl
*>
(
m_comp_node_impl
)
->
get_thread_pool
();
if
(
thread_pool
)
{
thread_pool
->
deactive
();
}
return
;
}
}
...
...
@@ -939,11 +971,6 @@ void CpuCompNode::CpuDispatchableBase::EventImpl::host_wait_cv() {
m_dev_wait_cv
.
wait
(
lock
);
}
m_dev_wait_nr_waiter
.
fetch_sub
(
1
,
std
::
memory_order_release
);
auto
thread_pool
=
static_cast
<
CpuCompNodeImpl
*>
(
m_comp_node_impl
)
->
get_thread_pool
();
if
(
thread_pool
)
{
thread_pool
->
deactive
();
}
}
CpuCompNode
::
CpuDispatchableBase
::
EventImpl
::~
EventImpl
()
noexcept
{
...
...
src/core/impl/comp_node/cpu/comp_node.h
浏览文件 @
10106341
...
...
@@ -64,9 +64,8 @@ namespace mgb {
//! implement Event on CpuDispatchableBase comp nodes
class
CpuCompNode
::
CpuDispatchableBase
::
EventImpl
:
public
EventImplHelper
{
protected:
TimeSpec
m_prev_finish_time
;
#if MGB_HAVE_THREAD
std
::
atomic_size_t
m_record_nr_req
{
0
},
m_record_nr_finish
{
0
},
...
...
@@ -83,22 +82,21 @@ namespace mgb {
void
host_wait_cv
()
override
;
protected:
void
do_record
()
override
;
void
do_record
()
override
;
//! incr m_record_nr_req; this is used in do_record()
void
incr_nr_req
()
{
//! incr m_record_nr_req; this is used in do_record()
void
incr_nr_req
()
{
#if MGB_HAVE_THREAD
m_record_nr_req
.
fetch_add
(
1
,
std
::
memory_order_relaxed
);
m_record_nr_req
.
fetch_add
(
1
,
std
::
memory_order_relaxed
);
#endif
}
}
//! callback to be dispatched to comp node
void
on_finish
();
//! callback to be dispatched to comp node
void
on_finish
();
public:
using
EventImplHelper
::
EventImplHelper
;
~
EventImpl
()
noexcept
;
public:
using
EventImplHelper
::
EventImplHelper
;
~
EventImpl
()
noexcept
;
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录