12 ビット データ (16 ビット データに格納) のバッファがあり、8 ビットに変換する必要があります (4 シフト)
NEON はどのようにこの処理を高速化できますか?
ご協力ありがとうございました
ブラヒム
12 ビット データ (16 ビット データに格納) のバッファがあり、8 ビットに変換する必要があります (4 シフト)
NEON はどのようにこの処理を高速化できますか?
ご協力ありがとうございました
ブラヒム
以下で説明するいくつかのことを自由に仮定しますが、この種のコード (テストされていないため、いくつかの変更が必要になる場合があります) は、単純な非 NEON バージョンと比較して優れたスピードアップを提供するはずです。
#include <arm_neon.h>
#include <stdint.h>
void convert(const restrict *uint16_t input, // the buffer to convert
restrict *uint8_t output, // the buffer in which to store result
int sz) { // their (common) size
/* Assuming the buffer size is a multiple of 8 */
for (int i = 0; i < sz; i += 8) {
// Load a vector of 8 16-bit values:
uint16x8_t v = vld1q_u16(buf+i);
// Shift it by 4 to the right, narrowing it to 8 bit values.
uint8x8_t shifted = vshrn_n_u16(v, 4);
// Store it in output buffer
vst1_u8(output+i, shifted);
}
}
ここで想定したこと:
uint*
-> int*
、*_u8
->*_s8
および*_u16
-> *_s16
) 。最後に、NEON ドキュメントから使用される 2 つのリソース ページ:
お役に立てれば!