Ram*_*sow 1 java-native-interface android neon
我在Android JNI上使用Neon实现了一个算法.当我想要将向量添加到一起时,我注意到有两种类型的方法,我无法发现差异.
// pairwise addition
int8x8_t vpadd_s8(int8x8_t a, int8x8_t b); // VPADD.I8 d0,d0,d0
// addition
int8x8_t vadd_s8(int8x8_t a, int8x8_t b); // VADD.I8 d0,d0,d0
Run Code Online (Sandbox Code Playgroud)
第二个做你期望的.它取a中的ith int8并将其添加到b中的ith int8.为什么这两种方法?
ARM的信息中心提供了很好的信息.引用是针对汇编指令,但名称与内在函数非常相似.虽然如果你打算使用NEON,你可以通过直接跳到装配来获得更好的性能.写入比使用内在函数更容易.
总而言之,成对加法在同一向量中添加元素对,然后将结果连接成单个向量.插图(我使用4元素矢量以便于绘图):
vector 'a' vector 'b'
+-+-+-+-+ +-+-+-+-+
|0|1|2|3| |4|5|6|7|
+-+-+-+-+ +-+-+-+-+
\+/ \+/ \+/ \+/
1 5 9 13
\ \ / /
+-+-+-+--+
|1|5|9|13| result
+-+-+-+--+
Run Code Online (Sandbox Code Playgroud)
这与常规加法指令不同,后者添加了两个向量的相应元素,给出了结果
+-+-+-+--+
|4|6|8|10|
+-+-+-+--+
Run Code Online (Sandbox Code Playgroud)
对于a与b在上述的图.
| 归档时间: |
|
| 查看次数: |
2162 次 |
| 最近记录: |