Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
dbb0b9b3
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看板
未验证
提交
dbb0b9b3
编写于
3月 07, 2020
作者:
W
wangchaochaohu
提交者:
GitHub
3月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine the profiler print (#22823)
* refine the profiler print test=develop
上级
0038bfbd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
8 deletion
+39
-8
paddle/fluid/framework/parallel_executor.cc
paddle/fluid/framework/parallel_executor.cc
+1
-0
paddle/fluid/platform/profiler_helper.h
paddle/fluid/platform/profiler_helper.h
+38
-8
未找到文件。
paddle/fluid/framework/parallel_executor.cc
浏览文件 @
dbb0b9b3
...
@@ -726,6 +726,7 @@ void ParallelExecutor::BCastParamsToDevices(
...
@@ -726,6 +726,7 @@ void ParallelExecutor::BCastParamsToDevices(
FetchResultType
ParallelExecutor
::
Run
(
FetchResultType
ParallelExecutor
::
Run
(
const
std
::
vector
<
std
::
string
>
&
fetch_tensors
,
bool
return_merged
)
{
const
std
::
vector
<
std
::
string
>
&
fetch_tensors
,
bool
return_merged
)
{
VLOG
(
3
)
<<
"enter ParallelExecutor Run"
;
VLOG
(
3
)
<<
"enter ParallelExecutor Run"
;
platform
::
RecordEvent
parallel_executor_event
(
"ParallelExecutor::Run"
);
#ifdef WITH_GPERFTOOLS
#ifdef WITH_GPERFTOOLS
if
(
gProfileStarted
)
{
if
(
gProfileStarted
)
{
ProfilerFlush
();
ProfilerFlush
();
...
...
paddle/fluid/platform/profiler_helper.h
浏览文件 @
dbb0b9b3
...
@@ -61,6 +61,18 @@ static std::mutex g_all_mem_event_lists_mutex;
...
@@ -61,6 +61,18 @@ static std::mutex g_all_mem_event_lists_mutex;
static
thread_local
int32_t
g_mem_thread_id
;
static
thread_local
int32_t
g_mem_thread_id
;
static
uint32_t
g_mem_next_thread_id
=
0
;
static
uint32_t
g_mem_next_thread_id
=
0
;
static
int
FindNthReversePos
(
const
std
::
string
&
s
,
const
char
ch
,
const
int
N
)
{
int
found_pos
=
-
1
;
auto
pos
=
s
.
rfind
(
'/'
,
s
.
length
()
-
1
);
int
pos_number
=
1
;
while
(
pos
!=
std
::
string
::
npos
&&
pos_number
<
N
)
{
pos
=
s
.
rfind
(
ch
,
pos
-
1
);
pos_number
++
;
}
if
(
pos
!=
std
::
string
::
npos
)
found_pos
=
pos
;
return
found_pos
;
}
inline
uint64_t
GetTimeInNsec
()
{
inline
uint64_t
GetTimeInNsec
()
{
using
clock
=
std
::
conditional
<
std
::
chrono
::
high_resolution_clock
::
is_steady
,
using
clock
=
std
::
conditional
<
std
::
chrono
::
high_resolution_clock
::
is_steady
,
std
::
chrono
::
high_resolution_clock
,
std
::
chrono
::
high_resolution_clock
,
...
@@ -263,8 +275,8 @@ std::function<bool(const EventItem &, const EventItem &)> SetSortedFunc(
...
@@ -263,8 +275,8 @@ std::function<bool(const EventItem &, const EventItem &)> SetSortedFunc(
return
sorted_func
;
return
sorted_func
;
}
}
void
SetEvent
(
bool
merge_thread
,
Event
analyze_event
,
size_t
*
max_name_width
,
void
SetEvent
(
bool
merge_thread
,
const
Event
&
analyze_event
,
std
::
list
<
Event
>
*
pushed_events
,
s
ize_t
*
max_name_width
,
s
td
::
list
<
Event
>
*
pushed_events
,
std
::
vector
<
EventItem
>
*
event_items
,
std
::
vector
<
EventItem
>
*
event_items
,
std
::
unordered_map
<
std
::
string
,
int
>
*
event_idx
)
{
std
::
unordered_map
<
std
::
string
,
int
>
*
event_idx
)
{
if
(
analyze_event
.
type
()
==
EventType
::
kPushRange
)
{
if
(
analyze_event
.
type
()
==
EventType
::
kPushRange
)
{
...
@@ -295,12 +307,22 @@ void SetEvent(bool merge_thread, Event analyze_event, size_t *max_name_width,
...
@@ -295,12 +307,22 @@ void SetEvent(bool merge_thread, Event analyze_event, size_t *max_name_width,
std
::
string
event_name
;
std
::
string
event_name
;
if
(
merge_thread
)
{
if
(
merge_thread
)
{
event_name
=
rit
->
name
();
event_name
=
rit
->
name
();
*
max_name_width
=
std
::
max
(
*
max_name_width
,
event_name
.
size
());
}
else
{
}
else
{
event_name
=
event_name
=
"thread"
+
std
::
to_string
(
rit
->
thread_id
())
+
"::"
+
rit
->
name
();
"thread"
+
std
::
to_string
(
rit
->
thread_id
())
+
"::"
+
rit
->
name
();
*
max_name_width
=
std
::
max
(
*
max_name_width
,
event_name
.
size
());
}
}
auto
print_name_size
=
event_name
.
size
();
int
found_pos
=
0
;
if
(
rit
->
role
()
==
EventRole
::
kInnerOp
&&
g_tracer_option
!=
TracerOption
::
kDefault
&&
(
found_pos
=
FindNthReversePos
(
event_name
,
'/'
,
2
))
!=
-
1
)
{
print_name_size
=
event_name
.
size
()
-
(
found_pos
+
1
);
}
else
if
((
found_pos
=
FindNthReversePos
(
event_name
,
'/'
,
1
))
!=
-
1
&&
(
rit
->
role
()
!=
EventRole
::
kInnerOp
||
g_tracer_option
==
TracerOption
::
kDefault
))
{
print_name_size
=
event_name
.
size
()
-
(
found_pos
+
1
);
}
*
max_name_width
=
std
::
max
(
*
max_name_width
,
print_name_size
);
if
(
event_idx
->
find
(
event_name
)
==
event_idx
->
end
())
{
if
(
event_idx
->
find
(
event_name
)
==
event_idx
->
end
())
{
event_idx
->
insert
({
event_name
,
event_items
->
size
()});
event_idx
->
insert
({
event_name
,
event_items
->
size
()});
...
@@ -455,7 +477,7 @@ void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table,
...
@@ -455,7 +477,7 @@ void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table,
const
std
::
multimap
<
std
::
string
,
EventItem
>
&
child_map
,
const
std
::
multimap
<
std
::
string
,
EventItem
>
&
child_map
,
const
OverHead
&
overhead
,
const
std
::
string
&
sorted_domain
,
const
OverHead
&
overhead
,
const
std
::
string
&
sorted_domain
,
const
size_t
name_width
,
const
size_t
data_width
,
const
size_t
name_width
,
const
size_t
data_width
,
bool
merge_thread
,
int
print_depth
,
int
remove_len
)
{
bool
merge_thread
,
int
print_depth
)
{
if
(
print_depth
==
0
)
{
if
(
print_depth
==
0
)
{
// Output header information
// Output header information
std
::
cout
<<
"
\n
------------------------->"
std
::
cout
<<
"
\n
------------------------->"
...
@@ -514,9 +536,16 @@ void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table,
...
@@ -514,9 +536,16 @@ void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table,
table
.
push_back
(
it
->
second
);
table
.
push_back
(
it
->
second
);
}
}
}
}
child_table
.
push_back
(
table
);
if
(
!
table
.
empty
())
child_table
.
push_back
(
table
);
auto
name_len
=
event_item
.
name
.
length
();
auto
name_len
=
event_item
.
name
.
length
();
int
remove_len
=
0
;
int
Nth
=
1
;
int
found_pos
=
0
;
if
(
event_item
.
role
==
EventRole
::
kInnerOp
)
Nth
=
2
;
found_pos
=
FindNthReversePos
(
event_item
.
name
,
'/'
,
Nth
);
if
(
found_pos
!=
-
1
)
remove_len
=
found_pos
+
1
;
std
::
string
print_name
=
event_item
.
name
.
substr
(
remove_len
,
name_len
);
std
::
string
print_name
=
event_item
.
name
.
substr
(
remove_len
,
name_len
);
std
::
string
delimiter
;
std
::
string
delimiter
;
for
(
int
i
=
0
;
i
<
print_depth
;
i
++
)
{
for
(
int
i
=
0
;
i
<
print_depth
;
i
++
)
{
...
@@ -541,8 +570,9 @@ void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table,
...
@@ -541,8 +570,9 @@ void PrintProfiler(const std::vector<std::vector<EventItem>> &events_table,
<<
std
::
setw
(
data_width
)
<<
event_item
.
max_time
<<
std
::
setw
(
data_width
)
<<
event_item
.
max_time
<<
std
::
setw
(
data_width
)
<<
event_item
.
ave_time
<<
std
::
setw
(
data_width
)
<<
event_item
.
ave_time
<<
std
::
setw
(
data_width
)
<<
event_item
.
ratio
<<
std
::
endl
;
<<
std
::
setw
(
data_width
)
<<
event_item
.
ratio
<<
std
::
endl
;
PrintProfiler
(
child_table
,
child_map
,
overhead
,
sorted_domain
,
name_width
,
PrintProfiler
(
child_table
,
child_map
,
overhead
,
sorted_domain
,
name_width
,
data_width
,
merge_thread
,
print_depth
+
1
,
0
);
data_width
,
merge_thread
,
print_depth
+
1
);
}
}
}
}
}
}
...
@@ -662,7 +692,7 @@ void ParseEvents(const std::vector<std::vector<Event>> &events,
...
@@ -662,7 +692,7 @@ void ParseEvents(const std::vector<std::vector<Event>> &events,
// Print report
// Print report
PrintProfiler
(
events_table
,
child_map
,
overhead
,
sorted_domain
,
PrintProfiler
(
events_table
,
child_map
,
overhead
,
sorted_domain
,
max_name_width
+
8
,
12
,
merge_thread
,
0
,
0
);
max_name_width
+
8
,
12
,
merge_thread
,
0
);
}
}
}
// namespace platform
}
// namespace platform
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录