Configuring OpenCl over Android Platform

1k views Asked by At

How to configure OpenCL environment for android platform either in windows or linux using any IDE? I want to make use of GPU using OpenCL for smartphone.

2

There are 2 answers

0
Robert Wang On

Basically, to develop OpenCL program/applications for Android, the followings are what you need:

  1. Android SDK, Android NDK
  2. Cygwin (if under windows)
  3. OpenCL header file (could be downloaded from Khronos website)
  4. OpenCL lib file. For different chip vendor, this library is located under different path. See here for details.

  5. Develop OpenCL program in C/C++. compile with ndk-build to a shared library.

  6. Develop your application using Android Studio. Use JNI to call your OpenCL-related functions from the native shared library.
1
sharpneli On

Android does not have official support for OpenCL and Google is openly hostile towards it, going to far as to remove unofficial drivers http://www.anandtech.com/show/7191/android-43-update-for-nexus-10-and-4-removes-unofficial-opencl-drivers . Even if your hardware still has OpenCL drivers you cannot distribute the app in Google Play, so it's practically useless.

For Android you are better off using Google's Renderscript (the reason why they hate OpenCL, they want their solution to be used) http://developer.android.com/guide/topics/renderscript/compute.html

You can write certain algorithms easily using Renderscript. It's basically like OpenCL but it has no concept of local memory and accessing thread id is not supported. But for things like simple image processing or particle simulation it's perfect.

If you must use OpenCL for some reason and your target hardware supports it just use adb pull to get the libOpenCL.so out of the phone, copy it to the ndk lib directory, and also place OpenCL include headers to the include path and you're good to go.