Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

Building Android* NDK applications with Intel® Integrated Performance Primitives (Intel® IPP)

$
0
0


Intel® Integrated Performance Primitives (Intel® IPP) provides highly optimized building block functions for image processing, signal processing, vector math and small matrix computation. Several Intel IPP domains contain the hand-tuned functions for Intel® Atom(TM) processor by taking advantage of Intel® Streaming SIMD Extensions (Intel® SSE) instructions. This article gives an introduction on how to add Intel IPP functions into Android NDK applications. Note that Intel IPP provides processor-specific optimization, and only can be linked with native Android C/C++ code.

Getting Intel IPP 

Intel IPP is included in Intel® System Studio  for Android package, which provides comprehensive and integrated tool suite for embedded and mobile developers.  The Intel IPP static non-threaded libraries support the Android* OS, and can be used with Android applications, If you are installing Intel IPP with Intel® System Studio, by default, the IPP libraries can be found at the folder  /system_studio_2015.x.xxx/ipp/lib/ia32_android

Using Intel IPP

1. Adding Intel IPP functions in source

  • Include the Intel IPP header files (ipp.h) in the source files.
  • Call ippInit() before using any other Intel IPP functions. Intel IPP detects the processor features and selects the optimizing code path for the target processors. Before calling any other Intel IPP functions, call ippInit() to initialize the CPU dispatching for Intel IPP.

  • Call Intel IPP functions in your C/C++ source.

2. Including Intel IPP libraries into the Android NDK build files

  • Find Intel libraries required for the application: Intel IPP libraries are categorized into different domains. Each domain has its own library, and some domain libraries depend on other ones. It needs to include all domain libraries and their dependencies into the linkage line. Check the article “Intel IPP Library Dependencies” to learn about the required Intel IPP libraries.
  • Copy the required Intel IPP libraries and headers to your project folder. Note, you only need copy static non-threaded Intel IPP libraries (/ipp/lib/ia32/*.a).
  • Add the Intel IPP libraries to android building script file “jni/Android.mk”:
    Declare each Intel IPP library as the prebuilt library module. For example, if the application uses two Intel IPP libraries "libipps.a" and "libippcore.a", add the following into the file:
               include $(CLEAR_VARS)
               LOCAL_MODULE := ipps
               LOCAL_SRC_FILES := ../ipp/lib/ia32/libipps.a
               include $(PREBUILT_STATIC_LIBRARY)

               include $(CLEAR_VARS)
               LOCAL_MODULE := ippcore
               LOCAL_SRC_FILES := ../ipp/lib/ia32/libippcore.a
               include $(PREBUILT_STATIC_LIBRARY)

Add the header path and Intel IPP libraries into the modules calling Intel IPP functions:

               include $(CLEAR_VARS)
               LOCAL_MODULE := IppAdd
               LOCAL_SRC_FILES := IppAdd.c
               LOCAL_STATIC_LIBRARIES := ipps ippcore
               LOCAL_C_INCLUDES := ./ipp/include
               include $(BUILT_SHARED_LIBRARY)

Building one sample code

A simple example is included below that shows Intel IPP usage in the native Android code. The code uses the Intel IPP ippsAdd_32f() function to add data for two arrays.

To review Intel IPP usage in the code:

  1. Download the sample code and unpack it to your project folder (<projectdir>).
  2. Learn Intel IPP usage in the source files: The "jni/IppAdd.c" file provides the implementation of one native function NativeIppAdd(). The function calls the Intel IPP ippsAdd_32f() function. The "src/com/example/testippadd/ArrayAddActivity.java" file calls the native "NativeIppAdd()" function through JNI.
  3. Check the "jni/Android.mk" file. This file adds the required Intel IPP libraries into the build script. The sample uses the ippsAdd_32f() function, which belongs to the Intel IPP signal processing domain. The function depends on "libipps.a" and "libippcore.a" libraries. The "Android.mk" file creates two prebuilt libraries for them.

You can build the sample code either using the SDK and NDK command tools or using Eclipse* IDE

Build the sample from a command line

>cd <projectdir>><ndkdir>/ndk-build
>cd <projectdir>>android update project -p . -s>ant debug>adb install bin/ArrayAddActivity-debug.apk
  1. Copy the Intel IPP headers and libraries into your project folder (e.g. <projectdir>/ipp).

  2. Run the "ndk-build" script from your project's directory to build the native code

  3. Build the Android package and install the application

Build the sample by Eclipse* IDE

>cd <projectdir>><ndkdir>/ndk-build
  1. Copy the Intel IPP headers and libraries into your project folder (e.g. <projectdir>/ipp).

  2. In Eclipse, click File>> New>> Project...>> Android>> Android Project from Existing Code. In the "Root Directory", select the sample code folder, then click Finish.

  3. Run the 'ndk-build' script from your project's directory to build the native code:

  4. Build the application in the Eclipse IDE and deploy the .apk file.

Summary
This article provides an introduction to Intel IPP usage with native Android applications. Check more information on Intel IPP functions in the Intel IPP manual.

Related Links and Resources

To learn more about Intel tools for the Android developer, visit Intel® Developer Zone for Android.


Viewing all articles
Browse latest Browse all 3384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>