Skip to content

fix(rocr): use runtime XNACK state for SVM_ACCESSIBLE_BY_DEFAULT query - #12558

Merged
kjayapra-amd merged 1 commit into
developfrom
users/kjayapra/rocrxnackbug
Oct 13, 2026
Merged

kjayapra-amd merged 1 commit into
developfrom
users/kjayapra/rocrxnackbug

Conversation

@kjayapra-amd

@kjayapra-amd kjayapra-amd commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

On gfx1250, hipMemPrefetchAsync on pageable host memory always returns hipErrorNotSupported even when XNACK is enabled at runtime via HSA_XNACK=1 and the KFD kernel driver accepts the mode change.

Technical Details

HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT was checking the static ISA registry feature flag (GetXnack()) which is hardcoded as IsaFeature::Unsupported for gfx1250, instead of querying the actual runtime XNACK state negotiated with KFD during initialization.

This caused a disconnect where:

  • KFD accepts XNACK=1 (hsaKmtSetXNACKMode succeeds)
  • rocminfo reports XNACK enabled: YES
  • But SVM_ACCESSIBLE_BY_DEFAULT returns false
  • CLR sets hmmCpuMemoryAccessible_=0
  • hipMemPrefetchAsync on pageable memory returns hipErrorNotSupported

Issue Tracking

ROCM-30999

Test Plan

Verified on gfx1250 (MI450):

  • HSA_XNACK=1: SVM_ACCESSIBLE_BY_DEFAULT now returns true
  • No HSA_XNACK: SVM_ACCESSIBLE_BY_DEFAULT correctly returns false
  • hipMemPrefetchAsync on pageable std::vector memory succeeds with HSA_XNACK=1
  • hipMemPrefetchAsync correctly returns hipErrorNotSupported without HSA_XNACK

Test Result

Verified on gfx1250

Submission Checklist

@therock-pr-bot

therock-pr-bot Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

❌ PR Check — Action Required

