Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
b7e6bd7b
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看板
提交
b7e6bd7b
编写于
8月 06, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(profiler): custom event support device
GitOrigin-RevId: 4709c44b399b22e6f84b198730f4cdb6d78d6074
上级
defbc20e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
3 deletion
+49
-3
imperative/src/impl/interpreter/interpreter_impl.cpp
imperative/src/impl/interpreter/interpreter_impl.cpp
+14
-0
imperative/src/impl/profiler/chrome_timeline.cpp
imperative/src/impl/profiler/chrome_timeline.cpp
+18
-3
imperative/src/impl/profiler/events.h
imperative/src/impl/profiler/events.h
+1
-0
imperative/src/impl/profiler/states.h
imperative/src/impl/profiler/states.h
+16
-0
未找到文件。
imperative/src/impl/interpreter/interpreter_impl.cpp
浏览文件 @
b7e6bd7b
...
@@ -78,6 +78,20 @@ void imperative_log_profile(const char* message){
...
@@ -78,6 +78,20 @@ void imperative_log_profile(const char* message){
imperative_log_profile_end
(
message
);
imperative_log_profile_end
(
message
);
}
}
SYMBOL_EXPORT
void
imperative_log_profile_begin
(
const
char
*
message
,
const
char
*
device
)
{
auto
comp_node
=
CompNode
::
load
(
device
);
MGB_RECORD_EVENT
(
CustomEvent
,
std
::
string
{
message
},
{},
comp_node
);
MGB_RECORD_EVENT
(
RecordDeviceEvent
,
EventPool
::
with_timer
().
alloc_shared
(
comp_node
));
}
SYMBOL_EXPORT
void
imperative_log_profile_end
(
const
char
*
message
,
const
char
*
device
)
{
auto
comp_node
=
CompNode
::
load
(
device
);
MGB_RECORD_EVENT
(
RecordDeviceEvent
,
EventPool
::
with_timer
().
alloc_shared
(
comp_node
));
MGB_RECORD_EVENT
(
CustomFinishEvent
,
std
::
string
{
message
},
{},
comp_node
);
}
}
}
std
::
thread
::
id
ChannelImpl
::
get_worker_tid
()
{
std
::
thread
::
id
ChannelImpl
::
get_worker_tid
()
{
...
...
imperative/src/impl/profiler/chrome_timeline.cpp
浏览文件 @
b7e6bd7b
...
@@ -350,8 +350,14 @@ struct ChromeTimelineEventVisitor: EventVisitor<ChromeTimelineEventVisitor> {
...
@@ -350,8 +350,14 @@ struct ChromeTimelineEventVisitor: EventVisitor<ChromeTimelineEventVisitor> {
new_host_event
(
"StopProfile"
,
'E'
);
new_host_event
(
"StopProfile"
,
'E'
);
}
else
if
constexpr
(
std
::
is_same_v
<
TEvent
,
CustomEvent
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
TEvent
,
CustomEvent
>
)
{
new_host_event
(
event
.
title
,
'B'
);
new_host_event
(
event
.
title
,
'B'
);
if
(
event
.
device
.
valid
())
{
new_device_event
(
event
.
title
,
'B'
,
event
.
device
);
}
}
else
if
constexpr
(
std
::
is_same_v
<
TEvent
,
CustomFinishEvent
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
TEvent
,
CustomFinishEvent
>
)
{
new_host_event
(
event
.
title
,
'E'
);
new_host_event
(
event
.
title
,
'E'
);
if
(
event
.
device
.
valid
())
{
new_device_event
(
event
.
title
,
'E'
,
event
.
device
);
}
}
else
if
constexpr
(
std
::
is_same_v
<
TEvent
,
AutoEvictEvent
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
TEvent
,
AutoEvictEvent
>
)
{
new_host_event
(
"AutoEvict"
,
'B'
);
new_host_event
(
"AutoEvict"
,
'B'
);
}
else
if
constexpr
(
std
::
is_same_v
<
TEvent
,
AutoEvictFinishEvent
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
TEvent
,
AutoEvictFinishEvent
>
)
{
...
@@ -378,12 +384,21 @@ struct ChromeTimelineEventVisitor: EventVisitor<ChromeTimelineEventVisitor> {
...
@@ -378,12 +384,21 @@ struct ChromeTimelineEventVisitor: EventVisitor<ChromeTimelineEventVisitor> {
}
}
void
name_threads
(
Profiler
::
thread_dict_t
thread_dict
)
{
void
name_threads
(
Profiler
::
thread_dict_t
thread_dict
)
{
for
(
auto
&&
[
tid
,
tname
]
:
thread_dict
)
{
for
(
auto
&&
host
:
host_threads
())
{
if
(
thread_dict
.
count
(
host
))
{
trace_events
.
new_event
()
.
name
(
"thread_name"
)
.
pid
(
'M'
)
.
tid
(
to_tid
(
host
))
.
arg
(
"name"
,
thread_dict
.
at
(
host
));
}
}
for
(
auto
&&
device
:
devices
())
{
trace_events
.
new_event
()
trace_events
.
new_event
()
.
name
(
"thread_name"
)
.
name
(
"thread_name"
)
.
pid
(
'M'
)
.
pid
(
'M'
)
.
tid
(
to_tid
(
tid
))
.
tid
(
to_tid
(
device
))
.
arg
(
"name"
,
tname
);
.
arg
(
"name"
,
device
.
to_string_logical
()
);
}
}
}
}
};
};
...
...
imperative/src/impl/profiler/events.h
浏览文件 @
b7e6bd7b
...
@@ -179,6 +179,7 @@ DEF_DUR_EVENT(AutoEvict, {});
...
@@ -179,6 +179,7 @@ DEF_DUR_EVENT(AutoEvict, {});
DEF_DUR_EVENT
(
Custom
,
{
DEF_DUR_EVENT
(
Custom
,
{
std
::
string
title
;
std
::
string
title
;
std
::
string
content
;
std
::
string
content
;
CompNode
device
;
});
});
DEF_EVENT
(
RecordDevice
,
{
DEF_EVENT
(
RecordDevice
,
{
...
...
imperative/src/impl/profiler/states.h
浏览文件 @
b7e6bd7b
...
@@ -218,6 +218,22 @@ protected:
...
@@ -218,6 +218,22 @@ protected:
return
m_device_tid_table
.
at
(
device
);
return
m_device_tid_table
.
at
(
device
);
}
}
SmallVector
<
std
::
thread
::
id
>
host_threads
()
{
SmallVector
<
std
::
thread
::
id
>
host_threads
;
for
(
auto
&&
[
host
,
_
]
:
m_host_tid_table
)
{
host_threads
.
push_back
(
host
);
}
return
host_threads
;
}
SmallVector
<
CompNode
>
devices
()
{
SmallVector
<
CompNode
>
devices
;
for
(
auto
&&
[
device
,
_
]
:
m_device_tid_table
)
{
devices
.
push_back
(
device
);
}
return
devices
;
}
void
inc_counter
(
const
char
*
key
,
int64_t
delta
)
{
void
inc_counter
(
const
char
*
key
,
int64_t
delta
)
{
if
(
!
m_counter_table
.
count
(
key
))
{
if
(
!
m_counter_table
.
count
(
key
))
{
m_counter_table
[
key
]
=
0
;
m_counter_table
[
key
]
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录