未验证 提交 090c863a 编写于 作者: C chentianyu03 提交者: GitHub

add CuddEvent destructor function (#34610)

上级 09892118
......@@ -120,6 +120,7 @@ class MemEvent {
class CudaEvent {
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
public:
CudaEvent() {
#ifdef PADDLE_WITH_HIP
......@@ -129,7 +130,7 @@ class CudaEvent {
#endif
}
CudaEvent(unsigned int flags) : flags_(flags) {
explicit CudaEvent(unsigned int flags) : flags_(flags) {
#ifdef PADDLE_WITH_HIP
hipEventCreateWithFlags(&event_, flags_);
#else
......@@ -137,7 +138,15 @@ class CudaEvent {
#endif
}
void Record(paddle::platform::stream::CUDAStream& stream) {
~CudaEvent() {
#ifdef PADDLE_WITH_HIP
PADDLE_ENFORCE_CUDA_SUCCESS(hipEventDestroy(event_));
#else
PADDLE_ENFORCE_CUDA_SUCCESS(cudaEventDestroy(event_));
#endif
}
void Record(const paddle::platform::stream::CUDAStream& stream) {
#ifdef PADDLE_WITH_HIP
PADDLE_ENFORCE_CUDA_SUCCESS(hipEventRecord(event_, stream.raw_stream()));
#else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册