Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
ebe72b88
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ebe72b88
编写于
4月 08, 2022
作者:
Q
Qi Li
提交者:
GitHub
4月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Cherry-pick][ROCm] fix dcu error in device event base, test=develop (#41523)
Cherry-pick of #41521
上级
cb7551fd
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
54 addition
and
2 deletion
+54
-2
paddle/fluid/platform/device_event.h
paddle/fluid/platform/device_event.h
+1
-1
paddle/fluid/platform/device_event_gpu.cc
paddle/fluid/platform/device_event_gpu.cc
+1
-1
paddle/fluid/platform/device_event_test.cc
paddle/fluid/platform/device_event_test.cc
+52
-0
未找到文件。
paddle/fluid/platform/device_event.h
浏览文件 @
ebe72b88
...
@@ -29,7 +29,7 @@ using ::paddle::platform::kCPU;
...
@@ -29,7 +29,7 @@ using ::paddle::platform::kCPU;
USE_EVENT
(
kCPU
)
USE_EVENT
(
kCPU
)
USE_EVENT_WAIT
(
kCPU
,
kCPU
)
USE_EVENT_WAIT
(
kCPU
,
kCPU
)
#if
def PADDLE_WITH_CUDA
#if
defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
USE_EVENT
(
kCUDA
);
USE_EVENT
(
kCUDA
);
USE_EVENT_WAIT
(
kCUDA
,
kCUDA
)
USE_EVENT_WAIT
(
kCUDA
,
kCUDA
)
USE_EVENT_WAIT
(
kCPU
,
kCUDA
)
USE_EVENT_WAIT
(
kCPU
,
kCUDA
)
...
...
paddle/fluid/platform/device_event_gpu.cc
浏览文件 @
ebe72b88
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include "paddle/fluid/platform/device_event_base.h"
#include "paddle/fluid/platform/device_event_base.h"
#include "paddle/fluid/platform/event.h"
#include "paddle/fluid/platform/event.h"
#if
def PADDLE_WITH_CUDA
#if
defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
namespace
paddle
{
namespace
paddle
{
namespace
platform
{
namespace
platform
{
struct
CUDADeviceEventWrapper
{
struct
CUDADeviceEventWrapper
{
...
...
paddle/fluid/platform/device_event_test.cc
浏览文件 @
ebe72b88
...
@@ -75,6 +75,58 @@ TEST(DeviceEvent, CUDA) {
...
@@ -75,6 +75,58 @@ TEST(DeviceEvent, CUDA) {
}
}
#endif
#endif
#ifdef PADDLE_WITH_HIP
#include <hip/hip_runtime.h>
TEST
(
DeviceEvent
,
CUDA
)
{
VLOG
(
1
)
<<
"In Test"
;
using
paddle
::
platform
::
CUDAPlace
;
auto
&
pool
=
DeviceContextPool
::
Instance
();
auto
place
=
CUDAPlace
(
0
);
auto
*
context
=
static_cast
<
paddle
::
platform
::
CUDADeviceContext
*>
(
pool
.
Get
(
place
));
ASSERT_NE
(
context
,
nullptr
);
// case 1. test for event_creator
DeviceEvent
event
(
place
);
ASSERT_NE
(
event
.
GetEvent
().
get
(),
nullptr
);
bool
status
=
event
.
Query
();
ASSERT_EQ
(
status
,
true
);
// case 2. test for event_recorder
event
.
Record
(
context
);
status
=
event
.
Query
();
ASSERT_EQ
(
status
,
false
);
// case 3. test for event_finisher
event
.
Finish
();
status
=
event
.
Query
();
ASSERT_EQ
(
status
,
true
);
// case 4. test for event_waiter
float
*
src_fp32
,
*
dst_fp32
;
int
size
=
1000000
*
sizeof
(
float
);
hipMallocHost
(
reinterpret_cast
<
void
**>
(
&
src_fp32
),
size
);
hipMalloc
(
reinterpret_cast
<
void
**>
(
&
dst_fp32
),
size
);
hipMemcpyAsync
(
dst_fp32
,
src_fp32
,
size
,
hipMemcpyHostToDevice
,
context
->
stream
());
event
.
Record
(
context
);
// step 1. record it
status
=
event
.
Query
();
ASSERT_EQ
(
status
,
false
);
event
.
Wait
(
kCUDA
,
context
);
// step 2. add streamWaitEvent
status
=
event
.
Query
();
ASSERT_EQ
(
status
,
false
);
// async
event
.
Wait
(
kCPU
,
context
);
// step 3. EventSynchornize
status
=
event
.
Query
();
ASSERT_EQ
(
status
,
true
);
// sync
// release resource
hipFree
(
dst_fp32
);
hipFreeHost
(
src_fp32
);
}
#endif
TEST
(
DeviceEvent
,
CPU
)
{
TEST
(
DeviceEvent
,
CPU
)
{
using
paddle
::
platform
::
CPUPlace
;
using
paddle
::
platform
::
CPUPlace
;
auto
place
=
CPUPlace
();
auto
place
=
CPUPlace
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录