Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
e7d459ac
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e7d459ac
编写于
11月 28, 2022
作者:
R
Ruibiao Chen
提交者:
GitHub
11月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove kSyncRun in StreamAnalyzer (#48425)
* Remove kSyncRun in StreamAnalyzer * Update code
上级
2bae75ed
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
26 deletion
+12
-26
paddle/fluid/framework/new_executor/interpreter/stream_analyzer.cc
...uid/framework/new_executor/interpreter/stream_analyzer.cc
+11
-25
paddle/fluid/framework/new_executor/interpreter/stream_analyzer.h
...luid/framework/new_executor/interpreter/stream_analyzer.h
+1
-1
未找到文件。
paddle/fluid/framework/new_executor/interpreter/stream_analyzer.cc
浏览文件 @
e7d459ac
...
...
@@ -64,8 +64,6 @@ class ContextManager {
inline
std
::
string
RunTypeToString
(
DownstreamRunType
run_type
)
{
if
(
run_type
==
DownstreamRunType
::
kDirectRun
)
{
return
"DirectRun"
;
}
else
if
(
run_type
==
DownstreamRunType
::
kSyncRun
)
{
return
"SyncRun"
;
}
else
{
return
"EventRun"
;
}
...
...
@@ -238,16 +236,10 @@ void StreamAnalyzer::AnalyseAllEventInfo(
event_info
)
const
{
for
(
size_t
cur_instr_id
=
0
;
cur_instr_id
<
instructions
.
size
();
++
cur_instr_id
)
{
const
Instruction
&
cur_instr
=
instructions
[
cur_instr_id
];
const
std
::
vector
<
std
::
vector
<
size_t
>>&
next_instr_list
=
run_type_info
[
cur_instr_id
];
const
std
::
vector
<
size_t
>&
next_instr_ids
=
run_type_info
[
cur_instr_id
][
DownstreamRunType
::
kEventRun
];
std
::
set
<
size_t
>
waiter_instr_ids
;
std
::
vector
<
size_t
>
next_instr_ids
=
next_instr_list
[
DownstreamRunType
::
kSyncRun
];
next_instr_ids
.
insert
(
next_instr_ids
.
end
(),
next_instr_list
[
DownstreamRunType
::
kEventRun
].
begin
(),
next_instr_list
[
DownstreamRunType
::
kEventRun
].
end
());
for
(
size_t
next_instr_id
:
next_instr_ids
)
{
AnalyseEventInfoForTwoInstructions
(
instructions
,
run_type_info
,
...
...
@@ -257,8 +249,9 @@ void StreamAnalyzer::AnalyseAllEventInfo(
}
for
(
size_t
waiter_instr_id
:
waiter_instr_ids
)
{
(
*
event_info
)[
&
(
cur_instr
.
DeviceContext
())][
waiter_instr_id
].
insert
(
cur_instr_id
);
(
*
event_info
)[
&
(
instructions
[
cur_instr_id
].
DeviceContext
())]
[
waiter_instr_id
]
.
insert
(
cur_instr_id
);
}
}
}
...
...
@@ -284,7 +277,7 @@ void StreamAnalyzer::AnalyseAllRunType(
}
}
// The caller should guarantee cur_instr and next_instr is k
SyncRun or k
EventRun
// The caller should guarantee cur_instr and next_instr is kEventRun
void
StreamAnalyzer
::
AnalyseEventInfoForTwoInstructions
(
const
std
::
vector
<
Instruction
>&
instructions
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
size_t
>>>&
run_type_info
,
...
...
@@ -311,7 +304,6 @@ void StreamAnalyzer::AnalyseEventInfoForTwoInstructions(
// can only add event for it with the help of depend_op.
if
(
HasDataDependency
(
instructions
[
cur_instr_id
],
instructions
[
next_instr_id
])
||
run_type_info
[
next_instr_id
][
DownstreamRunType
::
kSyncRun
].
size
()
||
run_type_info
[
next_instr_id
][
DownstreamRunType
::
kEventRun
].
size
()
||
instructions
[
next_instr_id
].
OpBase
()
->
Type
()
==
"depend"
)
{
waiter_instr_ids
->
insert
(
next_instr_id
);
...
...
@@ -319,8 +311,8 @@ void StreamAnalyzer::AnalyseEventInfoForTwoInstructions(
}
// NOTE(Ruibiao): If no data dependency from cur_instr to next_instr, and
// simultaneously next_instr has n
either sync_run nor event_run downstream
//
instr, we try to
recursively add events between cur_instr and next_instr's
// simultaneously next_instr has n
o event_run downstream instr, we try to
// recursively add events between cur_instr and next_instr's
// direct-run-instrs. This can delay the event wait and achieve better
// scheduling performance in some scenarios. However, when next_instr has too
// many direct-run-instrs, it may perform worse than add event directly
...
...
@@ -393,15 +385,9 @@ DownstreamRunType StreamAnalyzer::AnalyseRunTypeForTwoInstructions(
}
}
if
(
cur_instr
.
KernelType
()
==
OpFuncType
::
kGpuAsync
)
{
if
(
next_instr
.
KernelType
()
==
OpFuncType
::
kCpuSync
)
{
return
DownstreamRunType
::
kSyncRun
;
}
else
{
// cross-stream: kGpuAsync -> kGpuSync, kGpuAsync -> kGpuSync
if
(
&
cur_instr
.
DeviceContext
()
!=
&
next_instr
.
DeviceContext
())
{
return
DownstreamRunType
::
kEventRun
;
}
}
if
(
cur_instr
.
KernelType
()
==
OpFuncType
::
kGpuAsync
&&
(
&
cur_instr
.
DeviceContext
()
!=
&
next_instr
.
DeviceContext
()))
{
return
DownstreamRunType
::
kEventRun
;
}
return
DownstreamRunType
::
kDirectRun
;
...
...
paddle/fluid/framework/new_executor/interpreter/stream_analyzer.h
浏览文件 @
e7d459ac
...
...
@@ -26,7 +26,7 @@ namespace paddle {
namespace
framework
{
namespace
interpreter
{
enum
DownstreamRunType
{
kDirectRun
,
k
SyncRun
,
k
EventRun
};
enum
DownstreamRunType
{
kDirectRun
,
kEventRun
};
class
StreamAnalyzer
{
public:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录