16

I am now programming on Android and I wonder whether we can use GPGPU for Android now? I once heard that Renderscript can potentially execute on GPGPU in the future. But I wonder whether it is possible for us to programming on GPGPU now? And if it is possible for me to program on the Android GPGPU, where can I find some tutorials or sample programs? Thank you for your help and suggestions.

Up till now I know that the OpenGL ES library was now accelerated use GPU, but I want to use the GPU for computing. What I want to do is to accelerate computing so that I hope to use some libraries of APIs such as OpenCL.

Timothy
  • 469
  • 1
  • 5
  • 19
  • But I saw from the website http://developer.android.com and it did not tell me Renderscript is now able to be used on GPU. Do you mean that OpenGL ES is now able to be used for computing? I will try it. Thank you. @StephanBranczyk – Timothy Sep 09 '12 at 06:16
  • Yes and I am asking about the GPGPU. So I should try OpenCL instead of OpenGL. But is there any OpenCL libraries for Android, such as OpenCL ES? Thank you. @StephanBranczyk – Timothy Sep 09 '12 at 06:24
  • You should probably accept Morrison Chang's answer instead of the previous one (assuming StackOverflows' UI allows you to do that). The goal of StackOverflow is to make itself useful for people googling the answer, and marking an answer that really didn't answer the question, you meant to ask, doesn't serve that purpose. – Stephan Branczyk Sep 19 '12 at 19:51
  • Well, thank you for your suggestion, @StephanBranczyk I have not been online for some days because I was occupied doing some other work. Now I am trying to use OpenGL ES 2.0 in my work and I hope to finish a prototype first. And I also heard that GL ES can use GPU in programming, too. I am now trying it. – Timothy Sep 24 '12 at 00:57
  • see my answer http://stackoverflow.com/questions/16807349/live-camera-streaming-in-android – Chintan Rathod Jun 07 '13 at 11:40

4 Answers4

9

2021-April Update

Google has announced deprecation of the RenderScript API in favor of Vulkan with Android 12.

The option for manufacturers to include the Vulkan API was made available in Android 7.0 Compatibility Definition Document - 3.3.1.1. Graphic Libraries.

Original Answer

Actually Renderscript Compute doesn't use the GPU at this time, but is designed for it

From Romain Guy who works on the Android platform:

  • Renderscript Compute is currently CPU bound but with the for_each construct it will take advantage of multiple cores immediately
  • Renderscript Compute was designed to run on the GPU and/or the CPU
  • Renderscript Compute avoids having to write JNI code and gives you architecture independent, high performance results
  • Renderscript Compute can, as of Android 4.1, benefit from SIMD optimizations (NEON on ARM)

https://groups.google.com/d/msg/android-developers/m194NFf_ZqA/Whq4qWisv5MJ

Morrison Chang
  • 11,691
  • 3
  • 41
  • 77
  • Thank you and I am now trying to use it. I do not know whether Renderscript will meet my need yet, but I will try it. I am really confused because many people told me it works while other told me it does not. – Timothy Sep 11 '12 at 13:57
  • Its only available on 3.0 and above devices. You still didn't explain what your are trying to do (image processing, graphics computation, other). – Morrison Chang Sep 11 '12 at 14:14
  • Renderscript is lack of documentation. But I heard in Nexus 4 and Nexus 10, RenderScript is using GPU to accelerate the computation. And my question is if you want to use GPGPU, why you should invest on RenderScript? It is only for Android. OpenCL is the direction but not really ready on Android and IOS6. OpenGLES 2.0 is the good candidate for your use. – swcai Jan 05 '13 at 01:59
  • If you know OpenGL ES 2.0 do it there, but if you don't want to think about vertex arrays, textures and the shader pipeline, Renderscript simplifies the entry points for a 'average' programmer to use the CPU/GPU. Compared with OpenCL, Renderscript is simpler. How many lines of code does it take to setup a OpenCL compute kernel? I agree though on the lack of documentation and the Android only nature is holding it back. – Morrison Chang Jan 05 '13 at 03:40
3

yes , it is possible .

you can use either renderscript or opengGL ES 2.0 .

renderscript is available on android 3.0 and above , and openGL ES 2.0 is available on about 95% of the devices.

android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • So I can use renderscript to program on GPU now, just as CUDA on PCs? Thank you and I will try to learn renderscript. – Timothy Sep 09 '12 at 06:09
  • good luck . there are also some videos and tutorials about it , but i think they are not enough . wish there was much more info in order for developers to create amazing stuff. – android developer Sep 09 '12 at 07:16
3

As of Android 4.2, Renderscript can involve GPU in computations (in certain cases). More information here: http://android-developers.blogspot.com/2013/01/evolution-of-renderscript-performance.html

As I understand, ScriptIntrinsic subclasses are well-optimized to run on GPU on compatible hardware (for example, Nexus10 with Mali T604). Documentation: http://developer.android.com/reference/android/renderscript/ScriptIntrinsic.html

Of course you can decide to use OpenCL, but Renderscript is guaranteed (by Google, being a part of Android itself) to be running even on hardware which doesn't support GPGPU computation and will use any other available acceleration means supported by hardware it is running on.

keaukraine
  • 5,315
  • 29
  • 54
1

There are several options: You can use OpenGL ES 2.0, which is supported by almost all devices but has limited functionality for GPGPU. You can use OpenGL ES 3.0, with which you can do much more in terms of GPU processing. Or you can use RenderScript, but this is platform-specific and furthermore does not give you any influence on whether your algorithms run on the GPU or the CPU. A summary about this topic can be found in this master's thesis: Parallel Computing for Digital Signal Processing on Mobile Device GPUs.

You should also check out ogles_gpgpu, which allows GPGPU via OpenGL ES 2.0 on Android and iOS.

IsaacKleiner
  • 425
  • 2
  • 13