17年参与物理层研发时,发现X86体系一个大的困难是与FPGA交换数据,最后要转换为大端字节序。
时间的开销是相当可观的。
Intel的FlexRan里面,也有许多相关的代码,例如:
// Reverse in byte (used in scramble)
static inline uint64_t reverse_in_byte(const uint64_t x)
{
const auto bytes = _mm512_movm_epi8(x);
const auto mask = _mm512_set_epi8 (8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,
8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,
8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,
8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7);
const auto rev_bytes = _mm512_shuffle_epi8(bytes, mask);
return _mm512_movepi8_mask (rev_bytes);
}
所以,花一些时间,学习多媒体指令集。将一些相关的信息放在这里
1。 大小端字节转换
Efficient Algorithm for Bit Reversal (from MSB->LSB to LSB->MSB) in C - Stack Overflow
2。 epi8这类尾注的含义;
这一篇是我最喜欢的。这位同仁,喜欢研究最基本的含义。
What are the names and meanings of the intrinsic vector element types, like epi64x or pi32?
3。 AVX-512指令_mm512_shuffle_epi8分析