Skip to content

Add support for enabling/querying local memory exceptions.#105

Draft
oogunbow-amd wants to merge 4 commits into
amd-stagingfrom
users/oogunbow/lds_reporting
Draft

Add support for enabling/querying local memory exceptions.#105
oogunbow-amd wants to merge 4 commits into
amd-stagingfrom
users/oogunbow/lds_reporting

Conversation

@oogunbow-amd

@oogunbow-amd oogunbow-amd commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Add support for enabling/querying local memory exception reporting.

This feature allows users to detect out‑of‑address-range accesses
to local memory (LDS) during debugging sessions on AMD GPU devices
that support it (gfx12 and later).

When enabled, the GPU hardware will report an exception when a wave
attempts to access local memory beyond the allocated range, making
it easier to detect and debug invalid LDS accesses. The setting is
per-inferior and controlled via:

  • set amdgpu lds-addr-range-exception [on|off]
  • show amdgpu lds-addr-range-exception

Usage example:

(gdb) set amdgpu lds-addr-range-exception on
(gdb) run
...
Thread 2.1 "kern" received signal SIGBUS, Bus error.
[Switching to AMDGPU Wave 1:2:1:1 (0,0,0)/0]
kern (dyn_alloc=64, lds_size=65536) at test.cpp:43
43 arr[idx] = 8; /* Out-of-range access */

In this example, the kernel allocated 64 bytes of shared memory but
attempts to access arr[65532], which is beyond the allocated range.
With the feature enabled, GDB catches this as a SIGBUS instead of
the access silently failing or causing undefined behavior.

By default, the feature is off to maintain backward compatibility.
If enabled but not supported by the GPU architecture, a warning is
displayed.

Changes:

  • Updated target data structures and attach/detach logic
  • Updated clone/fork handling to propagate the new setting
  • Adjusted build configuration to require amd‑dbgapi ≥ 0.81.0

Co-Authored-By: Kondratiev Alexey [email protected]

@oogunbow-amd oogunbow-amd requested a review from a team as a code owner April 29, 2026 13:12
@oogunbow-amd oogunbow-amd self-assigned this Apr 29, 2026

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

The commit message says set/show lds-out-of-addr-range-exceptions, so I was going to say this setting should probably be under set/show amdgpu, but that's what the code actually does. So I think the commit message should be updated to reflect that.

Comment thread CHANGELOG_AMD.md Outdated
Comment thread gdb/amd-dbgapi-target.c Outdated
Comment thread gdb/amd-dbgapi-target.c Outdated
Comment thread gdb/amd-dbgapi-target.c
Comment thread gdb/amd-dbgapi-target.c Outdated
Comment thread gdb/testsuite/gdb.rocm/lds-addr-range-exception.exp Outdated
Comment thread gdb/testsuite/gdb.rocm/lds-addr-range-exception.cpp Outdated
Comment thread gdb/testsuite/gdb.rocm/lds-addr-range-exception.cpp Outdated
Comment thread gdb/testsuite/gdb.rocm/lds-addr-range-exception.cpp Outdated
Comment thread gdb/testsuite/gdb.rocm/lds-addr-range-exception.exp Outdated
Comment thread gdb/testsuite/gdb.rocm/branch-fault.exp Outdated
Comment thread gdb/amd-dbgapi-target.c
Comment thread gdb/amd-dbgapi-target.c Outdated
@palves

palves commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Please drop period from commit log.

@akondrat-amd akondrat-amd force-pushed the users/oogunbow/lds_reporting branch from 60c4db1 to 5e882e9 Compare June 4, 2026 20:51
@akondrat-amd

Copy link
Copy Markdown
Contributor

I've added last untested commit [f2deb49] on Olu's request, will test at the earliest opportunity.

@oogunbow-amd oogunbow-amd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed-up all pending reviews

@lumachad

lumachad commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

