Skip to content

Commit

Permalink
[Android] Fix GPU detection
Browse files Browse the repository at this point in the history
This fixes #4204.

Signed-off-by: Vitalii Koshura <[email protected]>
  • Loading branch information
AenBleidd committed Aug 17, 2023
1 parent 640be40 commit 49308a0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion android/build_boinc_arm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export CXX=armv7a-linux-androideabi16-clang++
export LD=arm-linux-androideabi-ld
export CFLAGS="--sysroot=$TCSYSROOT -DANDROID -DDECLARE_TIMEZONE -Wall -I$TCINCLUDES/include -O3 -fomit-frame-pointer -fPIE -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -D__ANDROID_API__=16"
export CXXFLAGS="--sysroot=$TCSYSROOT -DANDROID -Wall -I$TCINCLUDES/include -funroll-loops -fexceptions -O3 -fomit-frame-pointer -fPIE -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -D__ANDROID_API__=16"
export LDFLAGS="$CONFIG_LDFLAGS -llog -fPIE -pie -latomic -static-libstdc++ -march=armv7-a -Wl,--fix-cortex-a8"
export LDFLAGS="$CONFIG_LDFLAGS -llog -fPIE -pie -latomic -lOpenCL -static-libstdc++ -march=armv7-a -Wl,--fix-cortex-a8"
export GDB_CFLAGS="--sysroot=$TCSYSROOT -Wall -g -I$TCINCLUDES/include"

MAKE_FLAGS=""
Expand Down
2 changes: 1 addition & 1 deletion android/build_boinc_arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export CXX=aarch64-linux-android21-clang++
export LD=aarch64-linux-android-ld
export CFLAGS="--sysroot=$TCSYSROOT -DANDROID -DANDROID_64 -DDECLARE_TIMEZONE -Wall -I$TCINCLUDES/include -O3 -fomit-frame-pointer -fPIE -D__ANDROID_API__=21"
export CXXFLAGS="--sysroot=$TCSYSROOT -DANDROID -DANDROID_64 -Wall -I$TCINCLUDES/include -funroll-loops -fexceptions -O3 -fomit-frame-pointer -fPIE -D__ANDROID_API__=21"
export LDFLAGS="$CONFIG_LDFLAGS -llog -fPIE -pie -latomic -static-libstdc++"
export LDFLAGS="$CONFIG_LDFLAGS -llog -fPIE -pie -latomic -lOpenCL -static-libstdc++"
export GDB_CFLAGS="--sysroot=$TCSYSROOT -Wall -g -I$TCINCLUDES/include"

MAKE_FLAGS=""
Expand Down
2 changes: 1 addition & 1 deletion android/build_boinc_armv6.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export CXX=arm-linux-androideabi-clang++
export LD=arm-linux-androideabi-ld
export CFLAGS="--sysroot=$TCSYSROOT -DANDROID -DDECLARE_TIMEZONE -Wall -I$TCINCLUDES/include -O3 -fomit-frame-pointer -fPIE -march=armv6 -mfloat-abi=softfp -mfpu=vfp -D__ANDROID_API__=16 -DARMV6"
export CXXFLAGS="--sysroot=$TCSYSROOT -DANDROID -Wall -I$TCINCLUDES/include -funroll-loops -fexceptions -O3 -fomit-frame-pointer -fPIE -march=armv6 -mfloat-abi=softfp -mfpu=vfp -D__ANDROID_API__=16 -DARMV6"
export LDFLAGS="$CONFIG_LDFLAGS -L$TCSYSROOT/usr/lib -L$TCINCLUDES/lib -llog -fPIE -pie -static-libstdc++ -march=armv6 -lc++_static -lc++abi -landroid_support -lunwind -latomic"
export LDFLAGS="$CONFIG_LDFLAGS -L$TCSYSROOT/usr/lib -L$TCINCLUDES/lib -llog -fPIE -pie -static-libstdc++ -march=armv6 -lc++_static -lc++abi -landroid_support -lunwind -latomic -lOpenCL"
export GDB_CFLAGS="--sysroot=$TCSYSROOT -Wall -g -I$TCINCLUDES/include"

