136 9. CODE OPTIMIZATION
putational overhead, are responsible for memory address generation and transformation, data
loading and storage, and branch or loop logic. In comparison to the original code version, the
pointer manipulation approach reduces the number of supporting instructions by lowering the
overhead for memory address generation but the core computation remains the same.
Many other efficient C code writing techniques are covered in [1] and the reader is referred
to this reference.
9.5 ARCHITECTURE-SPECIFIC OPTIMIZATIONS
If the performance of a code is not adequately improved by compiler optimization options or
by refactoring, one may resort to using architecture-specific optimization. On ARM processors,
this consists of using specialized hardware capabilities built into the processor.
9.5.1 TARGET ARCHITECTURE
It is important to compile codes for the proper hardware capabilities of the smartphone target.
is subsection is focused on Android targets due to the wide range of target architectures used,
whereas iOS only uses ARMv7 and ARMv8 architectures.
A target architecture can be specified by listing the desired ABIs (Application Binary
Interfaces) in the file build.gradle as indicated below:
ndk {
moduleName "yourLibrary"
abiFilter " armeabi armeabi-v7a mips x86"
ldLibs "log"
cFlags "-O3"
}
is generates native libraries compiled specifically for the targets listed in the abiFilter directive.
For each targeted ABI, the compiler generates a native library which gets included with the
application. By default, all available ABIs will be built by the build system. When the application
is installed, the corresponding library also gets installed.
Architecture-specific optimizations may be included by setting flags and enabling code
sections at compile time. Flags can be set in the build.gradle file by checking the target using the
productFlavors directive as follows:
productFlavors {
armv7 {
ndk {
abiFilter "armeabi-v7a"
cFlags "-mfloat-abi=softfp -mfpu=neon -march=
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.53.5