Renderscript c样式指针使用性能问题 [英] Renderscript c style pointer usage performance issue

查看:206
本文介绍了Renderscript c样式指针使用性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在渲染脚本中,我使用绑定指针迭代大图像。
问题在于数组访问性能。

  ... 
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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