Skip to content

HIP workgroup scratch launch property#22669

Open
zjin-lcf wants to merge 3 commits into
intel:syclfrom
zjin-lcf:hip-workgroup-scratch-launch-property
Open

HIP workgroup scratch launch property#22669
zjin-lcf wants to merge 3 commits into
intel:syclfrom
zjin-lcf:hip-workgroup-scratch-launch-property

Conversation

@zjin-lcf

Copy link
Copy Markdown
Contributor

No description provided.

zjin-lcf and others added 3 commits July 18, 2026 07:51
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>
…rrier

The HIP adapter previously ignored the UR_KERNEL_LAUNCH_FLAG_COOPERATIVE
launch property and always issued an ordinary launch, so the work-groups of
a root-group kernel were not guaranteed to be co-resident. In addition, the
amdgpu libspirv __spirv_ControlBarrier always emitted a work-group scope
barrier regardless of the requested execution scope, so a Device/CrossDevice
(root-group) barrier only synchronized within a work-group.

Issue a cooperative launch via hipModuleLaunchCooperativeKernel when the
COOPERATIVE flag is set, and lower a Device/CrossDevice execution scope
barrier to the ROCm device library grid synchronization (__ockl_grid_sync),
which is valid because the launch is now cooperative. This makes root-group
synchronization work end-to-end on AMD GPUs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Free-function kernels request dynamic work-group local memory through a
UR_STRUCTURE_TYPE_KERNEL_LAUNCH_WORKGROUP_PROPERTY launch property node. The
HIP adapter previously rejected any launch property node other than the
cooperative flag with UR_RESULT_ERROR_UNSUPPORTED_FEATURE, so such launches
failed.

Parse the work-group launch property and add the requested amount to the
dynamic shared memory passed to the kernel launch, matching the CUDA adapter.

Co-authored-by: Cursor <cursoragent@cursor.com>
@zjin-lcf
zjin-lcf requested review from a team, Maetveis and wenju-he as code owners July 18, 2026 15:59
@zjin-lcf
zjin-lcf requested a review from kekaczma July 18, 2026 15:59
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