Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining whether Renderscript is running on CPU/GPU & Number of Threads

Tags:

renderscript

I can't seem to find any documentation on how to check if RenderScript is actually parallelizing code. I'd like to know whether the CPU or GPU is being utilized and the number of threads dispatched.

The only thing I've found is this bug report: http://code.google.com/p/android/issues/detail?id=28662

The author mentions that putting rsForEach in the script resulted it it being serialized by pointing to the following debug output:

01-02 00:21:59.960: D/RenderScript(1256): = 0  0x0
01-02 00:21:59.976: D/RenderScript(1256): = 1  0x1

I tried searching for a similar string in LogCat, but I haven't been able to find a match.

Any thoughts?

Update: Actually I seem to have figured it out. It just seems that my LogCat foo isn't as good as it should be. I filtered the debug output by my application information and found a line like this:

02-26 22:30:05.657: V/RenderScript(26113): rsContextCreate dev=0x5cec0458
02-26 22:30:05.735: V/RenderScript(26113): 0x5d9f63b8 Launching thread(s), CPUs 2
like image 298
icebreeze Avatar asked Feb 27 '13 06:02

icebreeze


2 Answers

This will only tell you how many CPUs could be used. This will not indicate how many threads or which processor is being used. By design RS avoid exposing this information

In general RS will use all the available CPU cores unless you call a "serial" function such as the rsg* or time functions. As to what criteria will result in a script being punted from the GPU to CPU, this will vary depending on the abilities of each vendors GPU.

The bug you referenced has been fixed in 4.1

like image 199
R. Jason Sams Avatar answered Sep 21 '22 06:09

R. Jason Sams


I came across the same issue, when I was working with RS. I used Nexus 5 for my testing. I found that initial launch of RS utilized CPU instead of using GPU, this is verified using Trepn 5.0s application. Later I found that Nexus-5 GPU doesnt support double precision (Link to Adreno 330), so by default it ports it onto CPU. To overcome this I used #pragma rs_fp_relaxed top of my rs file along with header declarations.

So if you strictly want to port it onto GPU then it may be best way to find out your mobile GPU specs and try above trick and measure GPU utilization using Trepn 5.0s or equivalent application. As of now RS doesnt expose thread level details but during the implementation we can utilize the x and y arguments of our root - Kernel as thread indexes.

like image 30
Kaliuday Avatar answered Sep 19 '22 06:09

Kaliuday