1 <html><body><pre>Android NDK CPU Features detection library: 2 ------------------------------------------- 3 4 This NDK provides a small library named "cpufeatures" that can be used at 5 runtime to detect the target device's CPU family and the optional features 6 it supports. 7 8 Usage: 9 ------ 10 11 The library is available as an import module. To use it, you must: 12 13 To use it, you must: 14 15 * List 'cpufeatures' in your list of static library dependencies, as in: 16 17 LOCAL_STATIC_LIBRARIES := cpufeatures 18 19 * At the end of your Android.mk, import the 'android/cpufeatures' module, 20 as in: 21 22 $(call import-module,android/cpufeatures) 23 24 * In your source code, include the header named <cpu-features.h> 25 26 27 Here is a simple example: 28 29 <project-path>/jni/Android.mk: 30 LOCAL_PATH := $(call my-dir) 31 32 include $(CLEAR_VARS) 33 LOCAL_MODULE := <your-module-name> 34 LOCAL_SRC_FILES := <your-source-files> 35 LOCAL_STATIC_LIBRARIES := cpufeatures 36 include $(BUILD_SHARED_LIBRARY) 37 38 $(call import-module,android/cpufeatures) 39 40 41 Features: 42 --------- 43 44 Two functions are provided for now: 45 46 AndroidCpuFamily android_getCpuFamily(); 47 48 Returns the target device's CPU Family as an enum. For now, the only 49 supported family is ANDROID_CPU_FAMILY_ARM. 50 51 52 uint64_t android_getCpuFeatures(); 53 54 Returns the set of optional features supported by the device's CPU. 55 The result is a set of bit-flags, each corresponding to one CPU 56 Family-specific optional feature. 57 58 Currently, only the following flags are defined, for the ARM CPU Family: 59 60 ANDROID_CPU_ARM_FEATURE_ARMv7 61 Indicates that the device's CPU supports the ARMv7-A instruction 62 set as supported by the "armeabi-v7a" abi (see CPU-ARCH-ABIS.html). 63 This corresponds to Thumb-2 and VFPv3-D16 instructions. 64 65 ANDROID_CPU_ARM_FEATURE_VFPv3 66 Indicates that the device's CPU supports the VFPv3 hardware FPU 67 instruction set extension. Due to the definition of 'armeabi-v7a', 68 this will always be the case if ANDROID_CPU_ARM_FEATURE_ARMv7 is 69 returned. 70 71 Note that this corresponds to the minimum profile VFPv3-D16 that 72 _only_ provides 16 hardware FP registers. 73 74 ANDROID_CPU_ARM_FEATURE_NEON 75 Indicates that the device's CPU supports the ARM Advanced SIMD 76 (a.k.a. NEON) vector instruction set extension. Note that ARM 77 mandates that such CPUs also implement VFPv3-D32, which provides 78 32 hardware FP registers (shared with the NEON unit). 79 80 And the following flags for the x86 CPU Family: 81 82 ANDROID_CPU_X86_FEATURE_SSSE3 83 Indicates that the device's CPU supports the SSSE3 instruction 84 extension set. Note that this is unlike SSE3 which is required 85 by the x86 NDK ABI. 86 87 ANDROID_CPU_X86_FEATURE_POPCNT 88 Indicates that the device's CPU supports the POPCNT instruction. 89 90 ANDROID_CPU_X86_FEATURE_MOVBE 91 Indicates that the device's CPU supports the MOVBE instruction. 92 This one is specific to some Intel IA-32 CPUs, like the Atom. 93 94 95 The following function is also defined to return the max number of 96 CPU cores on the target device: 97 98 int android_getCpuCount(void); 99 100 101 Important Note: 102 --------------- 103 104 The cpufeatures library will be updated to support more CPU families and 105 optional features in the future. It is designed to work as-is on all 106 official Android platform versions. 107 108 109 Change History: 110 --------------- 111 112 Please see the comments in $NDK/sources/android/cpufeatures/cpu-features.c 113 for the complete change history for this library. 114 </pre></body></html>