Skip to content

**GitHub Issue: Missing Symbol clGetKernelSubGroupInfo on OpenCL 2.0 (Qualcomm Adreno) for Android Build** #3015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
codingWiz-rick opened this issue Apr 8, 2025 · 0 comments

Comments

@codingWiz-rick
Copy link

codingWiz-rick commented Apr 8, 2025


Description

When building/running Whisper.cpp on an Android device with OpenCL 2.0 (Qualcomm Adreno GPU), the app crashes with the error:

CANNOT LINK EXECUTABLE ".../whisper-cli": cannot locate symbol "clGetKernelSubGroupInfo" referenced by "libggml-opencl.so"

The symbol clGetKernelSubGroupInfo is missing in the OpenCL 2.0 implementation on the device, despite the OpenCL version being reported as 2.0.


System Information

  • Device: Qualcomm Adreno(TM) 610 (OpenCL 2.0)
  • Platform: QUALCOMM Snapdragon
  • OpenCL Driver Version: OpenCL 2.0 QUALCOMM build: commit #43fc279f3a (Date: 03/24/23)
  • Affected File: libggml-opencl.so

Root Cause Analysis

  1. Missing OpenCL Symbol:
    clGetKernelSubGroupInfo is part of the OpenCL 2.1 specification (reference).

    • The Qualcomm Adreno GPU reports OpenCL 2.0 support but lacks this symbol, indicating a driver limitation or incomplete implementation of OpenCL 2.1 features.
  2. Compatibility Issue:
    Whisper.cpp’s OpenCL backend may conditionally use this symbol without proper runtime version checks, leading to linker errors on devices with older OpenCL implementations.


Steps to Reproduce

  1. Build Whisper.cpp for Android with OpenCL enabled.
  2. Run whisper-cli on a Qualcomm Adreno device with OpenCL 2.0 (e.g., devices using Adreno 610).
  3. Observe linker error due to missing symbol.
  4. Due to android delimation copy th gpu related libaries to your lib dir whitout those libs the whisper-cli binary will not even try to use the gpu and report gpu not present

Build Configuration:

git clone https://github.com/ggml-org/whisper.cpp.git
cd whisper.cpp
rm -rf build
cmake -B build \
  -DCMAKE_C_COMPILER=clang \
  -DCMAKE_CXX_COMPILER=clang++ \
  -DCMAKE_CXX_FLAGS=" \
     -isystem $PREFIX/include/c++/v1 \
     -isystem $PREFIX/lib/clang/19/include \
     -isystem $PREFIX/include/aarch64-linux-android \
     -isystem $PREFIX/include \
     -ffunction-sections -fdata-sections -fvisibility=hidden -fPIC \
     -Wno-unused-command-line-argument \
     -DCL_TARGET_OPENCL_VERSION=200 \  # Explicitly targets OpenCL 2.0
     -stdlib=libc++ \
  " \
  -DWHISPER_SDL2=ON \
  -DGGML_VULKAN=1 \
  -DGGML_OPENCL=1 \
  -DGGML_BLAS=1 \
  -DBLAS_INCLUDE_DIRS=$PREFIX/include/openblas \
  -DBLAS_LIBRARIES=$PREFIX/lib/libopenblas.so \
  -DOpenCL_INCLUDE_DIR=$PREFIX/include/CL \
  -DOpenCL_LIBRARY=/system/vendor/lib64/libOpenCL.so \  # Links to device's OpenCL 2.0 lib
  -DVulkan_GLSLC_EXECUTABLE=$PREFIX/bin/glslc \
  -DGGML_ENABLE_FP16=ON \
  -DGGML_OPT_DOTPROD=ON \
  -DGGML_OPT_I8MM=ON \

  -DGGML_OPT_SVE=ON \
  -DVulkan_LIBRARY=/system/lib64/libvulkan.so
cmake --build build -j4 > build.log 2>&1 &

Here’s a formatted GitHub issue description based on the provided log, with the extra timestamps and SHELLOUT tags removed, and organized for readability using GitHub Markdown formatting:


