File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ class MemEvent {
120120
121121class CudaEvent {
122122#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
123+
123124 public:
124125 CudaEvent () {
125126#ifdef PADDLE_WITH_HIP
@@ -129,15 +130,23 @@ class CudaEvent {
129130#endif
130131 }
131132
132- CudaEvent (unsigned int flags) : flags_(flags) {
133+ explicit CudaEvent (unsigned int flags) : flags_(flags) {
133134#ifdef PADDLE_WITH_HIP
134135 hipEventCreateWithFlags (&event_, flags_);
135136#else
136137 cudaEventCreateWithFlags (&event_, flags_);
137138#endif
138139 }
139140
140- void Record (paddle::platform::stream::CUDAStream& stream) {
141+ ~CudaEvent () {
142+ #ifdef PADDLE_WITH_HIP
143+ PADDLE_ENFORCE_CUDA_SUCCESS (hipEventDestroy (event_));
144+ #else
145+ PADDLE_ENFORCE_CUDA_SUCCESS (cudaEventDestroy (event_));
146+ #endif
147+ }
148+
149+ void Record (const paddle::platform::stream::CUDAStream& stream) {
141150#ifdef PADDLE_WITH_HIP
142151 PADDLE_ENFORCE_CUDA_SUCCESS (hipEventRecord (event_, stream.raw_stream ()));
143152#else
You can’t perform that action at this time.
0 commit comments