Search code examples
androidopenclgpu

Opencl integration with Android


I have searched a lot on google but I am unable to find a good documentation about integrating OpenCl with Android. I referred this link: https://aplacetogeek.wordpress.com/android-with-opencl-tutorial/

But this seems incomplete. Is anyone aware of how to go about doing things with OpenCl in Android? Also, example working code if any is also appreciated. I want to learn about it.


Solution

  • The similar questions have been asked before, I suggest you read the following pages first:

    How to use OpenCL on Android?

    Does Android support OpenCL?

    Basically, the following things you need to be aware:

    1. OpenCL on Android is not officially support by Google. Therefore, you may expect to see the OpenCL not supported on some Android devices. Though, so far, most of the flagship devices have the OpenCL support, such as devices with Qualcomm/Samsung chipsets (except Google Nexus devices, but there is workaround for some Nexus devices, please google online).

    2. If you clearly know your app will run only on certain devices, which support OpenCL, you can go ahead to do it. The OpenCL on Qualcomm and Samsung chipsets is pretty stable right now, and the compiler has been optimized for quite a few years; therefore, you can expect some good performance out of those devices.

    3. Development steps: 1) develop C/C++ OpenCL code and compile them using NDK. 2) Write JNI interface for you Android app. 3) Write your Android app, calling the JNI interface you wrote. Then you are done. Nothing special here, you can even debug your OpenCL kernel code on your desktop GPU. Most of the kernel code should work well from desktop to the Android environment, except for some limitations on the mobile devices, such as limited extensions and fewer resources.

    4. To optimize the performance, be sure that you check out the profilers provided by the chip vendors and the optimization guide from the developer network. For example, the Snapdragon Profiler contains the GPU profiling tools; Mali also has offline CL kernel compiler which provides some internal information such as register usage and so on.