Renderscript c style pointer usage performance issue

↘锁芯ラ 提交于 2019-12-04 06:55:55

问题


In render script, I am using bound pointers to iterate over a large image. The problem is in the array access performance.

...
for(int i=0; i < channels; i++) {
    sum += (input[i*input_size]) * mulValue;
}
...

For example, when the input_size is 12288 it takes 1.5 seconds to complete script, but when the input_size is 12280 it takes ~0.5 seconds.

What can cause such a mystery behavior?


回答1:


Understanding the performance implications of what you write in RenderScript (or openCL) is complex.

Just writing it in RendersScript does not guarantee performance. Many times you encounter cache coherence issues when your memory access hop around.

Quite often it is better to structure the code as a series of kernels that process in a cache friendly manner.

Sorry if this is vague. You questing does not have enough details.



来源:https://stackoverflow.com/questions/40452679/renderscript-c-style-pointer-usage-performance-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!