Skip to content

fix: getBackendHandles reports concrete backend name, not CHIP_BE value#1201

Merged
pvelesko merged 2 commits intomainfrom
fix-1199
Mar 16, 2026
Merged

fix: getBackendHandles reports concrete backend name, not CHIP_BE value#1201
pvelesko merged 2 commits intomainfrom
fix-1199

Conversation

@pvelesko
Copy link
Copy Markdown
Collaborator

Problem

hipGetBackendNativeHandles() was returning the value of CHIP_BE (e.g. "default") as the backend name string in NativeHandles[0]. When CHIP_BE is unset, BackendType::str() returns "default" — the requested backend selector, not the actual running backend.

Callers such as libMKLShim.so compare this string against "opencl" and "level0" and call std::abort() on any other value, producing:

Unsupported backend: default
Aborted (exit 134)

Closes #1199

Fix

  • CHIPBackendOpenCL.cc: hard-code NativeInfo[0] = (uintptr_t)"opencl"
  • CHIPBackendLevel0.cc: hard-code NativeInfo[0] = (uintptr_t)"level0"
  • CHIPDriver.hh: accept "default" as a valid CHIP_BE value (maps to BackendType::Default for auto-selection, same as empty string)

Test

Added tests/runtime/TestNativeHandlesBackendName.cpp: calls hipGetBackendNativeHandles() and asserts NativeHandles[0] is "opencl" or "level0", never "default". Includes a _NoBE variant that runs with CHIP_BE unset.

Results

  • dgpu opencl: 1156/1158 passed
  • dgpu level0: 1155/1157 passed
  • 2 pre-existing Unit_printf_* failures unrelated to this change

…ue (#1199)

When CHIP_BE is unset or set to "default", BackendType::str() returns
"default". Both CHIPQueueOpenCL and CHIPQueueLevel0 used this value for
NativeHandles[0] in hipGetBackendNativeHandles(). Interop callers such as
libMKLShim compare this string against "opencl"/"level0" and abort on any
other value, causing "Unsupported backend: default" + exit 134.

Fix:
- CHIPQueueOpenCL::getBackendHandles: hard-code NativeHandles[0] = "opencl"
- CHIPQueueLevel0::getBackendHandles: hard-code NativeHandles[0] = "level0"
- BackendType(string): accept "default" as a valid value (same as "") mapping
  to BackendType::Default for auto-selection in CHIPInitializeCallOnce
@pvelesko pvelesko merged commit 4446fee into main Mar 16, 2026
17 of 18 checks passed
@pvelesko pvelesko deleted the fix-1199 branch March 16, 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.

hipDeviceGetAttribute: Unsupported backend: default causes abort

1 participant