Renderscript c样式指针使用性能问题 [英] Renderscript c style pointer usage performance issue
问题描述
在渲染脚本中,我使用绑定指针迭代大图像。
问题在于数组访问性能。
...
for(int i = 0 ; i< channels; i ++){
sum + =(input [i * input_size])* mulValue;
}
...
例如,当input_size为12288时完成脚本需要1.5秒,但当input_size为12280时需要约0.5秒。
什么会导致这种神秘行为?
了解您在RenderScript(或openCL)中编写的内容的性能影响很复杂。
Just在RendersScript中编写它并不能保证性能。
很多时候,当你的内存访问跳转时,你会遇到缓存一致性问题。
通常最好将代码构造为一系列以缓存友好方式处理的内核。
<如果这很模糊,请抱歉。你的任务没有足够的细节。
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?
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.
这篇关于Renderscript c样式指针使用性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!