(9) CPU features

Source: Internet
Author: User

------

For English documents, see documentation.html of android-ndk-r5b.

Part of Android Native Development Kit (ndk)

See http://developer.android.com/sdk/ndk/ (Agent required)

Translation is personal opinion only

-----------------

 

Android ndk CPU features detection Library:

 

Android ndk CPU Feature Detection Library:

-------------------------------------------

 

This ndk provides a small library named "cpufeatures" that can be used at runtime to detect the target device's CPU family and the optional features it supports.

 

Ndk provides a small library named cpufeatures, which can be used to detect the CPU family of the target device and its optional features at runtime.

 

Usage:

 

Usage:

------

 

The library is available as an import module. to use it, you must:

 

This library is available as an import module. To use it, you must:

 

To use it, you must:

 

To use it, you must:

 

* List 'cpufeatures 'in your list of static library dependencies, as in:

 

* List cpufeatures in your static library dependency list, as shown in the following figure:

 

Local_static_libraries: = cpufeatures

 

* At the end of your android. mk, import the 'android/cpufeatures 'module, as in:

 

* At the end of your android. mk, import the android/cpufeatures module, as shown in the following figure:

 

$ (Call import-module, Android/cpufeatures)

 

* In your source code, include the header named <cpu-features.h>

 

* Include the header file named <cpu-features.h> in your source code

 

Here is a simple example:

 

Here is a simple example:

 

<Project-path>/JNI/Android. mk:

Local_path: = $ (call my-DIR)

 

Include $ (clear_vars)

Local_module: = <your-module-Name>

Local_src_files: = <your-source-files>

Local_static_libraries: = cpufeatures

Include $ (build_shared_library)

 

$ (Call import-module, Android/cpufeatures)

 

 

Features:

 

Features:

---------

 

Two functions are provided for now:

 

Two functions are provided:

 

Androidcpufamily android_getcpufamily ();

 

Returns the target device's CPU family as an enum. For now, the only supported family is android_cpu_family_arm.

 

Return the CPU family of the target device with an enumerated value. Currently, the only supported family is android_cpu_family_arm.

 

Uint64_t android_getcpufeatures ();

 

Returns the set of optional features supported by the device's CPU. The result is a set of bit-flags, each corresponding to one CPU family-specific optional feature.

 

Returns the optional features supported by the CPU. The structure is a set of single-digit flags, each of which corresponds to a specific feature of the CPU family.

 

Currently, only the following flags are defined, for the arm cpu family:

 

Currently, only the following labels are defined for the arm cpu family:

 

Android_cpu_arm_feature_armv7

Indicates that the device's CPU supports the ARMv7-A instruction set as supported by the "armeabi-v7a" Abi (see CPU-ARCH-ABIS.html). This corresponds to thumb-2 and VFPv3-D16 instructions.

 

Android_cpu_arm_feature_armv7

Indicates that the CPU of the device supports the ARMv7-A instruction set, which consists of the abi of the armeabi-v7a (Note: memory ). It corresponds to thumb-2 and VFPv3-D16 instructions.

 

 

Android_cpu_arm_feature_vfpv3

Indicates that the device's CPU supports the vfpv3 hardware FPU Instruction Set extension. Due to the definition of 'armeabi-v7a ', this will always be the case if there is returned.

 

Android_cpu_arm_feature_vfpv3

It is pointed out that the CPU of the device supports vfpv3 hardware FPU (Note: FPU is short for floating point operation units) Instruction Set extension. Because of the definition of the armeabi-v7a, it will always return android_cpu_arm_feature_armv7 (Note: it may mean that it will always return with android_cpu_arm_feature_armv7 ).

 

Note that this corresponds to the minimum profile VFPv3-D16 that _ only _ provides 16 hardware FP registers.

 

Note that it corresponds to a minimum VFPv3-D16 that provides only 16 hardware floating point registers.

 

Android_cpu_arm_feature_neon

Indicates that the device's CPU supports the arm advanced SIMD (a.k. a. neon) vector Instruction Set extension. note that arm mandates that such CPUs also implement VFPv3-D32, which provides 32 hardware FP registers (shared with the neon unit ).

 

Android_cpu_arm_feature_neon

It is pointed out that the CPU of the device supports arm advanced SIMD (that is, neon) (Note: neon technology is an arm SIMD extension command for hardware acceleration of multimedia processing) vector Instruction Set extension. Note that arm-authorized CPUs also implement VFPv3-D32 that provides 32 hardware floating point registers (shared with neon units ).

 

 

Important Note:

 

Important Notes:

---------------

 

The cpufeatures library will be updated to support more CPU families and optional features in the future. It is designed to work as-is on all official Android platform versions.

 

The cpufeatures library will be updated to support more CPU families and optional features in the future. It is designed to work as is on all official Android platforms.

 

Change history:

 

Modification history:

---------------

 

Please see the comments in $ ndk/sources/Android/cpufeatures/cpu-features.c for the complete change history for this library.

 

See comments in $ ndk/sources/Android/cpufeatures/cpu-features.c to get the complete modification history for this library. (Note: it is estimated that the person who writes the document is too lazy ...)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.