Skip to content

[UR][HIP] Implement urKernelSuggestMaxCooperativeGroupCount#22667

Open
zjin-lcf wants to merge 1 commit into
intel:syclfrom
zjin-lcf:hip-kernel-suggest-max-coop-group-count
Open

[UR][HIP] Implement urKernelSuggestMaxCooperativeGroupCount#22667
zjin-lcf wants to merge 1 commit into
intel:syclfrom
zjin-lcf:hip-kernel-suggest-max-coop-group-count

Conversation

@zjin-lcf

Copy link
Copy Markdown
Contributor

Implement the cooperative-group-count occupancy query for the HIP (AMD) adapter, which previously returned UR_RESULT_ERROR_UNSUPPORTED_FEATURE and forced the SYCL runtime onto a coarse 0/1 host-side fallback for kernel::ext_oneapi_get_info<max_num_work_groups>.

As noted in #21803, a direct port of the CUDA implementation does not work: hipOccupancyMaxActiveBlocksPerMultiprocessor expects a host function pointer, whereas our kernel handle (hKernel->get()) is a module-loaded hipFunction_t. Use the module-occupancy entry point hipModuleOccupancyMaxActiveBlocksPerMultiprocessor instead, mirroring the existing hipModuleOccupancyMaxPotentialBlockSize usage in the adapter.

The total suggested group count is the per-CU occupancy multiplied by the device multiprocessor (compute-unit) count. When the per-CU occupancy is 0, fall back to reporting 1 group if the requested work-group size, dynamic local memory, and per-block register usage all fit within device limits, matching the CUDA adapter's semantics.

Closes: #21803

Implement the cooperative-group-count occupancy query for the HIP (AMD)
adapter, which previously returned UR_RESULT_ERROR_UNSUPPORTED_FEATURE and
forced the SYCL runtime onto a coarse 0/1 host-side fallback for
kernel::ext_oneapi_get_info<max_num_work_groups>.

As noted in intel#21803, a direct port of the CUDA implementation does
not work: hipOccupancyMaxActiveBlocksPerMultiprocessor expects a host
function pointer, whereas our kernel handle (hKernel->get()) is a
module-loaded hipFunction_t. Use the module-occupancy entry point
hipModuleOccupancyMaxActiveBlocksPerMultiprocessor instead, mirroring the
existing hipModuleOccupancyMaxPotentialBlockSize usage in the adapter.

The total suggested group count is the per-CU occupancy multiplied by the
device multiprocessor (compute-unit) count. When the per-CU occupancy is 0,
fall back to reporting 1 group if the requested work-group size, dynamic
local memory, and per-block register usage all fit within device limits,
matching the CUDA adapter's semantics.

Closes: intel#21803

Co-authored-by: Cursor <cursoragent@cursor.com>
@zjin-lcf
zjin-lcf requested a review from a team as a code owner July 18, 2026 15:57
@zjin-lcf
zjin-lcf requested a review from bratpiorka July 18, 2026 15:57
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.

urKernelSuggestMaxCooperativeGroupCountExp for Hip

1 participant