halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.78k stars 1.07k forks source link

Does Halide support opencl on Android (Qualcomm)? #8228

Open wgy123-cell opened 1 month ago

wgy123-cell commented 1 month ago

Hello,

I am porting Halide/apps/blur to Android (Qualcomm Snapdragon 7325) and the CPU version works fine. Then I tried the OpenCL version with the following changes:

  1. set APP_TARGET=arm-64-android-opencl.
  2. script run command line changed to: HL_TARGET=arm-64-android-opencl adb_run_on_device.sh

But it compiles wrong and reports the following error: g++ -O3 -std=c++17 -I /home/Halide-16.0.0/distrib/include/ -I /home/Halide-16.0.0/distrib/tools/ -Wall -Werror -Wno-unused-function -Wcast-qual -Wignored-qualifiers -Wno-comment -Wsign-compare -Wno-psabi -fopenmp -Wall -O2 -Ibin/arm-64-android-opencl test.cpp bin/arm-64-android-opencl/halide_blur.a -o bin/arm-64-android-opencl/test -ldl -lpthread -lz /usr/bin/ld: bin/arm-64-android-opencl/halide_blur.a(halide_blur.a.o):Relocations in generic ELF(M:183) /usr/bin/ld: bin/arm-64-android-opencl/halide_blur.a(halide_blur.a.o):Relocations in generic ELF(M:183) /usr/bin/ld: bin/arm-64-android-opencl/halide_blur.a(halide_blur.a.o):Relocations in generic ELF(M:183) /usr/bin/ld: bin/arm-64-android-opencl/halide_blur.a(halide_blur.a.o):Relocations in generic ELF(M:183) bin/arm-64-android-opencl/halide_blur.a:** error adding symbols: File in wrong format collect2: error:ld return 1 Makefile:26: recipe for target 'bin/arm-64-android-opencl/test' failed make: *** [bin/arm-64-android-opencl/test] Error 1 rm bin/arm-64-android-opencl/halide_blur.a

Compiled on Ubuntu 18.04, ANDROID_NDK_ROOT=android-ndk-r24, llvm+clang=16.0.6, halide-16.0.0, gcc=9.4.0, running on Qualcomm Snapdragon 7325 on Android side.

I'm not sure if there's a mistake in my changes or if halide doesn't support the opencl version for android, hopefully someone can answer this, any relevant replies would be appreciated.