Add OpenCL/Adreno backend support for Android aarch64#181
Merged
Conversation
Idea ported from LLaMAndroid (Rattlyy/LLaMAndroid): build a second Android arm64 artifact with the OpenCL backend enabled and Adreno-tuned kernels embedded, so users on Qualcomm Snapdragon devices get real GPU acceleration instead of CPU-only inference. The existing CPU Android JAR stays as the default fallback for devices without an OpenCL ICD. - CMakeLists.txt: route GGML_OPENCL builds to resources_android_opencl/ - pom.xml: add opencl-android profile + classifier opencl-android-aarch64 - publish.yml: new crosscompile-android-aarch64-opencl job wired into package, publish-snapshot, and publish-release - CLAUDE.md: document the three wiring points https://claude.ai/code/session_01CQFUfYpg9m65CBt5RRaFRr
The dockcross/android-arm64 image does not ship OpenCL headers or a stub libOpenCL.so, so find_package(OpenCL REQUIRED) in ggml-opencl fails. Add build_opencl_android.sh which clones pinned KhronosGroup OpenCL-Headers and cross-builds OpenCL-ICD-Loader inside the container, then passes -DOpenCL_INCLUDE_DIR and -DOpenCL_LIBRARY into the main project cmake. The device's vendor ICD (Adreno driver) provides the runtime symbols. https://claude.ai/code/session_01CQFUfYpg9m65CBt5RRaFRr
CI passes all cmake flags as a single quoted string. The previous
script preserved it as one array element via "${EXTRA_ARGS[@]}",
so cmake received one giant argument and OS_NAME/OS_ARCH/etc. were
never set. Match .github/build.sh's unquoted $@ pattern so the
shell re-splits the string into individual -D flags.
https://claude.ai/code/session_01CQFUfYpg9m65CBt5RRaFRr
|
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.



Summary
opencl-android-aarch64Changes
CMakeLists.txt:
src/main/resources_android_opencl/instead of the default CPU resource directory.github/workflows/publish.yml:
crosscompile-android-aarch64-opencljob that cross-compiles with-DGGML_OPENCL=ON -DGGML_OPENCL_EMBED_KERNELS=ON -DGGML_OPENCL_USE_ADRENO_KERNELS=ONpackage,publish-snapshot, andpublish-releasejobs to download the OpenCL artifacts and activate theopencl-androidMaven profilepom.xml:
opencl-androidMaven profile that produces a JAR with classifieropencl-android-aarch64from the separate output directoryCLAUDE.md:
Test plan
Related issues / PRs
Checklist
CONTRIBUTING.mdandCODE_OF_CONDUCT.mdhttps://claude.ai/code/session_01CQFUfYpg9m65CBt5RRaFRr