Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions projects/clr/hipamd/src/hip_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ namespace hip {
}
/// Release graph when capture is invalidated
void ReleaseCaptureGraph();
/// Drop the capture-graph pointer without freeing it (forks alias the origin's graph).
void ClearCaptureGraph() { pCaptureGraph_ = nullptr; }
/// Generate and assign a new capture ID (used at BeginCapture)
void SetCaptureID() { captureID_ = GenerateCaptureID(); }
/// Inherit capture ID from the parent stream
Expand Down
9 changes: 7 additions & 2 deletions projects/clr/hipamd/src/hip_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@ void Stream::Detach() {
if (captureStatus_ == hipStreamCaptureStatusActive) {
captureStatus_ = hipStreamCaptureStatusInvalidated;
for (auto s : parallelCaptureStreams_) {
reinterpret_cast<hip::Stream*>(s)->SetCaptureStatus(
hipStreamCaptureStatusInvalidated);
auto* fork = reinterpret_cast<hip::Stream*>(s);
fork->SetCaptureStatus(hipStreamCaptureStatusInvalidated);
fork->ClearCaptureGraph(); // fork only aliases origin's graph; avoid double free
}
// EndCapture's cleanup is now unreachable (detached), so free the graph here.
if (originStream_) {
ReleaseCaptureGraph();
}
}
detached_.store(true, std::memory_order_release);
Expand Down
Loading