Repository navigation
Run staging copies on the per-thread stream - #234
Merged
Merged
Conversation
The staging copies for buffers that are staged through host memory (hipObjGet(), hipObjPut(), and hipObjBufSync()) now use hipStreamPerThread instead of the null stream, for both the copy and the event that tracks it. Work on the null stream waits for every other blocking stream on the device, so copies from different threads waited for each other. As a result, the copies no longer wait for GPU work that the application queued on streams it created. The documentation of hipObjGet(), hipObjPut(), and hipObjBufSync() in hipobj.h now says what GPU work has to finish before each call. Only comments change in the header. FakeHip records the streams that memcpyAsync() and eventRecord() are given, and a new staging test checks that both get hipStreamPerThread. AGENTS.md now says that the API in the public header needs permission to change, but its documentation comments don't. It also says which header changes need a changelog entry. Co-Authored-By: Claude <noreply@anthropic.com>
derobins
requested review from
akolliasAMD,
gaoikawa,
jordan-turbofish,
kurtmcmillan,
riley-dixon,
sbates130272 and
zbyrne
as code owners
October 15, 2026 20:09
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The completion guarantee must exclude timeout returns that can leave a copy accessing the buffer.
1 open finding
What changed in this PR
Moves host-staging copies to the calling thread’s stream, avoiding null-stream synchronization with unrelated GPU work.
Changes:
- Uses
hipStreamPerThreadfor staging copies and completion events. - Records and tests stream selection.
- Documents caller synchronization requirements and clarifies header-edit guidance.
| File | Description |
|---|---|
| test/unit/test-staging.cpp | Tests copy and event stream selection. |
| test/unit/fake-device.h | Adds recorded stream fields. |
| test/unit/fake-device.cpp | Captures copy and event streams. |
| src/hipobj.cpp | Switches staging operations to the per-thread stream. |
| include/hipobj.h | Documents GPU synchronization requirements; declarations unchanged. |
| CHANGELOG.md | Records the staging behavior change. |
| AGENTS.md | Clarifies API and documentation change policies. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Security scan found no critical or high findings on lines changed by this pull requestView the security scan run for complete reports. “New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta. |
When a staging copy doesn't finish within HIPOBJ_STAGE_TIMEOUT_MS, hipObjGet(), hipObjPut(), and hipObjBufSync() return hipObjInternalError and leave the copy running. The documentation of hipObjBufSync() said the copy had always finished when the call returned. It now says that's only true on success, and all three functions say that a timed-out copy can still write the buffer (GET), read it (PUT), or do either (hipObjBufSync()) after the call returns. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The staging copies for buffers that are staged through host memory (hipObjGet(), hipObjPut(), and hipObjBufSync()) now use hipStreamPerThread instead of the null stream, for both the copy and the event that tracks it. Work on the null stream waits for every other blocking stream on the device, so copies from different threads waited for each other. As a result, the copies no longer wait for GPU work that the application queued on streams it created.
The documentation of hipObjGet(), hipObjPut(), and hipObjBufSync() in hipobj.h now says what GPU work has to finish before each call. Only comments change in the header.
FakeHip records the streams that memcpyAsync() and eventRecord() are given, and a new staging test checks that both get hipStreamPerThread.
AGENTS.md now says that the API in the public header needs permission to change, but its documentation comments don't. It also says which header changes need a changelog entry.