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

Using Intel® Integrated Performance Primitives with Android* OS

$
0
0

This tutorial shows how to set up an Android* OS application using Intel® IPP.  This library provides a wide variety of functions so that you can focus on developing your application, not  processor-specific details.  They are a common interface to implementations tuned for Intel processors, including Intel® Atom™, Core™, and Xeon™, though they can be used on any processor supporting Intel® Streaming SIMD Extensions 2 (Intel® SSE2) or newer instruction sets.  The goal of this tutorial is to walk through setting up a very simple example to help you get started with using Intel® IPP in the Beacon Mountain Development Environment for Android*.

A preview of Intel® IPP functionality can be found in Beacon Mountain.  This is a package combining key components for developing Android* software.  It is suitable for general Android* development but bundles additional tools such as Intel® IPP, Intel® Threading Building Blocks (TBB),  and Intel® Graphics Performance Analyzers (GPA) along with prerequisites like Android* NDK for a streamlined start to mobile application development with the performance and power advantages of this toolset.  After you have gotten the "hello world" application from this article working it is very simple to switch to the full range of functions in the IPP library.

The steps to get started are outlined below:

1. Start Eclipse

Click on the "Eclipse for Android ADT" icon to start the development environment. 

Android* ADT Shortcut

2. Enable the Android* NDK

IPP is accessed via the Android* Native Development Kit (NDK).  That is, IPP is called via C/C++ (much like in Windows*, Linux*, and OSX*), not directly from Java.  Native development is well supported in the Eclipse environment, but you must make sure that the NDK is available and Eclipse is set up with its location.  The place to do this can be found in the "Window" menu under "Preferences".

Set NDK location

If it is not filled in already, add the NDK install location.  Below is the Beacon Mountain default.

Set NDK location 2

3. Create the HelloIPP project

The next step is to create a new HelloIPP project.  Names are case sensitive.  To match the code in this example the names should be filled out as below:

Create HelloIPP project

The activity is also named HelloIPP, so make sure this is also created with the correct name and cases.

Create HelloIPP Project 2

4. Add native support to the HelloIPP project

Even though the Eclipse environment itself was set up to enable NDK programming in step 2, native support must be added to the project.  You can find the option to do this by right-clicking the HelloIPP project in the Eclipse Package Explorer, then clicking 'Android Tools->Add Native Support'.  This will automatically make all of the changes to the project to allow programming Java Native Interface (JNI) functions in C/C++. 

Add native support to project

5. Copy files to the Eclipse* workspace

Now you can copy the example files and IPP preview to the HelloIPP project jni folder in your Eclipse workspace.  Delete the autogenerated contents of this directory first.  Files are copied from two places: 1) the example source (below) and 2) the Beacon Mountain IPP directory (default c:/Intel/BeaconMountain/IPP).  

Source code for the HelloIPP example is here: helloippexamplecode.zip

Workspace JNI contents

The main HelloIPP.java file should also be copied to workspace/HelloIPP/src/intel/example/HelloIPP.  This will replace the autogenerated file already in this directory.

6. Run the application

Now you can start the application.  For best results run on an Android Virtual Device (AVD) emulator using the Intel Atom (x86) CPU/ABI or an Android* device based on Intel hardware.  You should see something like the output below. 

Android emulator view

The output is the major and minor version numbers as returned from the IPP ippGetLibVersion function. 

 

How to switch from the Beacon Mountain Intel® IPP preview to the full range of functions in the IPP library 

 

The 32 bit non-threaded static Linux* functions may be used in Android* applications.  If you have a license for Intel® IPP for Linux*, copy the static library files (.a extension) and include (.h) files from a Linux installation to your host machine.   These can then be added to the JNI folder in your Eclipse* project workspace instead of the preview files, as below. 

Workspace JNI contents with IPP

Note: you do not need to add all library and include files, only what your project will use.  If a domain include file is not needed simply comment it out in ipp.h.

After successful compilation with the files from IPP for Linux*, you should see the same output as from building with the preview.

Summary

This was a quick introduction to show how to get started with using IPP for Android* applications.  This simple beginning has the ingredients you’ll need to access the performance and power advantages of IPP functions in your own code.  Now that all of the pieces are there to call one function you can easily expand to the rest of the functions in the IPP preview and the broad range in the IPP library. 


Viewing all articles
Browse latest Browse all 183

Trending Articles



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