Skip to content

perf(amdgpu): reduce per-kernel SGPR pressure#39

Open
peizhang56 wants to merge 2 commits into
amd-integrationfrom
perf/amdgpu-trim-sgpr-pressure
Open

perf(amdgpu): reduce per-kernel SGPR pressure#39
peizhang56 wants to merge 2 commits into
amd-integrationfrom
perf/amdgpu-trim-sgpr-pressure

Conversation

@peizhang56

Copy link
Copy Markdown

Two AMDGPU codegen changes:

  • Emit a no-loop variant of gpu_parallel_range_for_fixed_config when the launch grid fully covers the iteration space, removing the grid-stride loop's SGPR bookkeeping at kernel entry. Gated by a saturating_grid_dim safety check.

  • Strip 8 unused implicit kernarg SGPR preloads at JIT time (amdgpu-no-{queue-ptr,dispatch-id,completion-action, multigrid-sync-arg,heap-ptr,default-queue,hostcall-ptr, lds-kernel-id}). No Quadrants kernel consumes them; each one freed reclaims an SGPR pair on every AMDGPU kernel.

Issue: #

Brief Summary

copilot:summary

Walkthrough

copilot:walkthrough

Two AMDGPU codegen changes:

* Emit a no-loop variant of gpu_parallel_range_for_fixed_config when
  the launch grid fully covers the iteration space, removing the
  grid-stride loop's SGPR bookkeeping at kernel entry. Gated by a
  saturating_grid_dim safety check.

* Strip 8 unused implicit kernarg SGPR preloads at JIT time
  (amdgpu-no-{queue-ptr,dispatch-id,completion-action,
  multigrid-sync-arg,heap-ptr,default-queue,hostcall-ptr,
  lds-kernel-id}). No Quadrants kernel consumes them; each one
  freed reclaims an SGPR pair on every AMDGPU kernel.

Co-authored-by: Cursor <cursoragent@cursor.com>
@peizhang56

Copy link
Copy Markdown
Author

/run-ci

Add JIT-time predicate grid_exactly_covers_range in codegen_amdgpu.cpp and
a leaner runtime template gpu_parallel_range_for_fixed_config_no_loop_no_guard
in runtime.cpp that omits the s_and_saveexec/s_cbranch_execz guard when
bounds are compile-time constants and grid_dim*block_dim == (end-begin).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant