• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html><body><pre>Android NDK CPU Features detection library:
2-------------------------------------------
3
4This NDK provides a small library named "cpufeatures" that can be used at
5runtime to detect the target device's CPU family and the optional features
6it supports.
7
8Usage:
9------
10
11The library is available as an import module. To use it, you must:
12
13To 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 &lt;cpu-features.h&gt;
25
26
27Here is a simple example:
28
29&lt;project-path&gt;/jni/Android.mk:
30    LOCAL_PATH := $(call my-dir)
31
32    include $(CLEAR_VARS)
33    LOCAL_MODULE := &lt;your-module-name&gt;
34    LOCAL_SRC_FILES := &lt;your-source-files&gt;
35    LOCAL_STATIC_LIBRARIES := cpufeatures
36    include $(BUILD_SHARED_LIBRARY)
37
38    $(call import-module,android/cpufeatures)
39
40
41Features:
42---------
43
44Two functions are provided for now:
45
46   AndroidCpuFamily   android_getCpuFamily();
47
48Returns the target device's CPU Family as an enum. For now, the only
49supported family is ANDROID_CPU_FAMILY_ARM.
50
51
52   uint64_t   android_getCpuFeatures();
53
54Returns the set of optional features supported by the device's CPU.
55The result is a set of bit-flags, each corresponding to one CPU
56Family-specific optional feature.
57
58Currently, 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
80And 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
95The following function is also defined to return the max number of
96CPU cores on the target device:
97
98    int  android_getCpuCount(void);
99
100
101Important Note:
102---------------
103
104The cpufeatures library will be updated to support more CPU families and
105optional features in the future. It is designed to work as-is on all
106official Android platform versions.
107
108
109Change History:
110---------------
111
112Please see the comments in $NDK/sources/android/cpufeatures/cpu-features.c
113for the complete change history for this library.
114</pre></body></html>