【问题标题】:NEON vs Intel SSE - equivalence of certain operationsNEON 与英特尔 SSE - 某些操作的等效性
【发布时间】:2011-11-04 10:01:26
【问题描述】:

我在确定几个英特尔 SSE 操作的 NEON 等效性时遇到了一些麻烦。 NEON 似乎无法一次处理整个 Q 寄存器(128 位值数据类型)。我在 arm_neon.h 标头或 NEON intrinsics reference 中没有找到任何内容。

我想做的是:

// Intel SSE
// shift the entire 128 bit value with 2 bytes to the right; this is done 
// without sign extension by shifting in zeros
__m128i val = _mm_srli_si128(vector_of_8_s16, 2);
// insert the least significant 16 bits of "some_16_bit_val"
// the whole thing in this case, into the selected 16 bit 
// integer of vector "val"(the 16 bit element with index 7 in this case)
val = _mm_insert_epi16(val, some_16_bit_val, 7);

我查看了 NEON 提供的移位操作,但找不到执行上述操作的等效方法(我对 NEON 没有太多经验)。是否有可能做到以上(我想我只是不知道怎么做)? 任何指针都非常感谢。

【问题讨论】:

    标签: c++ c sse simd neon


    【解决方案1】:

    您需要 VEXT 指令。您的示例如下所示:

    int16x8_t val = vextq_s16(vector_of_8_s16, another_vector_s16, 1);
    

    此后,val 的第 0-111 位将包含vector_of_8_s16 的第 16-127 位,val 的第 112-127 位将包含another_vector_s16 的第 0-15 位。

    【讨论】:

    • 我实际上已经以这种方式实现了它。您是否可以提供一个示例,以便我验证我的方法?
    • 删除了我关于 vtbl 和 vtbx 的回答。 vext 是要走的路!
    • @celavek:我提供了一个示例,但验证您的方法的方法是对其进行测试,而不是将其与示例进行比较。它要么有效,要么无效。
    • 完全同意你的看法(不打算比较任何东西)。这是一个糟糕的词选择。而且我认为您的意思是位而不是字节。
    猜你喜欢
    • 2014-10-05
    • 2018-01-04
    • 2013-10-21
    • 2012-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-18
    • 2011-04-29
    相关资源
    最近更新 更多