Check Status Details
📝 PR Description ❌ Fail Error: PR description must reference a JIRA ID, ISSUE ID, or a GitHub closing keyword.
Expected: include a JIRA ID / ISSUE ID line (separator : or -, or omitted; value may be a JIRA key, a number with/without #, or a link), OR a closing keyword + issue reference. Accepted examples:
• JIRA ID : TESTAUTO-6039
• JIRA ID - #330
• JIRA ID #330
• JIRA ID (on separate line)
ROCM-25757
• ISSUE ID : TESTUTO-3334
• ISSUE ID #3334
• ISSUE ID - TESTAUTO-3433
• ISSUE ID (on separate line)
AIRUNTIME-2352
• ISSUE ID : https://github.com/<org_name>/<repo_name>/issues/1234
• Closes #10
• Fixes octo-org/octo-repo#100
• Resolves: #123
• #123
• https://github.com/<org_name>/<repo_name>/issues/123
Current: no valid JIRA/ISSUE/closing-keyword reference found
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/clr/hipamd/src/hip_hmm.cpp, projects/hip-tests/catch/unit/memory/hipMemPrefetchBatchAsync.cc, projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp; no test file found
🔎 pre-commit ⏳ Pending ⏳ Still running…
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

⚠️ 1 policy check(s) failed. Please address the issues above before this PR can be Reviewed.

🚫 Please fix the failed policies

  • ❌ PR Description

The Not ready to Review label was added to this PR. Once all policies pass, the label is removed automatically.

📖 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

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Description

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

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

🤖 AI-assisted pre-review (for @cfreeamd)

projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp looks correct. dayatsin-amd has approved.

@kjayapra-amd
kjayapra-amd force-pushed the users/kjayapra/rocrxnackbug branch from 99d1725 to 2fcbd6f Compare October 9, 2026 18:25
@kjayapra-amd
kjayapra-amd marked this pull request as ready for review October 9, 2026 18:27
On gfx1250, hipMemPrefetchAsync on pageable host memory always returns
hipErrorNotSupported even when XNACK is enabled at runtime via
HSA_XNACK=1 and the KFD kernel driver accepts the mode change.

HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT was checking the static
ISA registry feature flag (GetXnack()) which is hardcoded as
IsaFeature::Unsupported for gfx1250, instead of querying the actual
runtime XNACK state negotiated with KFD during initialization.

This caused a disconnect where:
- KFD accepts XNACK=1 (hsaKmtSetXNACKMode succeeds)
- rocminfo reports XNACK enabled: YES
- But SVM_ACCESSIBLE_BY_DEFAULT returns false
- CLR sets hmmCpuMemoryAccessible_=0
- hipMemPrefetchAsync on pageable memory returns hipErrorNotSupported

Replace the static ISA feature loop with a query to
Runtime::XnackEnabled(), which already holds the actual XNACK state
set by BindXnackMode() at init time. This is consistent with how
HSA_AMD_SYSTEM_INFO_XNACK_ENABLED already uses XnackEnabled().

Verified on gfx1250 (MI450):
- HSA_XNACK=1: SVM_ACCESSIBLE_BY_DEFAULT now returns true
- No HSA_XNACK: SVM_ACCESSIBLE_BY_DEFAULT correctly returns false
- hipMemPrefetchAsync on pageable std::vector memory succeeds with
  HSA_XNACK=1
- hipMemPrefetchAsync correctly returns hipErrorNotSupported without
  HSA_XNACK

Co-Authored-By: Claude <noreply@anthropic.com>
@kjayapra-amd
kjayapra-amd force-pushed the users/kjayapra/rocrxnackbug branch from 2fcbd6f to a09a0ec Compare October 10, 2026 11:10
@kjayapra-amd
kjayapra-amd requested a review from a team as a code owner October 10, 2026 11:10
@kjayapra-amd
kjayapra-amd merged commit ae6a9a2 into develop Oct 13, 2026
615 of 626 checks passed
@kjayapra-amd
kjayapra-amd deleted the users/kjayapra/rocrxnackbug branch October 13, 2026 14:22
systems-assistant Bot pushed a commit to ROCm/clr that referenced this pull request Oct 13, 2026
 SVM_ACCESSIBLE_BY_DEFAULT query (#12558)

## Motivation

On gfx1250, hipMemPrefetchAsync on pageable host memory always returns
hipErrorNotSupported even when XNACK is enabled at runtime via
HSA_XNACK=1 and the KFD kernel driver accepts the mode change.

## Technical Details

HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT was checking the static
ISA registry feature flag (GetXnack()) which is hardcoded as
IsaFeature::Unsupported for gfx1250, instead of querying the actual
runtime XNACK state negotiated with KFD during initialization.

This caused a disconnect where:
- KFD accepts XNACK=1 (hsaKmtSetXNACKMode succeeds)
- rocminfo reports XNACK enabled: YES
- But SVM_ACCESSIBLE_BY_DEFAULT returns false
- CLR sets hmmCpuMemoryAccessible_=0
- hipMemPrefetchAsync on pageable memory returns hipErrorNotSupported

## Issue Tracking

ROCM-30999

## Test Plan

Verified on gfx1250 (MI450):
- HSA_XNACK=1: SVM_ACCESSIBLE_BY_DEFAULT now returns true
- No HSA_XNACK: SVM_ACCESSIBLE_BY_DEFAULT correctly returns false
- hipMemPrefetchAsync on pageable std::vector memory succeeds with
HSA_XNACK=1
- hipMemPrefetchAsync correctly returns hipErrorNotSupported without
HSA_XNACK

## Test Result

Verified on gfx1250

## Submission Checklist

- [X ] Look over the contributing guidelines at
https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.

Co-authored-by: Karthik Jayaprakash <kjayapra@amd.com>
Co-authored-by: Claude <noreply@anthropic.com>
[rocm-systems] ROCm/rocm-systems#12558 (commit ae6a9a2)
systems-assistant Bot pushed a commit to ROCm/hip-tests that referenced this pull request Oct 13, 2026
 SVM_ACCESSIBLE_BY_DEFAULT query (#12558)

## Motivation

On gfx1250, hipMemPrefetchAsync on pageable host memory always returns
hipErrorNotSupported even when XNACK is enabled at runtime via
HSA_XNACK=1 and the KFD kernel driver accepts the mode change.

## Technical Details

HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT was checking the static
ISA registry feature flag (GetXnack()) which is hardcoded as
IsaFeature::Unsupported for gfx1250, instead of querying the actual
runtime XNACK state negotiated with KFD during initialization.

This caused a disconnect where:
- KFD accepts XNACK=1 (hsaKmtSetXNACKMode succeeds)
- rocminfo reports XNACK enabled: YES
- But SVM_ACCESSIBLE_BY_DEFAULT returns false
- CLR sets hmmCpuMemoryAccessible_=0
- hipMemPrefetchAsync on pageable memory returns hipErrorNotSupported

## Issue Tracking

ROCM-30999

## Test Plan

Verified on gfx1250 (MI450):
- HSA_XNACK=1: SVM_ACCESSIBLE_BY_DEFAULT now returns true
- No HSA_XNACK: SVM_ACCESSIBLE_BY_DEFAULT correctly returns false
- hipMemPrefetchAsync on pageable std::vector memory succeeds with
HSA_XNACK=1
- hipMemPrefetchAsync correctly returns hipErrorNotSupported without
HSA_XNACK

## Test Result

Verified on gfx1250

## Submission Checklist

- [X ] Look over the contributing guidelines at
https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.

Co-authored-by: Karthik Jayaprakash <kjayapra@amd.com>
Co-authored-by: Claude <noreply@anthropic.com>
[rocm-systems] ROCm/rocm-systems#12558 (commit ae6a9a2)
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

litvaOo pushed a commit that referenced this pull request Oct 21, 2026
#13430)

## Motivation

`HipTest::isXnackOn()` and five tests detect XNACK by searching
`gcnArchName` for `xnack+`. GPUs whose ISA has no XNACK on/off target
feature (e.g. gfx1250) never report `xnack+`, so these tests always skip
there, even with `HSA_XNACK=1`.

## Technical Details

- `isXnackOn()` now returns `hipDeviceAttributePageableMemoryAccess`.
Since #12558 this reflects the process XNACK mode on every GPU, and it
is the capability these tests actually need (GPU access to
`malloc`/`mmap` memory).
- The five tests that duplicated the `gcnArchName` check now call
`isXnackOn()`:
  - `hipMemCoherencyTstMProc.cc`
  - `hipHmmOvrSubscriptionTst.cc`
  - `hipHostRegisterStress.cc`
  - `hipMemAdvise_old.cc`
  - `hipGetProcAddressVmmApis.cc`
- On NVIDIA `isXnackOn()` returns false; the NVIDIA backend never fills
`gcnArchName`, so the old check could not match there either.

## Issue Tracking

JIRA ID: AIRUNTIME-2926

## Test Plan

MI350X (gfx950), ROCr/CLR built from develop `ae6a9a29dd`. Ran all
`isXnackOn()`-gated tests, unpatched develop vs this change, with
`HSA_XNACK` unset and `HSA_XNACK=1`.

## Test Result

Identical results with and without the change:

| Test | `HSA_XNACK` unset | `HSA_XNACK=1` |
|---|---|---|
| `Unit_malloc_CoherentTst`, `Unit_malloc_CoherentTstWthAdvise` | skip |
pass |
| `Unit_mmap_CoherentTst`, `Unit_mmap_CoherentTstWthAdvise` | skip |
pass |
| `Unit_hipMemAdvise_TstAlignedAllocMem` | skip | pass |
| `Unit_hipMemAdvise_TstAlignedAllocMem_XNACK` | pass | pass |
| `Unit_hipGetProcAddress_VMM` | pass | pass |
| `Stress_HMM_OverSubscriptionTst`,
`Stress_hipHostRegister_Oversubscription` | skip | not run |

The two stress tests were not run with `HSA_XNACK=1` because they
oversubscribe host memory (~1.2× GPU memory). Their gate is the same
`isXnackOn()` call as the tests above.

Not tested on gfx1250.

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.

---------

Co-authored-by: Claude <noreply@anthropic.com>
dgaliffiAMD pushed a commit that referenced this pull request Oct 21, 2026
#13430)

## Motivation

`HipTest::isXnackOn()` and five tests detect XNACK by searching
`gcnArchName` for `xnack+`. GPUs whose ISA has no XNACK on/off target
feature (e.g. gfx1250) never report `xnack+`, so these tests always skip
there, even with `HSA_XNACK=1`.

## Technical Details

- `isXnackOn()` now returns `hipDeviceAttributePageableMemoryAccess`.
Since #12558 this reflects the process XNACK mode on every GPU, and it
is the capability these tests actually need (GPU access to
`malloc`/`mmap` memory).
- The five tests that duplicated the `gcnArchName` check now call
`isXnackOn()`:
  - `hipMemCoherencyTstMProc.cc`
  - `hipHmmOvrSubscriptionTst.cc`
  - `hipHostRegisterStress.cc`
  - `hipMemAdvise_old.cc`
  - `hipGetProcAddressVmmApis.cc`
- On NVIDIA `isXnackOn()` returns false; the NVIDIA backend never fills
`gcnArchName`, so the old check could not match there either.

## Issue Tracking

JIRA ID: AIRUNTIME-2926

## Test Plan

MI350X (gfx950), ROCr/CLR built from develop `ae6a9a29dd`. Ran all
`isXnackOn()`-gated tests, unpatched develop vs this change, with
`HSA_XNACK` unset and `HSA_XNACK=1`.

## Test Result

Identical results with and without the change:

| Test | `HSA_XNACK` unset | `HSA_XNACK=1` |
|---|---|---|
| `Unit_malloc_CoherentTst`, `Unit_malloc_CoherentTstWthAdvise` | skip |
pass |
| `Unit_mmap_CoherentTst`, `Unit_mmap_CoherentTstWthAdvise` | skip |
pass |
| `Unit_hipMemAdvise_TstAlignedAllocMem` | skip | pass |
| `Unit_hipMemAdvise_TstAlignedAllocMem_XNACK` | pass | pass |
| `Unit_hipGetProcAddress_VMM` | pass | pass |
| `Stress_HMM_OverSubscriptionTst`,
`Stress_hipHostRegister_Oversubscription` | skip | not run |

The two stress tests were not run with `HSA_XNACK=1` because they
oversubscribe host memory (~1.2× GPU memory). Their gate is the same
`isXnackOn()` call as the tests above.

Not tested on gfx1250.

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

6 participants