Skip to content

Commit

Permalink
Support for armv8 arch only devices (#994)
Browse files Browse the repository at this point in the history
Recent pixel devices do not report armv7 arch support and only
arm64-v8a. This causes benchmark test to exit early with message stating
"Not an ARMv7 and not an X86 SSSE3 CPU !\n".

This update includes check for `ANDROID_CPU_FAMILY_ARM64` along with
subsequent cmake and gradle updates for running the test app.
  • Loading branch information
nfynt authored May 3, 2024
1 parent 9ae3781 commit 1cb6518
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion hello-neon/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
targetSdkVersion 33
versionCode 1
versionName "1.0"
ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a'
ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
}
buildTypes {
release {
Expand Down
6 changes: 5 additions & 1 deletion hello-neon/app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ elseif (${ANDROID_ABI} STREQUAL "x86")
-Wno-constant-conversion \
-Wno-static-in-inline")
add_definitions(-DHAVE_NEON_X86=1 -DHAVE_NEON=1)
elseif (${ANDROID_ABI} STREQUAL "x86_64")
set(neon_SRCS helloneon-intrinsics.c)
add_definitions(-DHAVE_NEON_X86=1 -DHAVE_NEON=1)
else ()
set(neon_SRCS)
set(neon_SRCS helloneon-intrinsics.c)
add_definitions("-DHAVE_NEON=1")
endif ()

add_library(hello-neon SHARED helloneon.c ${neon_SRCS})
Expand Down
7 changes: 0 additions & 7 deletions hello-neon/app/src/main/cpp/helloneon.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ jstring Java_com_example_helloneon_HelloNeon_stringFromJNI(JNIEnv* env,

strlcat(buffer, "Neon version : ", sizeof buffer);

family = android_getCpuFamily();
if ((family != ANDROID_CPU_FAMILY_ARM) &&
(family != ANDROID_CPU_FAMILY_X86)) {
strlcat(buffer, "Not an ARM and not an X86 CPU !\n", sizeof buffer);
goto EXIT;
}

features = android_getCpuFeatures();
if (((features & ANDROID_CPU_ARM_FEATURE_ARMv7) == 0) &&
((features & ANDROID_CPU_X86_FEATURE_SSSE3) == 0)) {
Expand Down

0 comments on commit 1cb6518

Please sign in to comment.