Skip to content

[rocjitsu] DBI: Introduce mask policy for probes and pass EXEC as an argument - #11514

Merged
accauble merged 7 commits into
developfrom
users/accauble/rj-dbi-mask-policy
Sep 17, 2026
Merged

accauble merged 7 commits into
developfrom
users/accauble/rj-dbi-mask-policy

Conversation

@accauble

@accauble accauble commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

This PR has two related parts:

  1. Pass the value of EXEC to a probe (will be required for tools like a weighted flops counter or a data-race detector)
  2. Set whether the probe executes with that value of EXEC (some tools may want to run under that value, some tools will be okay running under a full mask)

Note: This requires PR #11332, which starts to pass arguments to probes.

Technical Details

  • Set a mask policy. At instrumentation points, allow force_full_exec (was there but not supported). The trampoline uses this information to decide whether to restore EXEC back to the anchor value before calling the probe (it gets set to -1 for spilling and setting arguments)
  • Since EXEC gets set to -1 for setting arguments, the value has to come from the temporary register holding the value of EXEC. The trampoline already required a temporary dead register to hold the value. Improving upon this is possible, but not in scope for this PR.
  • Updated ProbeKey to only have symbol and object. There should not be multiple copies of a probe. If the sources are so different that they require a different copy, then it should really be a different probe.
  • Updated the probe to have argument type (immediate or exec for now) and the mask policy. Although the mask policy is really consumed at the instrumentation point, mentally, this is a probe policy.

Issue Tracking

Issue #8879

Test Plan

  • Added unit tests.
  • Added simulation tests to verify that the probe can run masked or not
  • Added simulation tests to verify that the probe receives the value of EXEC (both 32-bit and 64-bit)

Note: This does not include tests for real hardware. These will be added when we can pass data to the host from the probe.

Test Result

Tests pass!

Submission Checklist

@accauble
accauble requested a review from bjacob September 11, 2026 16:15
@github-actions github-actions Bot added documentation Improvements or additions to documentation project: rocjitsu labels Sep 11, 2026
@accauble accauble mentioned this pull request Sep 11, 2026
9 of 55 tasks
@accauble
accauble marked this pull request as ready for review September 11, 2026 17:52
@accauble
accauble requested review from a team and atgutier as code owners September 11, 2026 17:52

@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 be good to update the stale policy documentation in this patch so it matches the implementation:

  • emulation/rocjitsu/lib/rocjitsu/src/rocjitsu/code/patch/instrumentor.h:30 still lists EXEC policy as future work, and instrumentor.h:218-225 still calls fields reserved and says force_full_exec must be false.
  • emulation/rocjitsu/lib/rocjitsu/src/rocjitsu/code/patch/trampoline_builder.h:103-105 says an EXEC-sourced argument uniquely forces the EXEC temp, although any argument opens the full-mask window, and line 111 says one toggle instead of the emitted two.
  • emulation/rocjitsu/docs/dbi-design.md:80, :376, and :394 still describe immediate-only arguments and a count-only deduplication key.

These are public contract/design comments, so aligning them here would prevent callers from following the previous milestone rules.

@accauble
accauble requested a review from kuhar September 14, 2026 18:22
@accauble

Copy link
Copy Markdown
Contributor Author

Made those suggested changes and updated the stale documentation

An error occurred while trying to automatically change base from users/accauble/rj-dbi-probe-args to users/accauble/rj-dbi-probe-abi September 16, 2026 12:25
An error occurred while trying to automatically change base from users/accauble/rj-dbi-probe-args to users/accauble/rj-dbi-probe-abi September 16, 2026 12:49
@accauble
accauble marked this pull request as draft September 16, 2026 12:50
@accauble
accauble changed the base branch from users/accauble/rj-dbi-probe-args to develop September 16, 2026 12:50
@accauble
accauble force-pushed the users/accauble/rj-dbi-mask-policy branch from 4abe3ac to ce449b0 Compare September 16, 2026 12:51
@therock-pr-bot

therock-pr-bot Bot commented Sep 16, 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.

@accauble
accauble marked this pull request as ready for review September 16, 2026 12:55

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

We should finish aligning the public documentation with the current probe contract. A few references still describe the previous behavior:

  • emulation/rocjitsu/docs/dbi-design.md:74 says body reuse is keyed by (probe_obj, probe_symbol, argument count), but it is now keyed by object and symbol, with conflicting arity, source, or mask declarations rejected.
  • emulation/rocjitsu/docs/dbi-design.md:193 and :415 list only build_v_mov_b32_imm, although this patch adds and tests build_v_mov_b32_src.
  • emulation/rocjitsu/lib/rocjitsu/src/rocjitsu/code/patch/instrumentor.h:218-224 documents the force_full_exec-without-probe check but omits the matching probe_args rule.

Updating these remaining references together would give callers one consistent contract.

@accauble

Copy link
Copy Markdown
Contributor Author

finish aligning the public documentation

Ugh. I need to work on my prompting; my agents clearly have tunnel vision. Thanks for finding these. They are fixed.

@accauble
accauble requested a review from kuhar September 16, 2026 18:58
* Update ProbeKey to carry source of the argument
* Added exec_lo and exec_hi as possible sources
* Mask is read from saved EXEC value not from EXEC (which is -1
  at the arg passing point in the envelope anyway)
* Currently requires planner to reserve a temp register (it
  already needed to do this to save EXEC and we can get
  fancier later)
* Rejects exec_hi for wave32 kernels
* Allow force_full_exec (except for inline nop)
* Skip anchor mask restore if set and reset EXEC after
* Set at instrumentation site, but ProbeKey has the policy too
* Updated stale documentation
* Use exhaustive switch for argument types with a runtime
  rejection to catch undefined argument types
* Change probe key to use just name and symbol. At this point,
  there is no good reason to hold multiple copies of the same
  probe...the argument sources should not change and the EXEC
  policy definitely should not change. If these should change,
  then the probe should actually be different.
* Added more tests

@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 be good to update emulation/rocjitsu/lib/rocjitsu/src/rocjitsu/code/patch/instrumentor.h:245 to name the actual remaining restriction. force_full_exec and probe_args are now consumed, so saying validate_anchor() rejects reserved InstrumentationPoint fields is stale; only non-zero filter_flags remains reserved.

LGTM

@accauble
accauble force-pushed the users/accauble/rj-dbi-mask-policy branch from f274c61 to 1d537db Compare September 17, 2026 12:20
@accauble
accauble merged commit 4b7c921 into develop Sep 17, 2026
32 checks passed
@accauble
accauble deleted the users/accauble/rj-dbi-mask-policy branch September 17, 2026 15:50
@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