Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
oneflow
提交
e602cd54
O
oneflow
项目概览
Oneflow-Inc
/
oneflow
上一次同步 接近 3 年
通知
13
Star
2733
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oneflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e602cd54
编写于
6月 09, 2017
作者:
W
Wind5
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove useless var
上级
b1a5b018
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
10 deletion
+30
-10
oneflow/core/actor/fw_data_comp_actor.cpp
oneflow/core/actor/fw_data_comp_actor.cpp
+28
-9
oneflow/core/actor/fw_data_comp_actor.h
oneflow/core/actor/fw_data_comp_actor.h
+2
-1
未找到文件。
oneflow/core/actor/fw_data_comp_actor.cpp
浏览文件 @
e602cd54
#include "oneflow/core/actor/fw_data_comp_actor.h"
#include "oneflow/core/actor/actor_registry.h"
#include "oneflow/core/register/local_register_warpper.h"
namespace
oneflow
{
...
...
@@ -10,12 +11,12 @@ void FwDataCompActor::Init(const TaskProto& task_proto) {
expected_model_version_id_
=
0
;
}
bool
FwDataCompActor
::
IsReadReady
(
uint32_t
staleness
,
uint32_t
num_of_piece_in_batch
)
{
bool
FwDataCompActor
::
IsReadReady
()
{
uint32_t
staleness
=
JobDesc
::
Singleton
().
staleness
();
uint32_t
num_of_piece_in_batch
=
JobDesc
::
Singleton
().
num_of_piece_in_batch
();
if
(
model_regst_
!=
nullptr
&&
model_tmp_regst_
!=
nullptr
&&
!
in_
.
empty
())
{
uint64_t
piece_id
=
in_
.
front
()
->
piece_id
();
if
(
model_regst_
->
model_version_id
()
+
staleness
-
1
>=
piece_id
/
num_of_piece_in_batch
)
{
in_
.
front
()
->
piece_id
()
/
num_of_piece_in_batch
)
{
return
true
;
}
}
...
...
@@ -25,15 +26,24 @@ bool FwDataCompActor::IsReadReady(uint32_t staleness,
void
FwDataCompActor
::
ProcessMsg
(
const
ActorMsg
&
msg
,
const
ThreadContext
&
thread_ctx
)
{
KernelContext
kernel_ctx
;
uint32_t
staleness
=
JobDesc
::
Singleton
().
staleness
();
uint32_t
num_of_piece_in_batch
=
JobDesc
::
Singleton
().
num_of_piece_in_batch
();
if
(
TryOneReadDone
(
msg
.
regst_warpper
()
->
regst_raw_ptr
())
!=
0
)
{
kernel_ctx
.
cuda_stream
=
thread_ctx
.
compute_cuda_stream
;
if
(
msg
.
msg_type
()
==
ActorMsgType
::
kCmdMsg
)
{
TODO
();
}
if
(
TryUpdtStateAsFromRegstReader
(
msg
.
regst_warpper
()
->
regst_raw_ptr
())
!=
0
)
{
std
::
shared_ptr
<
RegstWarpper
>
regst_wp
=
msg
.
regst_warpper
();
if
(
regst_wp
->
regst_desc_id
()
==
model_tmp_regst_desc_id_
)
{
CHECK_EQ
(
model_tmp_regst_
,
nullptr
);
model_tmp_regst_
=
regst_wp
;
ready_in_regst_
[
model_tmp_regst_desc_id_
]
=
regst_wp
;
}
else
if
(
regst_wp
->
regst_desc_id
()
==
model_regst_desc_id_
)
{
CHECK_EQ
(
regst_wp
->
model_version_id
(),
expected_model_version_id_
);
ActorMsgBus
::
Singleton
().
SendMsg
(
ActorMsg
::
BuildMsgForRegstWriter
(
model_regst_
->
producer_actor_id
(),
model_regst_
->
regst_raw_ptr
()));
model_regst_
=
regst_wp
;
ready_in_regst_
[
model_regst_desc_id_
]
=
regst_wp
;
expected_model_version_id_
+=
1
;
}
else
{
in_
.
push
(
regst_wp
);
}
...
...
@@ -44,18 +54,27 @@ void FwDataCompActor::ProcessMsg(const ActorMsg& msg,
}
void
FwDataCompActor
::
WardKernelAndSendMsg
(
const
KernelContext
&
kernel_ctx
)
{
CHECK_EQ
(
in_
.
front
()
->
piece_id
(),
expected_piece_id
());
ready_in_regst_
[
in_
.
front
()
->
regst_desc_id
()]
=
in_
.
front
();
uint64_t
piece_id
=
in_
.
front
()
->
piece_id
();
uint64_t
model_version_id
=
model_regst_
->
model_version_id
();
WardKernel
(
kernel_ctx
,
[
this
](
uint64_t
regst_desc_id
)
->
std
::
shared_ptr
<
RegstWarpper
>
{
Regst
*
regst
=
GetCurWriteableRegst
(
regst_desc_id
);
if
(
regst
==
nullptr
)
{
return
ready_in_regst_
.
front
().
second
->
at
(
regst_desc_id
)
;
return
ready_in_regst_
[
regst_desc_id
]
;
}
else
{
return
std
::
make_shared
<
LocalRegstWarpper
>
(
regst
);
}
});
ForEachCurWriteableRegst
([
piece_id
](
Regst
*
regst
)
{
ForEachCurWriteableRegst
([
piece_id
,
model_version_id
](
Regst
*
regst
)
{
regst
->
set_piece_id
(
piece_id
);
regst
->
set_model_version_id
(
model_version_id
);
});
CurWriteDone
();
ActorMsgBus
::
Singleton
().
SendMsg
(
ActorMsg
::
BuildMsgForRegstWriter
(
in_
.
front
()
->
producer_actor_id
(),
in_
.
front
()
->
regst_raw_ptr
()));
in_
.
pop
();
}
REGISTER_ACTOR
(
kDataCompTask
,
true
,
FwDataCompActor
);
...
...
oneflow/core/actor/fw_data_comp_actor.h
浏览文件 @
e602cd54
...
...
@@ -15,7 +15,7 @@ public:
void
ProcessMsg
(
const
ActorMsg
&
,
const
ThreadContext
&
)
override
;
private:
bool
IsReadReady
(
uint32_t
,
uint32_t
);
bool
IsReadReady
();
void
WardKernelAndSendMsg
(
const
KernelContext
&
);
uint64_t
expected_model_version_id_
;
...
...
@@ -24,6 +24,7 @@ private:
std
::
shared_ptr
<
RegstWarpper
>
model_regst_
;
std
::
shared_ptr
<
RegstWarpper
>
model_tmp_regst_
;
std
::
queue
<
std
::
shared_ptr
<
RegstWarpper
>>
in_
;
HashMap
<
uint64_t
,
std
::
shared_ptr
<
RegstWarpper
>>
ready_in_regst_
;
};
}
// namespace oneflow
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录