Issue: Build Log Analysis for com.codewiz.ailyrics - CMake and Compiler Warnings

Description

The following build log was generated during the compilation of the com.codewiz.ailyrics project on an ARM-based system (aarch64). The log includes CMake configuration details, compiler outputs, and several warnings that may indicate potential issues or areas for improvement in the build process. This issue is to document and address the warnings and potential failures observed.

Build Environment

  • Date: April 08, 2025
  • Package: com.codewiz.ailyrics
  • CMake Version: Minimum required version triggering a deprecation warning
  • Compiler: Clang 19.1.7 (C and CXX)
  • Processor: aarch64 (ARM)
  • Git Version: 2.49.0
  • Python Version: 3.12.9

Log Details

CMake Deprecation Warning
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of CMake.
  Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier.
  • Action Needed: Update the cmake_minimum_required version in CMakeLists.txt to a supported range (e.g., 3.10...3.27) to avoid future compatibility issues.
Compiler Memory Allocation
Compiler allocated 4964KB to compile void android.view.ViewRootImpl.performTraversals()
  • Note: Indicates significant memory usage for a single function compilation, potentially worth optimizing if performance is a concern.
Compiler Identification
-- The C compiler identification is Clang 19.1.7
-- The CXX compiler identification is Clang 19.1.7
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /data/user/0/com.codewiz.ailyrics/files/usr/bin/clang - skipped
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /data/user/0/com.codewiz.ailyrics/files/usr/bin/clang++ - skipped
-- Detecting CXX compile features - done
  • Status: Compiler setup is successful.
Dependencies Found
-- Found Git: /data/user/0/com.codewiz.ailyrics/files/usr/bin/git (found version "2.49.0")
-- Found Threads: TRUE
-- Found OpenMP_C: -fopenmp=libomp (found version "5.1")
-- Found OpenMP_CXX: -fopenmp=libomp (found version "5.1")
-- Found OpenMP: TRUE (found version "5.1")
-- Found BLAS: /data/user/0/com.codewiz.ailyrics/files/usr/lib/libopenblas.so
-- BLAS found, Libraries: /data/user/0/com.codewiz.ailyrics/files/usr/lib/libopenblas.so
-- BLAS found, Includes: /data/user/0/com.codewiz.ailyrics/files/usr/include/openblas
-- Found Vulkan: /system/lib64/libvulkan.so (found version "1.4.310") found components: glslc glslangValidator
-- Found OpenCL: /system/vendor/lib64/libOpenCL.so
-- Found Python3: /data/user/0/com.codewiz.ailyrics/files/usr/bin/python3.12 (found version "3.12.9") found components: Interpreter
  • Status: All major dependencies are detected successfully.
Failed Tests
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Performing Test GGML_COMPILER_SUPPORTS_FP16_FORMAT_I3E - Failed
-- Performing Test GGML_MACHINE_SUPPORTS_dotprod - Failed
-- Performing Test GGML_MACHINE_SUPPORTS_i8mm - Failed
-- Performing Test GGML_MACHINE_SUPPORTS_sve - Failed
-- Performing Test GGML_MACHINE_SUPPORTS_sme - Failed
  • Observation: Several hardware-specific feature tests failed, indicating limited support for certain ARM optimizations (e.g., dot product, SVE, SME). The build falls back to compatible options:
    -- Adding CPU backend variant ggml-cpu: -mcpu=native+nodotprod+noi8mm+nosve+nosme
    
OpenCL Version Detection
-- Looking for CL_VERSION_3_0 - not found
-- Looking for CL_VERSION_2_2 - not found
-- Looking for CL_VERSION_2_1 - not found
-- Looking for CL_VERSION_2_0 - not found
-- Looking for CL_VERSION_1_2 - not found
-- Looking for CL_VERSION_1_1 - not found
-- Looking for CL_VERSION_1_0 - not found
  • Note: No specific OpenCL version was identified, but OpenCL is still included with Adreno-optimized kernels.
Vulkan Warnings

During the compilation of ggml-vulkan.cpp, the following warnings were generated:

