Skip to content

feat (rocr): ROCr support for cwsr size calculation for DRM - #13479

Merged
bimaniamd merged 1 commit into
amd-unified-interfacefrom
users/bimani/AILIROCR-563-CWSR-Fallback
Oct 29, 2026
Merged

bimaniamd merged 1 commit into
amd-unified-interfacefrom
users/bimani/AILIROCR-563-CWSR-Fallback

Conversation

@bimaniamd

Copy link
Copy Markdown
Contributor
runtime gets cwsr size from KFD, and if KFD does not expose them,
then Runtime tries to do the calculations. Changes are made; so now
we should do the same for DRM.

Motivation

Technical Details

Issue Tracking

Test Plan

Test Result

Submission Checklist

@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/amd_aql_queue.cpp looks correct overall — the fallback logic structure and the call-site integration both look sound.

[Required] PR title format: feat (rocr): → feat(rocr): (no space before the parenthesis). ROCm squash-merges, so the PR title becomes the permanent commit title. The type(component): conventional-commit form requires the component immediately following the type with no space.

break;
if (amdgpu_query_cwsr_info(agent_->libDrmDev(), &cwsr_info) != 0) {
memset(&cwsr_info, 0, sizeof(cwsr_info));
ComputeCwsrSizeFallback(agent_->properties(), &cwsr_info);

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)

[Question] ComputeCwsrSizeFallback() duplicates the VGPR/SGPR/hwreg/wave-count sizing chain from libhsakmt/src/queues.c:update_ctx_save_restore_size(). When is amdgpu_query_cwsr_info expected to fail in practice — older kernels, DRM-without-KFD, or something else? Is there CI that exercises this path, so a future GPU addition to the thunk table that isn't mirrored here doesn't silently produce an undersized CWSR buffer?

@bimaniamd
bimaniamd force-pushed the users/bimani/AILIROCR-563-CWSR-Fallback branch from cc3ae7f to d81c122 Compare October 14, 2026 18:14
@bimaniamd
bimaniamd force-pushed the users/bimani/AILIROCR-563-CWSR-Fallback branch 3 times, most recently from 5ba0655 to 7e8c1d5 Compare October 16, 2026 19:50
    runtime gets cwsr size from KFD, and if KFD does not expose them,
    then Runtime tries to do the calculations. Changes are made; so now
    we should do the same for DRM.
@bimaniamd
bimaniamd force-pushed the users/bimani/AILIROCR-563-CWSR-Fallback branch from 7e8c1d5 to 3df77f0 Compare October 16, 2026 19:52

@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) — follow-up after author force-push (2026-10-16)

Re-checked each raised issue against the current diff. Note: the original commit 3df77f03 was amended in place (same author-date, commit count unchanged) and the rework added amd_drm_driver.cpp/.h, so the change is easy to miss; all gating threads were marked resolved without reply. Per-issue status:

Process / [Required]:

  1. PR title feat (rocr): → feat(rocr): (stray space before the paren) — ⛔ Still open. Title is unchanged, and it becomes the permanent squash-merge commit title.

@dayatsin-amd (gating, CHANGES_REQUESTED):
2. Move the CWSR calc into amd_drm_driver's CreateQueue(...); amd_aql_queue should only hold code common to all driver classes — ⚠️ Partially addressed. ComputeCwsrSizeFallback is now a DrmDriver method and is called from DrmDriver::CreateQueue (good). But amd_aql_queue.cpp still contains the DRM-specific block — static_cast<DrmDriver&>(agent_->driver()).QueryCwsrInfo(...) / .ComputeCwsrSizeFallback(...) plus the cwsr_buf_ sizing — so the fallback is now invoked from two sites and amd_aql_queue is still not driver-common-only as requested. Suggest removing the DRM-specific path from amd_aql_queue.cpp so CreateQueue is the single owner.
3. "Start support with gfx12 and later" — ✅ Addressed. ComputeCwsrSizeFallback returns an error for gfxv < GFX_VERSION_GFX1200, gating the fallback to GFX12+.

@cfreeamd (AI pre-review):
4. The fallback duplicates the thunk's update_ctx_save_restore_size sizing chain; when is amdgpu_query_cwsr_info expected to fail, and is there CI that exercises this path? — ⛔ Still open. No reply and the thread is unresolved; the duplication now lives in amd_drm_driver.cpp::ComputeCwsrSizeFallback, and no CI was added. A future GPU added to the thunk table but not mirrored here would still silently undersize the CWSR buffer.

Net: 1 of 4 fully resolved (gfx12 gating). dayatsin's #2 is only partially met — DRM-specific CWSR code still lives in amd_aql_queue.cpp and the fallback now has two call sites. The [Required] title fix and the duplication/CI question remain open. Heads-up @cfreeamd: your earlier APPROVE (2026-10-15) was against the pre-rework version; @dayatsin-amd's CHANGES_REQUESTED still stands and has not been re-reviewed since the 10-16 force-push.

@bimaniamd
bimaniamd merged commit b9aa308 into amd-unified-interface Oct 29, 2026
22 of 27 checks passed
@bimaniamd
bimaniamd deleted the users/bimani/AILIROCR-563-CWSR-Fallback branch October 29, 2026 16:53
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.

3 participants