This needs a rebase on top of current rocm-systems develop branch, and then a force-push so we run CI.

@oogunbow-amd oogunbow-amd force-pushed the users/oogunbow/lds_reporting branch from db2504e to 2867577 Compare July 1, 2026 22:11
@oogunbow-amd oogunbow-amd requested a review from akondrat-amd July 1, 2026 22:20
@oogunbow-amd oogunbow-amd force-pushed the users/oogunbow/lds_reporting branch from 2867577 to a4d35a3 Compare July 1, 2026 22:24
This feature allows users to detect out‑of‑address-range accesses
to local memory (LDS) during debugging sessions on AMD GPU devices
that support it (gfx12 and later).

When enabled, the GPU hardware will report an exception when a wave
attempts to access local memory beyond the allocated range, making
it easier to detect and debug invalid LDS accesses. The setting is
per-inferior and controlled via:
  - set amdgpu lds-addr-range-exception [on|off]
  - show amdgpu lds-addr-range-exception

Usage example:

 (gdb) set amdgpu lds-addr-range-exception on
 (gdb) run
 ...
 Thread 2.1 "kern" received signal SIGBUS, Bus error.
 [Switching to AMDGPU Wave 1:2:1:1 (0,0,0)/0]
 kern (dyn_alloc=64, lds_size=65536) at test.cpp:43
 43        arr[idx] = 8;  /* Out-of-range access */

In this example, the kernel allocated 64 bytes of shared memory but
attempts to access arr[65532], which is beyond the allocated range.
With the feature enabled, GDB catches this as a SIGBUS instead of
the access silently failing or causing undefined behavior.

By default, the feature is off to maintain backward compatibility.
If enabled but not supported by the GPU architecture, a warning is
displayed.

Changes:
- Updated target data structures and attach/detach logic
- Updated clone/fork handling to propagate the new setting
- Adjusted build configuration to require amd‑dbgapi ≥ 0.81.0

Co-Authored-By: Kondratiev Alexey <[email protected]>
@oogunbow-amd oogunbow-amd force-pushed the users/oogunbow/lds_reporting branch from a4d35a3 to c9d1ee5 Compare July 1, 2026 23:51
@lumachad

lumachad commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Still running into...
[rocgdb] configure: error: amd-dbgapi is required, but cannot find an appropriate version: Package dependency requirement 'amd-dbgapi >= 0.81.0' could not be satisfied.

@akondrat-amd

Copy link
Copy Markdown
Contributor

Still running into... [rocgdb] configure: error: amd-dbgapi is required, but cannot find an appropriate version: Package dependency requirement 'amd-dbgapi >= 0.81.0' could not be satisfied.

You need to build it with this branch ROCm/rocm-systems#5536, it bumps amd-dbgapi to version 0.81.0

@akondrat-amd

Copy link
Copy Markdown
Contributor

The test is finished, the CI job should be failing on gfx94X until this PR is merged ROCm/rocm-systems#8382

@lumachad

Copy link
Copy Markdown
Collaborator

Still running into... [rocgdb] configure: error: amd-dbgapi is required, but cannot find an appropriate version: Package dependency requirement 'amd-dbgapi >= 0.81.0' could not be satisfied.

You need to build it with this branch ROCm/rocm-systems#5536, it bumps amd-dbgapi to version 0.81.0

If that's a requirement for this PR, then we need to sequence things correctly and wait for rocm-systems to pick up the change, then bump rocm-systems in TheRock. Until then, this should probably be a draft and ci:skip.

@lumachad lumachad marked this pull request as draft July 12, 2026 21:13
@lumachad lumachad added the ci:skip Skip all pre-commit / CI jobs while the label is up label Jul 12, 2026
@lumachad

Copy link
Copy Markdown
Collaborator

Please lift ci:skip once we have all the pre-requisite changes in rocm-systems/TheRock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:skip Skip all pre-commit / CI jobs while the label is up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants