Skip to content

[rocjitsu][amdisa] Model s_buffer_atomic_* instructions - #14972

Merged
accauble merged 5 commits into
developfrom
users/accauble/rj-s-buffer-atomic
Nov 5, 2026
Merged

accauble merged 5 commits into
developfrom
users/accauble/rj-s-buffer-atomic

Conversation

@accauble

@accauble accauble commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

This models the s_buffer_atomic_* instructions (Issue #13025). The implementation is very similar to the s_atomic implementation except for how smem_calculate_address computes the address and an extra bounds check.

Requires a quick fix in PR #14922. I also found another possible bug with how the buffer memory accesses are checked for the debugger. That is scoped as a follow-up since it existed before this change. (PR #14995)

@github-actions github-actions Bot added documentation Improvements or additions to documentation project: rocjitsu labels Nov 3, 2026
@accauble
accauble force-pushed the users/accauble/rj-s-buffer-atomic branch from 6778aa9 to efdadd8 Compare November 3, 2026 21:41
@accauble
accauble marked this pull request as ready for review November 4, 2026 00:02
@accauble
accauble requested review from a team and atgutier as code owners November 4, 2026 00:02

@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.

It would help to describe load_dword_mask in terms of set and clear bits. At addr_calc_scalar.h:31–32 and mem_state.h:98–99, a set bit selects a DWORD for access. A clear bit makes a load return zero or skips a store. The scalar_buffer_address comment at addr_calc_scalar.h:44–52 could then explain the atomic case. An aligned element needs every DWORD in range, while a misaligned one keeps the full mask so it can fault. Parenthesizing the || condition at line 69 would make those two paths easier to spot.

@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.

Added some comments and an inline reply

@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.

Original anchor: emulation/rocjitsu/tests/scalar_atomic_test.cpp:725

Waitcnt now pins that buffer atomics consume the three V# words (ScalarBufferAtomicChecksItsConsumedDescriptorWords). InstDefUse still only sees the 64-bit s_atomic address here.

Buffer constructors emit a 128-bit sbase, the same shape smem_sbase_operand_test.cpp already pins for s_buffer_load_dwordx4 -> s[4:7]. That test exists because a scaled-SBASE miss once reached the probe-call planner. Looping buffer_atomic_opcode here with width 4, or adding one s_buffer_atomic_inc case there, would put liveness and spill on the same V# path as loads instead of leaving them with only the 64-bit address.

This is a small test addition, not a model change. Worth doing in this PR while the constructors are new, so a later consumer of InstDefUse does not have to rediscover that buffer atomics are a V#, not s[0:1].

@accauble
accauble requested a review from kuhar November 4, 2026 19:22

@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.

One comment, plus an inline reply

@accauble
accauble requested a review from kuhar November 5, 2026 13:16

@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

Base automatically changed from users/accauble/rj-cdna-s-buffer-load-bounds to develop November 5, 2026 17:03
@therock-pr-bot

therock-pr-bot Bot commented Nov 5, 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

therock-pr-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

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

* Very similar to `s_atomic` implementation except for how
  smem_calculate_address computes the address and an extra bounds
  check
* `s_buffer_atomics` get `modifiers.buffer_resource = &sbase` and
  `scalar_buffer_words = 3` like buffer loads.
* Prevent future additions to `s_buffer_atomic` from being parsed
  as something else
* Test change
* Comment clarifications
@accauble
accauble force-pushed the users/accauble/rj-s-buffer-atomic branch from 4039d70 to 8994908 Compare November 5, 2026 17:07
@accauble
accauble merged commit 8d93dea into develop Nov 5, 2026
71 checks passed
@accauble
accauble deleted the users/accauble/rj-s-buffer-atomic branch November 5, 2026 18:07
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

rocjitsu post-commit fuzz passed

The 32-worker multiplexer campaigns for commit 8d93deab161c completed without recording a crash or hang.

  • ASan+UBSan (6-minute): 580,720 input executions (1,649.11 inputs/s)
  • TSan (6-minute): 550,195 input executions (1,574.35 inputs/s)

View the workflow run.

accauble added a commit that referenced this pull request Nov 6, 2026
## Motivation

Found by @kuhar in PR #14972. `report_routed_access` in
`ComputeUnitCore` reported valid and requested lane masks as "1" even
when the whole operation was masked. This updates it to show that the
lane is "active" but not "valid."
@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

Labels

documentation Improvements or additions to documentation organization: ROCm project: rocjitsu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants