Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
5a0a4617
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5a0a4617
编写于
1月 05, 2018
作者:
Y
Yibing Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make time calc funcs return ms instead of us
上级
d7e56847
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
13 deletion
+12
-13
paddle/platform/profiler.cc
paddle/platform/profiler.cc
+6
-7
paddle/platform/profiler.h
paddle/platform/profiler.h
+2
-2
paddle/platform/profiler_test.cc
paddle/platform/profiler_test.cc
+4
-4
未找到文件。
paddle/platform/profiler.cc
浏览文件 @
5a0a4617
...
@@ -74,11 +74,11 @@ std::string Event::kind() const {
...
@@ -74,11 +74,11 @@ std::string Event::kind() const {
PADDLE_THROW
(
"Unknown EventKind."
);
PADDLE_THROW
(
"Unknown EventKind."
);
}
}
double
Event
::
CpuElapsed
U
s
(
const
Event
&
e
)
const
{
double
Event
::
CpuElapsed
M
s
(
const
Event
&
e
)
const
{
return
(
e
.
cpu_ns_
-
cpu_ns_
)
/
(
1000.0
);
return
(
e
.
cpu_ns_
-
cpu_ns_
)
/
(
1000
000
.0
);
}
}
double
Event
::
CudaElapsed
U
s
(
const
Event
&
e
)
const
{
double
Event
::
CudaElapsed
M
s
(
const
Event
&
e
)
const
{
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
PADDLE_ENFORCE
(
e
.
has_cuda
()
&&
has_cuda
());
PADDLE_ENFORCE
(
e
.
has_cuda
()
&&
has_cuda
());
PADDLE_ENFORCE
(
e
.
device
()
==
device
());
PADDLE_ENFORCE
(
e
.
device
()
==
device
());
...
@@ -86,7 +86,7 @@ double Event::CudaElapsedUs(const Event& e) const {
...
@@ -86,7 +86,7 @@ double Event::CudaElapsedUs(const Event& e) const {
PADDLE_ENFORCE
(
cudaEventSynchronize
(
e
.
event
()));
PADDLE_ENFORCE
(
cudaEventSynchronize
(
e
.
event
()));
float
ms
;
float
ms
;
PADDLE_ENFORCE
(
cudaEventElapsedTime
(
&
ms
,
event_
,
e
.
event
()));
PADDLE_ENFORCE
(
cudaEventElapsedTime
(
&
ms
,
event_
,
e
.
event
()));
return
ms
*
1000.0
;
return
ms
;
#else
#else
PADDLE_THROW
(
"CUDA is not enabled"
);
PADDLE_THROW
(
"CUDA is not enabled"
);
#endif
#endif
...
@@ -239,11 +239,10 @@ void ParseEvents(std::vector<std::vector<Event>>& events,
...
@@ -239,11 +239,10 @@ void ParseEvents(std::vector<std::vector<Event>>& events,
++
rit
;
++
rit
;
}
}
if
(
rit
!=
pushed_events
.
rend
())
{
if
(
rit
!=
pushed_events
.
rend
())
{
// get event time in ms
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
double
event_time
=
rit
->
CudaElapsed
Us
(
events
[
i
][
j
])
/
1000.0
;
double
event_time
=
rit
->
CudaElapsed
Ms
(
events
[
i
][
j
])
;
#else
#else
double
event_time
=
rit
->
CpuElapsed
Us
(
events
[
i
][
j
])
/
1000.0
;
double
event_time
=
rit
->
CpuElapsed
Ms
(
events
[
i
][
j
])
;
#endif
#endif
std
::
string
event_name
=
std
::
string
event_name
=
"thread"
+
std
::
to_string
(
rit
->
thread_id
())
+
"::"
+
rit
->
name
();
"thread"
+
std
::
to_string
(
rit
->
thread_id
())
+
"::"
+
rit
->
name
();
...
...
paddle/platform/profiler.h
浏览文件 @
5a0a4617
...
@@ -41,8 +41,8 @@ class Event {
...
@@ -41,8 +41,8 @@ class Event {
int
device
()
const
{
return
device_
;
}
int
device
()
const
{
return
device_
;
}
#endif
#endif
double
CpuElapsed
U
s
(
const
Event
&
e
)
const
;
double
CpuElapsed
M
s
(
const
Event
&
e
)
const
;
double
CudaElapsed
U
s
(
const
Event
&
e
)
const
;
double
CudaElapsed
M
s
(
const
Event
&
e
)
const
;
private:
private:
EventKind
kind_
;
EventKind
kind_
;
...
...
paddle/platform/profiler_test.cc
浏览文件 @
5a0a4617
...
@@ -26,7 +26,7 @@ TEST(Event, CpuElapsedTime) {
...
@@ -26,7 +26,7 @@ TEST(Event, CpuElapsedTime) {
counter
++
;
counter
++
;
}
}
Event
stop_event
(
EventKind
::
kPopRange
,
"test"
,
0
,
nullptr
);
Event
stop_event
(
EventKind
::
kPopRange
,
"test"
,
0
,
nullptr
);
EXPECT_GT
(
start_event
.
CpuElapsed
U
s
(
stop_event
),
0
);
EXPECT_GT
(
start_event
.
CpuElapsed
M
s
(
stop_event
),
0
);
}
}
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
...
@@ -45,7 +45,7 @@ TEST(Event, CudaElapsedTime) {
...
@@ -45,7 +45,7 @@ TEST(Event, CudaElapsedTime) {
counter
++
;
counter
++
;
}
}
Event
stop_event
(
EventKind
::
kPopRange
,
"test"
,
0
,
dev_ctx
);
Event
stop_event
(
EventKind
::
kPopRange
,
"test"
,
0
,
dev_ctx
);
EXPECT_GT
(
start_event
.
CudaElapsed
U
s
(
stop_event
),
0
);
EXPECT_GT
(
start_event
.
CudaElapsed
M
s
(
stop_event
),
0
);
}
}
#endif
#endif
...
@@ -114,9 +114,9 @@ TEST(RecordEvent, RecordEvent) {
...
@@ -114,9 +114,9 @@ TEST(RecordEvent, RecordEvent) {
if
(
events
[
i
][
j
].
name
()
==
"push"
)
{
if
(
events
[
i
][
j
].
name
()
==
"push"
)
{
EXPECT_EQ
(
events
[
i
][
j
+
1
].
name
(),
"pop"
);
EXPECT_EQ
(
events
[
i
][
j
+
1
].
name
(),
"pop"
);
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
EXPECT_GT
(
events
[
i
][
j
].
CudaElapsed
U
s
(
events
[
i
][
j
+
1
]),
0
);
EXPECT_GT
(
events
[
i
][
j
].
CudaElapsed
M
s
(
events
[
i
][
j
+
1
]),
0
);
#else
#else
EXPECT_GT
(
events
[
i
][
j
].
CpuElapsed
U
s
(
events
[
i
][
j
+
1
]),
0
);
EXPECT_GT
(
events
[
i
][
j
].
CpuElapsed
M
s
(
events
[
i
][
j
+
1
]),
0
);
#endif
#endif
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录