CNugteren / CLBlast

Tuned OpenCL BLAS
Apache License 2.0
1.06k stars 202 forks source link

Do I have to cross-compile both opencl and clblast for android? #511

Open DavdGao opened 1 year ago

DavdGao commented 1 year ago

Target

I want to build CLBlast for android app with JNI.

Question

I am cross-compiling clblast for android with the following scripts.

#!/bin/bash

ANDROID_NDK_PATH=/Users/david/Library/Android/sdk/ndk/25.1.8937393/

cmake .. \
    -DCMAKE_SYSTEM_NAME=Android \
    -DCMAKE_SYSTEM_VERSION=33 \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
    -DCMAKE_ANDROID_NDK=$ANDROID_NDK_PATH \
    -DCMAKE_ANDRFOID_STL_TYPE=gnustl_static \
    -DBUILD_SHARED_LIBS=OFF \
    -DOPENCL_ROOT=/Users/david/Documents/C++/OpenCL-SDK/build_android/OpenCL/include/ \
    -DOPENCL_INCLUDE_DIRS=/Users/david/Documents/C++/OpenCL-SDK/build_android/OpenCL/include/ \
    -DOPENCL_LIBRARIES=/Users/david/Documents/C++/OpenCL-SDK/build_android/OpenCL/libOpenCL.so

cmake --build . --config Release

cmake --install . --prefix install_android

Update 2023/10/25

CNugteren commented 1 year ago

Regarding Q1, compiling the OpenCL library yourself seems unusual, I would expect that you simply get one from your vendor or find one on your device and link against that one. In any case, something like clGetPlatformsIDs not working isn't a CLBlast problem, so I can't help you any further with that. You would have to look at your vendors manual for OpenCL.

Regarding Q2, I think linking against either a dynamic or static version of CLBlast should work. Just go with your preference or whatever is easiest.

By the way, there is quite some information spread over various issues regarding Android on CLBlast's GitHub issue tracker, as well as some Android documentation at https://github.com/CNugteren/CLBlast/blob/master/doc/installation.md#android-compilation-from-source.

I hope this helps.

engineer1109 commented 1 year ago

build OpenCL lib by mesa or KHR code