Reputation: 19
the appliction abort when i add LOCAL_ARM_NEON := true
in android.mk, even without any neon instructions. some words like "-mfpu=neon" alse cause abort.
my phone is motorola android2.2
is my configuration in Android NDK not correct? or my phone arm can not support neon instructions? i need to run neon instructions on my phone.
help me!!!thanks!!!
ps: application.mk:
APP_STL := gnustl_static
APP_ABI := armeabi-v7a
APP_CPPFLAGS += -fexceptions
APP_MODULES := AudioEngine
android.mk:
CC = $(BASE_PATH)/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-gcc
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_NEON := true
LOCAL_MODULE := AudioEngine
LOCAL_SRC_FILES := AudioEngine.cpp Effecter.cpp SoundTouch.cpp TDStretch.cpp RateTransposer.cpp AAFilter.cpp BPMDetect.cpp \
FIFOSampleBuffer.cpp FIRFilter.cpp mmx_optimized.cpp PeakFinder.cpp sse_optimized.cpp cpu_detect_x86.cpp fft.s\
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
Upvotes: 1
Views: 1281
Reputation: 1788
The following approach is used in the the official Hello-Neon-Example:
Android.mk:
# inside a module:
LOCAL_SRC_FILES := helloneon.c
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_CFLAGS := -DHAVE_NEON=1
LOCAL_SRC_FILES += helloneon-intrinsics.c.neon
endif
#...
Some C/C++ source file:
/* HAVE_NEON is defined in Android.mk */
#ifdef HAVE_NEON
callNeonFunc();
#else
callStandardFunc();
#endif
Upvotes: 0
Reputation: 250
I use a second small .so library that I've written to check if a CPU supports NEON at all. After checking, I decide in java which version of my library I have to load, one built with full NEON support, one without NEON support at all: This is the code, grabbed from the NDK documentation:
JNIEXPORT JNICALL int Java_xypackagename_base_detectCPU_isNeon( JNIEnv* _env, jobject thiz )
{
uint64_t features;
if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM)
{
__android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor is NOT an ARM processor" );
return 0;
}
__android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor is an ARM processor" );
features = android_getCpuFeatures();
__android_log_print( ANDROID_LOG_INFO, "detectCPU", "Processor features: %u", (unsigned int)features );
if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7) == 0)
{
__android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor is NOT an ARM v7" );
return 0;
}
__android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor is an ARM v7" );
if ((features & ANDROID_CPU_ARM_FEATURE_NEON) == 0)
{
__android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor has NO NEON support" );
return 0;
}
__android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor has NEON support" );
return 1;
}
Upvotes: 1