Skip to content

fix(rocjitsu): Sign-extend the gfx1250 GLOBAL saddr VGPR offset - #10847

Merged
atgutier merged 1 commit into
developfrom
users/agutierr/gfx1250-signed-gvs-offset
Aug 29, 2026
Merged

atgutier merged 1 commit into
developfrom
users/agutierr/gfx1250-signed-gvs-offset

Conversation

@atgutier

Copy link
Copy Markdown
Contributor

The VGPR half of a GLOBAL saddr address is a signed 32-bit offset on gfx1250, where every earlier target zero-extends it. LLVM gates the difference on hasSignedGVSOffset, matching a sign extension rather than a zero extension and selecting the signed multiply-add for the scaled form, so it will place a negative value there whenever an access walks backwards from its base. The address calculation zero-extended it, which does not move an offset of -4 one dword below the base but 4 GiB above it. Nothing is mapped that far out, so in daemon mode the access fell through to the client-memory bridge, failed there, and the store was discarded -- the symptom is quietly missing data rather than a fault.

Widen the offset through int32_t, and apply the scale to the widened value so the multiply is signed too. A two-element torch.flip reproduces the original: the lane carrying the -4 stride lost its store and the destination kept the zero it was allocated with, while the lane at offset zero wrote correctly. A single element passes either way because its only offset is zero, which is why this survived until a reversed iteration order reached the simulator. The regression test stores a marker through a negative offset and checks that it lands below the base and that the base itself is untouched.

Closes #10757

Copilot AI lite review requested due to automatic review settings August 27, 2026 19:38
@atgutier
atgutier requested a review from a team as a code owner August 27, 2026 19:38
@therock-pr-bot

therock-pr-bot Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes incorrect address calculation for gfx1250 GLOBAL saddr operations by properly sign-extending the 32-bit VGPR offset (and applying any scaling using signed arithmetic), preventing negative strides from being interpreted as large positive offsets and silently dropping stores/loads in daemon mode.

Changes:

  • Update gfx1250 GLOBAL saddr address calculation to sign-extend the VGPR offset and multiply it with signed semantics.
  • Add a regression test that writes through a negative VGPR offset and verifies the marker lands below the base while the base remains unchanged.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
emulation/rocjitsu/lib/rocjitsu/src/rocjitsu/isa/arch/amdgpu/cdna5/addr_calc.cpp Sign-extend GLOBAL saddr VGPR offsets (and scale them in signed arithmetic) when forming per-lane addresses.
emulation/rocjitsu/tests/cdna5_dispatch_memory_test.cpp Add a regression test validating negative GLOBAL saddr VGPR offsets write below the base on gfx1250.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@atgutier
atgutier force-pushed the users/agutierr/gfx1250-signed-gvs-offset branch from 391037b to ac6cdef Compare August 27, 2026 20:10
@atgutier
atgutier requested a lite review from Copilot August 27, 2026 20:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

@atgutier
atgutier force-pushed the users/agutierr/gfx1250-signed-gvs-offset branch from ac6cdef to 0592323 Compare August 27, 2026 20:33

@kuhar kuhar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

The VGPR half of a GLOBAL saddr address is a signed 32-bit offset on gfx1250,
where every earlier target zero-extends it. LLVM gates the difference on
hasSignedGVSOffset, matching a sign extension rather than a zero extension and
selecting the signed multiply-add for the scaled form, so it will place a
negative value there whenever an access walks backwards from its base. The
address calculation zero-extended it, which does not move an offset of -4 one
dword below the base but 4 GiB above it. Nothing is mapped that far out, so in
daemon mode the access fell through to the client-memory bridge, failed there,
and the store was discarded -- the symptom is quietly missing data rather than
a fault.

Widen the offset through int32_t, and apply the scale to the widened value so
the multiply is signed too. A two-element torch.flip reproduces the original:
the lane carrying the -4 stride lost its store and the destination kept the
zero it was allocated with, while the lane at offset zero wrote correctly. A
single element passes either way because its only offset is zero, which is why
this survived until a reversed iteration order reached the simulator. The
regression test stores a marker through a negative offset and checks that it
lands below the base and that the base itself is untouched.

Closes #10757

Signed-off-by: Tony Gutierrez <anthony.gutierrez@amd.com>
@atgutier
atgutier force-pushed the users/agutierr/gfx1250-signed-gvs-offset branch from 0592323 to dbc6f33 Compare August 29, 2026 19:55
@atgutier
atgutier merged commit 1269ffb into develop Aug 29, 2026
44 of 47 checks passed
@atgutier
atgutier deleted the users/agutierr/gfx1250-signed-gvs-offset branch August 29, 2026 20:49
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

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.

[rocJITsu][gfx1250] Two-element torch.flip returns corrupt data with process_vm failures

3 participants