# Prepare android toolchain and environment
Expand Down
2 changes: 1 addition & 1 deletion android/build_boinc_x86.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export CXX=i686-linux-android16-clang++
export LD=i686-linux-android-ld
export CFLAGS="--sysroot=$TCSYSROOT -DANDROID -DDECLARE_TIMEZONE -Wall -I$TCINCLUDES/include -O3 -fomit-frame-pointer -fPIE -D__ANDROID_API__=16"
export CXXFLAGS="--sysroot=$TCSYSROOT -DANDROID -Wall -I$TCINCLUDES/include -funroll-loops -fexceptions -O3 -fomit-frame-pointer -fPIE -D__ANDROID_API__=16"
export LDFLAGS="$CONFIG_LDFLAGS -llog -fPIE -pie -latomic -static-libstdc++"
export LDFLAGS="$CONFIG_LDFLAGS -llog -fPIE -pie -latomic -lOpenCL -static-libstdc++"
export GDB_CFLAGS="--sysroot=$TCSYSROOT -Wall -g -I$TCINCLUDES/include"

MAKE_FLAGS=""
Expand Down
2 changes: 1 addition & 1 deletion android/build_boinc_x86_64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export CXX=x86_64-linux-android21-clang++
export LD=x86_64-linux-android-ld
export CFLAGS="--sysroot=$TCSYSROOT -DANDROID -DANDROID_64 -DDECLARE_TIMEZONE -Wall -I$TCINCLUDES/include -O3 -fomit-frame-pointer -fPIE -D__ANDROID_API__=21"
export CXXFLAGS="--sysroot=$TCSYSROOT -DANDROID -DANDROID_64 -Wall -I$TCINCLUDES/include -funroll-loops -fexceptions -O3 -fomit-frame-pointer -fPIE -D__ANDROID_API__=21"
export LDFLAGS="$CONFIG_LDFLAGS -llog -fPIE -pie -latomic -static-libstdc++"
export LDFLAGS="$CONFIG_LDFLAGS -llog -fPIE -pie -latomic -lOpenCL -static-libstdc++"
export GDB_CFLAGS="--sysroot=$TCSYSROOT -Wall -g -I$TCINCLUDES/include"

MAKE_FLAGS=""
Expand Down
11 changes: 10 additions & 1 deletion client/gpu_opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
#include <mach-o/dyld.h>
#endif
#include "config.h"
#ifdef ANDROID
#include <CL/cl.h>
#else
#include <dlfcn.h>
#endif
#endif

#include <vector>
#include <string>
Expand Down Expand Up @@ -216,6 +220,11 @@ void COPROCS::get_opencl(
p_clGetPlatformInfo = (CL_PLATFORMINFO)GetProcAddress( opencl_lib, "clGetPlatformInfo" );
p_clGetDeviceIDs = (CL_DEVICEIDS)GetProcAddress( opencl_lib, "clGetDeviceIDs" );
p_clGetDeviceInfo = (CL_INFO)GetProcAddress( opencl_lib, "clGetDeviceInfo" );
#elif defined (ANDROID)
p_clGetPlatformIDs = &clGetPlatformIDs;
p_clGetPlatformInfo = &clGetPlatformInfo;
p_clGetDeviceIDs = &clGetDeviceIDs;
p_clGetDeviceInfo = &clGetDeviceInfo;
#else
#ifdef __APPLE__
opencl_lib = dlopen("/System/Library/Frameworks/OpenCL.framework/Versions/Current/OpenCL", RTLD_NOW);
Expand Down Expand Up @@ -669,7 +678,7 @@ void COPROCS::get_opencl(
leave:
#ifdef _WIN32
if (opencl_lib) FreeLibrary(opencl_lib);
#else
#elif !defined (ANDROID)
if (opencl_lib) dlclose(opencl_lib);
#endif
}
Expand Down

0 comments on commit 49308a0

Please sign in to comment.