/data/user/0/com.codewiz.ailyrics/files/home/whisper.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp:1483:2: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
  1483 | };
       |  ^

/data/user/0/com.codewiz.ailyrics/files/home/whisper.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp:4147:175: warning: unused parameter 'src1_type' [-Wunused-parameter]
  4147 | static vk_pipeline ggml_vk_guess_matmul_pipeline(ggml_backend_vk_context * ctx, vk_matmul_pipeline& mmp, uint32_t m, uint32_t n, bool aligned, ggml_type src0_type, ggml_type src1_type) {
       |                                                                                                                                                                               ^

/data/user/0/com.codewiz.ailyrics/files/home/whisper.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp:6830:9: warning: suggest braces around initialization of subobject [-Wmissing-braces]
  6830 |         sections[0], sections[1], sections[2], sections[3], backprop
       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/data/user/0/com.codewiz.ailyrics/files/home/whisper.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp:7970:16: warning: 'return' will never be executed [-Wunreachable-code-return]
  7970 |         return false;
       |                ^~~~~

/data/user/0/com.codewiz.Ошибкиailyrics/files/home/whisper.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp:9235:15: warning: 'break' will never be executed [-Wunreachable-code-break]
  9235 |             } break;
       |               ^~~~~
  • Total Warnings: 8
  • Action Needed: Review and fix the following:
    1. Remove extra semicolon at line 1483.
    2. Address unused parameter src1_type at line 4147.
    3. Add braces for initialization at line 6830.
    4. Investigate unreachable code at lines 7970, 9235, 9194, 9107, and 9052.
Build Completion
-- Configuring done (28.0s)
-- Generating done (0.6s)
-- Build files have been written to: /data/user/0/com.codewiz.ailyrics/files/home/whisper.cpp/build
[100%] Built target whisper-talk-llama
  • Status: Build completed successfully despite warnings.

Steps to Reproduce

  1. Clone the repository containing com.codewiz.ailyrics.
  2. Run the build process on an ARM-based system with the specified tools (Clang 19.1.7, CMake, etc.).
  3. Observe the log output for warnings and failed tests.

Expected Behavior

  • No deprecation warnings from CMake.
  • No compiler warnings or unreachable code in ggml-vulkan.cpp.
  • Successful detection of hardware-specific features or clear fallbacks.

Actual Behavior

  • CMake deprecation warning due to outdated version requirement.
  • Multiple compiler warnings in ggml-vulkan.cpp.
  • Failed hardware feature tests, with fallbacks applied.

Proposed Fixes

  1. Update CMakeLists.txt to use a modern cmake_minimum_required version.
  2. Refactor ggml-vulkan.cpp to address warnings (remove extra semicolon, handle unused parameters, fix unreachable code).
  3. Investigate OpenCL version detection failures and ensure compatibility.

Additional Notes

  • The build succeeds, so these issues are not critical but should be addressed for maintainability and future-proofing.
  • Hardware-specific optimizations (e.g., SVE, dotprod) are not supported on this aarch64 system, which may impact performance.

This format organizes the log into a clear GitHub issue with actionable insights while adhering to Markdown conventions. Let me know if you'd like further adjustments!

Proposed Solutions

  1. Add Runtime OpenCL Version Checks:
    Ensure clGetKernelSubGroupInfo is only used if CL_VERSION_2_1 (or higher) is supported by the device. Example:
    #if defined(CL_VERSION_2_1)
    // Use clGetKernelSubGroupInfo
    #else
    // Fallback for older OpenCL versions
    #endif

Log Snippet

Click to expand device/platform logs
Platform Name: QUALCOMM Snapdragon(TM)
Platform Version: OpenCL 2.0 QUALCOMM build...
Device Name: QUALCOMM Adreno(TM) 610
Driver Version: OpenCL 2.0 QUALCOMM build...

Error: CANNOT LINK EXECUTABLE ".../whisper-cli": cannot locate symbol "clGetKernelSubGroupInfo"

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

No branches or pull requests

1 participant