Repository navigation
Conversation
The HIP adapter reported only the non-opt-in shared-memory size and set hipFuncAttributeMaxDynamicSharedMemorySize only when UR_HIP_MAX_LOCAL_MEM_SIZE was set. On NVIDIA that hides the opt-in pool above 48 KiB. Query the opt-in ceiling and set the attribute when a launch exceeds the default limit, matching the CUDA adapter. A missing or zero opt-in result keeps the non-opt-in size. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
🟡 Changes recommended
The central HIP-on-NVIDIA opt-in launch path lacks automated coverage.
1 open finding
What changed in this PR
Aligns the HIP adapter with CUDA’s opt-in shared-memory behavior.
Changes:
- Reports the larger opt-in local-memory ceiling with fallback.
- Opts kernels into larger dynamic shared memory when needed.
- Preserves environment-variable caps.
| File | Description |
|---|---|
hip/enqueue.cpp |
Enables per-kernel opt-in shared memory. |
hip/device.hpp |
Queries and stores default and opt-in limits. |
hip/device.cpp |
Documents the reported local-memory ceiling. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The opt-in attribute path is only reachable when the per-block ceiling exceeds the non-opt-in limit. Skip that launch when the two are equal, and still check the reported size, a launch at that size, and rejection of one extra byte, including a UR_HIP_MAX_LOCAL_MEM_SIZE cap.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open findings
This test implicitly relies on the default SYCL device selection to pick the HIP backend device… · New This test implicitly relies on the default SYCL device selection to pick the HIP backend device… · New This path setshipFuncAttributeMaxDynamicSharedMemorySizetoLocalSizewithout guarding against… · New Add HIP test coverage for opt-in local memory branch The comment about laterhipDeviceGetAttributecalls being 'poisoned' is potentially misleading:… · New CallinghipFuncSetAttributeon every enqueue can add measurable overhead for workloads with many… · New
🧠 Review effort: Lite
There was a problem hiding this comment.
🟡 Changes recommended
Launch correctness issues remain in NVIDIA API usage, shared-function synchronization, and static-memory accounting, alongside missing test SDK gating.
10 open findings
HIP test must require the hip_dev_kit feature · New Use the NVIDIA driver API for module function attributes · New Race updating shared function limits across concurrent launches · New Include static shared memory when checking launch limits · New This path setshipFuncAttributeMaxDynamicSharedMemorySizetoLocalSizewithout guarding against… This test implicitly relies on the default SYCL device selection to pick the HIP backend device… This test implicitly relies on the default SYCL device selection to pick the HIP backend device… Add HIP test coverage for opt-in local memory branch CallinghipFuncSetAttributeon every enqueue can add measurable overhead for workloads with many… The comment about laterhipDeviceGetAttributecalls being 'poisoned' is potentially misleading:…
🧠 Review effort: Balanced
ldorau
left a comment
There was a problem hiding this comment.
Please fix failing CI builds
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed the latest review in 475f087:
Hardware validation on gilgamesh:
The changed NVIDIA |
Co-authored-by: Cursor <cursoragent@cursor.com>
|
The actionable Windows CI failure was the new HIP test being selected by the build-only Windows configuration: |
The Windows build compiles this test for spir64, where --rocm-path from %hip_options is unused and fails under -Werror. Co-authored-by: Cursor <cursoragent@cursor.com>



Summary
The HIP adapter reported
hipDeviceAttributeMaxSharedMemoryPerBlockasUR_DEVICE_INFO_LOCAL_MEM_SIZEand calledhipFuncSetAttribute(hipFuncAttributeMaxDynamicSharedMemorySize)only whenUR_HIP_MAX_LOCAL_MEM_SIZE/SYCL_PI_HIP_MAX_LOCAL_MEM_SIZEwas set. That matches neither the CUDA adapter nor HIP on NVIDIA.On NVIDIA, HIP forwards these calls to CUDA. The default per-block limit stays 48 KiB, and the opt-in ceiling is larger (measured: T4 64 KiB, RTX A2000 99 KiB, H100 PCIe 227 KiB). A launch above 48 KiB has to opt in with
cudaFuncSetAttribute/hipFuncSetAttribute. The CUDA adapter already does this; the HIP adapter did not, so a SYCL program on the HIP backend could not use that pool.This change:
hipDeviceAttributeSharedMemPerBlockOptinand reports the larger of that value and the non-opt-in size aslocal_mem_size.hipFuncAttributeMaxDynamicSharedMemorySizewhen the kernel's dynamic local size exceeds the non-opt-in limit.UR_HIP_MAX_LOCAL_MEM_SIZEas a cap on that ceiling.A failed query or a zero opt-in result keeps the non-opt-in size. ROCm 5.7 rejects the attribute on AMD, and ROCm 6.2 returns 0. ROCm 6.4+ reports the opt-in value, but it is the same 64 KiB LDS size as the non-opt-in limit for every ISA in the ROCclr table (
gfx906,gfx90a,gfx942, and the RDNA targets). On those AMD devices this does not grow the pool; it also does not shrinklocal_mem_sizeto 0.Fixes #23365.
Test plan
gfx90a, ROCm 7.1.1), both devices, with the patchedlibur_adapter_hip.so:local_mem_sizeis 65536; 1 KiB, 48 KiB, and 64 KiBlocal_accessorlaunches read back the first and last byte; 64 KiB + 1 KiB is rejected before launch.UR_HIP_MAX_LOCAL_MEM_SIZE=32768lowers both the query and the launch limit. A cap above the device size is clamped to 65536.hipFuncSetAttribute; 65 KiB fails with or without it.sycl/test-e2e/Adapters/hip-local-mem-optin.cppskips thedefault + 1launch.local_mem_sizeis 65536; a 64 KiB launch reads back the first and last byte; 64 KiB + 1 is rejected.UR_HIP_MAX_LOCAL_MEM_SIZE=32768lowers both the query and the launch limit.HIP_PLATFORM=nvidia, ROCm 7.1.1 HIP, CUDA 12.8).hipDeviceAttributeMaxSharedMemoryPerBlockis 49152 andhipDeviceAttributeSharedMemPerBlockOptinis 232448 (227 KiB). A dynamic launch of 48 KiB succeeds with nohipFuncSetAttribute. 49153 bytes fails withhipErrorInvalidValueunlesshipFuncAttributeMaxDynamicSharedMemorySizeis set to the launch size (or once, to 232448). The opted-in launch then succeeds through 232448 bytes and reads back the first and last byte; 232449 is rejected. This is a native HIP program, not a SYCL HIP-adapter launch.gfx90a, ROCm 7.1.1). Both attributes are 65536. A 64 KiB dynamic launch succeeds with nohipFuncSetAttribute. 65537 fails with or without it, and setting the attribute to 65537 is itselfhipErrorInvalidValue.Made with Cursor