Skip to content

Conversation

@iassiour
Copy link
Contributor

@iassiour iassiour commented Nov 28, 2025

Motivation

This PR fixes the Unit_hipStreamBeginCaptureToGraph_CapturePartialInThreads test by ensuring that when an event is recorded on a new stream during graph capture, it is properly removed from the previous stream's capture event list.
Otherwise when the event is destroyed, it can lead to a dangled event reference in the original stream and cause a segfault.

Technical Details

Added logic to erase the event from the previous capture stream before setting a new capture stream
Prevents duplicate event tracking across multiple streams during graph capture operations.

Test Plan

Unit_hipStreamBeginCaptureToGraph_CapturePartialInThreads should pass

Test Result

Unit_hipStreamBeginCaptureToGraph_CapturePartialInThreads passes and does not show any warning in valgrind

Submission Checklist

Copilot AI review requested due to automatic review settings November 28, 2025 03:32
@iassiour iassiour requested a review from a team as a code owner November 28, 2025 03:32
Copilot finished reviewing on behalf of iassiour November 28, 2025 03:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the Unit_hipStreamBeginCaptureToGraph_CapturePartialInThreads test by ensuring that when an event is recorded on a new stream during graph capture, it is properly removed from the previous stream's capture event list.

Key Changes:

  • Added logic to erase the event from the previous capture stream before setting a new capture stream
  • Prevents duplicate event tracking across multiple streams during graph capture operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@iassiour iassiour force-pushed the users/iassiour/capturefix branch from b826a04 to fe3c8e6 Compare November 28, 2025 08:18
@iassiour iassiour changed the title Fix Unit_hipStreamBeginCaptureToGraph_CapturePartialInThreads SWDEV-569450 - Fix Unit_hipStreamBeginCaptureToGraph_CapturePartialInThreads Nov 28, 2025
@iassiour iassiour force-pushed the users/iassiour/capturefix branch 3 times, most recently from 6f35d03 to 73ac21e Compare December 1, 2025 14:34
if (hipStream_t lastCaptureStream = e->GetCaptureStream()) {
if (hip::isValid(lastCaptureStream)) {
if ((lastCaptureStream != nullptr) && (lastCaptureStream != hipStreamLegacy)) {
reinterpret_cast<hip::Stream*>(e->GetCaptureStream())->EraseCaptureEvent(event);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It Should get cleared during end capture.

Copy link
Contributor

@anugodavar anugodavar Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense if same event is used again to record during capture.

@iassiour iassiour force-pushed the users/iassiour/capturefix branch from 73ac21e to d392d8f Compare December 3, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants