Repository navigation
Replies: 1 comment
|
Update: the ICD-loader analysis above still stands, but there's a working bypass Follow-up after finding a working path, wanted to correct the record rather than leave the conclusion above standing as-is. The ICD-loader-specific diagnosis (broken But it turns out that's only a blocker for the generic ICD dispatch path, not for OpenCL on this device in general. Linking Tested just now:
Only tested a single short prompt so far, not a full test suite, so treat this as "promising, not fully validated" rather than a confirmed fix. But the driver is clearly usable for real inference when you don't route through the generic ICD dispatch mechanism — worth knowing before anyone reads the original post and rules the whole device out. |
Uh oh!
There was an error while loading. Please reload this page.
Adreno
libOpenCL_system.so(Android/system_ext/lib64) is not ICD-loader compatible — heads-up for anyone chasing this pathDevice: RedMagic 10 Pro, Snapdragon 8 Elite (SM8750), Adreno 830, Android 16, no root. Running llama.cpp under Termux (Android userspace terminal, no NDK/system-app context).
Why I went looking
The usual vendor OpenCL blob (
/vendor/lib64/libOpenCL_adreno.so) is blocked for non-system apps by Android's Bionic linker namespace. But there's a second, less-known driver:/system_ext/lib64/libOpenCL_system.so. It's a normal system library (no namespace restriction), loads cleanly, and exports standard, correctly-workingcl*symbols —clGetPlatformIDs/clGetPlatformInfo/clGetDeviceIDs/clGetDeviceInfoall work fine when called directly (confirmed: "QUALCOMM Snapdragon(TM)" / "Adreno (TM) 830" / OpenCL 3.0).Termux already ships
llama-cpp-backend-opencl(-DGGML_OPENCL=ON), andocl-icd(the ICD loader Termux'slibOpenCL.sois built on) just needs a.icdvendor file pointing at the driver. So I pointed it there, expecting this to just work.What actually happens
Two separate, real problems, in sequence:
1.
clIcdGetPlatformIDsKHR(the ICD-specific platform-enumeration entry point) is broken in this driver. It returnsCL_SUCCESSwith 0 platforms, while the standardclGetPlatformIDson the same library correctly returns 1.ocl-icd(and presumably any standard ICD loader, since this is the entry point they're specified to prefer) ends up with "no platforms" and skips the ICD entirely.Workaround: a ~10-line shim
.sothat just forwardsclIcdGetPlatformIDsKHRto the realclGetPlatformIDs(linked against the real driver as a direct dependency, so every othercl*symbol stays reachable transitively viadlsym). Point the.icdfile at the shim instead of the driver directly. This gets the loader toTry to load 1 platforms.2. Right after that, the loader crashes dereferencing the platform handle. Traced to
ocl-icd'sKHR_ICD2_HAS_TAGcheck:This assumes every
cl_platform_idbegins with a dispatch-table pointer — a core requirement of the OpenCL ICD spec itself, not anocl-icdquirk. I checked the actual handle value this driver hands back: a small, non-pointer-looking value (0xde763ed3), nowhere near any mapped memory region (the library itself is mapped around0x77a3ee...). Dereferencing it segfaults immediately, reproducibly.Conclusion
This driver's platform/device handles aren't ICD-dispatch-table-based at all — likely because it was built for direct internal linking by system apps that call it as the implementation, never for generic multi-vendor ICD loading. That's a structural ABI mismatch with the ICD spec, not a loader bug, and not something fixable with a small patch — every place a loader dereferences the handle through a dispatch table would need to go, which is close to a full rewrite of the dispatch mechanism, not a patch.
Posting this mainly because I noticed a lot of active Adreno-specific work in
ggml-openclrecently (dedicated matmul paths per Adreno generation, MoE fusion, etc.) — if anyone else on a similar Snapdragon/Android/Termux setup finds/system_ext/lib64/libOpenCL_system.soand is tempted to route the ICD loader at it like I was: it doesn't work, and here's why, so you don't have to re-derive it.Happy to share the shim source and repro steps if useful to anyone.
All reactions