Hello everyone. I have issued when try to build Android RPC application with OpenCL backend. Few points to admit:
- I have built tvm and tvm runtime with OpenCL enabled. libOpenCL.so was taken from /usr/lib/x86_64-linux-gnu/libOpenCL.so
So, when I try to build android_rpc with libOpenCL.so pulled from device (I have tried from both /vendor/lib64/ and /system/vendor/lib64) - log from terminal is:
make: Entering directory '/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni'
Android NDK: WARNING: APP_PLATFORM android-24 is higher than android:minSdkVersion 1 in /home/whoami/Documents/tvm/apps/android_rpc/app/src/main/AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android-24. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.
Android NDK: WARNING:/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni/Android.mk:tvm4j_runtime_packed: non-system libraries in linker flags: -latomic libOpenCL.so
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
make: Leaving directory '/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni'
make: Entering directory '/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni'
[arm64-v8a] Compile++ : tvm4j_runtime_packed <= org_apache_tvm_native_c_api.cc
[arm64-v8a] SharedLibrary : libtvm4j_runtime_packed.so
/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function `tvm::runtime::cl::OpenCLWorkspace::AllocTextureWorkspace(DLDevice, unsigned long, unsigned long, DLDataType)':
/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/opencl/opencl_device_api.cc:250: undefined reference to `tvm::runtime::TexturePool::AllocTexture(DLDevice, unsigned long, unsigned long, DLDataType)'
/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function `tvm::runtime::cl::OpenCLWorkspace::FreeTextureWorkspace(DLDevice, void*)':
/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/opencl/opencl_device_api.cc:254: undefined reference to `tvm::runtime::TexturePool::FreeTexture(DLDevice, void*)'
/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function `~OpenCLThreadEntry':
/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/opencl/opencl_common.h:294: undefined reference to `tvm::runtime::TexturePool::~TexturePool()'
/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/org_apache_tvm_native_c_api.o: In function `OpenCLThreadEntry':
/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/opencl/opencl_common.h:313: undefined reference to `tvm::runtime::TexturePool::TexturePool(DLDeviceType, tvm::runtime::DeviceAPI*)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/whoami/Android/Sdk/ndk/21.3.6528147/build/core/build-binary.mk:725: /home/whoami/Documents/tvm/apps/android_rpc/app/src/main/obj/local/arm64-v8a/libtvm4j_runtime_packed.so] Error 1
make: Leaving directory '/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni
Also, I have got error if I use libOpencl.so from /usr/lib/x86_64-linux-gnu/ (I use it for tvm compilation), the log is the next:
make: Entering directory '/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni'
Android NDK: WARNING: APP_PLATFORM android-24 is higher than android:minSdkVersion 1 in /home/whoami/Documents/tvm/apps/android_rpc/app/src/main/AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android-24. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.
Android NDK: WARNING:/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni/Android.mk:tvm4j_runtime_packed: non-system libraries in linker flags: -latomic libOpenCL.so
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
make: Leaving directory '/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni'
make: Entering directory '/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni'
[arm64-v8a] Compile++ : tvm4j_runtime_packed <= org_apache_tvm_native_c_api.cc
[arm64-v8a] SharedLibrary : libtvm4j_runtime_packed.so
libOpenCL.so: error adding symbols: File in wrong format
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/whoami/Android/Sdk/ndk/21.3.6528147/build/core/build-binary.mk:725: /home/whoami/Documents/tvm/apps/android_rpc/app/src/main/obj/local/arm64-v8a/libtvm4j_runtime_packed.so] Error 1
make: Leaving directory '/home/whoami/Documents/tvm/apps/android_rpc/app/src/main/jni'
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:buildJni'.
> Process 'command 'sh'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Could you help me with android_rpc building with opencl backend? Do you have any suggestions, why libOpenCL.so pulled from device didnt fir for compilation?
P.S. Settings from config.mk:
APP_ABI = arm64-v8a
APP_PLATFORM = android-24
USE_OPENCL = 1
USE_SORT = 1
USE_RANDOM = 1
ADD_C_INCLUDES = /home/whoami/Documents/OpenCL_SDK/opencl20
ADD_LDLIBS = libOpenCL.so # put lib in the same current dir of config