在 SIMD 中矢量化直方图的方法? [英] Methods to vectorise histogram in SIMD?
本文介绍了在 SIMD 中矢量化直方图的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 Neon 中实现直方图.可以矢量化吗?
I am trying to implement histogram in Neon. Is it possible to vectorise ?
推荐答案
不幸的是,直方图几乎不可能矢量化.
Histogramming is almost impossible to vectorize, unfortunately.
您可能可以稍微优化标量代码 - 一个常见的技巧是使用两个直方图,然后在最后组合它们.这允许您重叠加载/增量/存储,从而隐藏一些串行依赖项和相关的延迟.伪代码:
You can probably optimise the scalar code somewhat however - a common trick is to use two histograms and then combine them at the end. This allows you to overlap loads/increments/stores and thereby bury some of the serial dependencies and associated latencies. Pseudo code:
init histogram 1 to all 0s
init histogram 2 to all 0s
loop
get input value 1
get input value 2
load count for value 1 from histogram 1
load count for value 2 from histogram 2
increment count for histogram 1
increment count for histogram 2
store count for value 1 to histogram 1
store count for value 2 to histogram 2
until done
combine histogram 1 and histogram 2
这篇关于在 SIMD 中矢量化直方图的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文