HIP workgroup scratch launch property#22669
Open
zjin-lcf wants to merge 3 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.