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

add cudaEvent destructor function (#34734)

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