Skip to content

Commit d0a148a

Browse files
authored
[SYCL][CUDA] Cleanup of profiling events (#1956)
Additional CUDA events created for profiling are now released upon destruction of the PI Event. Signed-off-by: Ruyman Reyes <[email protected]>
1 parent 9c0dc7f commit d0a148a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,18 @@ pi_result _pi_event::wait() {
405405
return retErr;
406406
}
407407

408+
pi_result _pi_event::release() {
409+
assert(queue_ != nullptr);
410+
PI_CHECK_ERROR(cuEventDestroy(evEnd_));
411+
412+
if (queue_->properties_ & PI_QUEUE_PROFILING_ENABLE) {
413+
PI_CHECK_ERROR(cuEventDestroy(evQueued_));
414+
PI_CHECK_ERROR(cuEventDestroy(evStart_));
415+
}
416+
417+
return PI_SUCCESS;
418+
}
419+
408420
// makes all future work submitted to queue wait for all work captured in event.
409421
pi_result enqueueEventWait(pi_queue queue, pi_event event) {
410422
// for native events, the cuStreamWaitEvent call is used.
@@ -2889,8 +2901,7 @@ pi_result cuda_piEventRelease(pi_event event) {
28892901
pi_result result = PI_INVALID_EVENT;
28902902
try {
28912903
ScopedContext active(event->get_context());
2892-
auto cuEvent = event->get();
2893-
result = PI_CHECK_ERROR(cuEventDestroy(cuEvent));
2904+
result = event->release();
28942905
} catch (...) {
28952906
result = PI_OUT_OF_RESOURCES;
28962907
}

sycl/plugins/cuda/pi_cuda.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ class _pi_event {
374374
return new _pi_event(type, queue->get_context(), queue);
375375
}
376376

377+
pi_result release();
378+
377379
~_pi_event();
378380

379381
private:

0 commit comments

Comments
 (0)