diff --git a/projects/clr/hipamd/src/hip_event.cpp b/projects/clr/hipamd/src/hip_event.cpp index 8b533712c8..3a97124899 100644 --- a/projects/clr/hipamd/src/hip_event.cpp +++ b/projects/clr/hipamd/src/hip_event.cpp @@ -396,6 +396,13 @@ hipError_t hipEventRecord_common(hipEvent_t event, hipStream_t stream, unsigned hip::Event* e = reinterpret_cast(event); hip::Stream* s = reinterpret_cast(stream); hip::Stream* hip_stream = hip::getStream(stream); + if (hipStream_t lastCaptureStream = e->GetCaptureStream()) { + if (hip::isValid(lastCaptureStream)) { + if ((lastCaptureStream != nullptr) && (lastCaptureStream != hipStreamLegacy)) { + reinterpret_cast(e->GetCaptureStream())->EraseCaptureEvent(event); + } + } + } e->SetCaptureStream(stream); if ((stream != nullptr && stream != hipStreamLegacy) && (s->GetCaptureStatus() == hipStreamCaptureStatusActive)) {