AVX512 - 使用掩码按索引左包装元素

问题描述

简而言之,我正在尝试按索引压缩(左包)64 位整数。 scattercompress 内在函数都不能直接解决这个问题。

假设您在 a 中有 8 个 64 位整数,并且想要左打包这些元素位于从 base_addr 开始的地址处,index 受掩码约束k

int64_t* dst; // memory to store the result
__m512i a = _mm512_loadu_si512 ( arr ); // load data from memory into a
__mmask8 k = _mm512_cmpgt_epi64_mask ( a,_mm512_set1_epi64(6) ); // compare for greater-than
__m512i index = _mm512_set_epi64 ( 14,12,10,8,6,4,2,0 ); // index vector
_mm512_mask_compressstoreu_epi64_by_index ( dst,k,index,a ); // How can I implement this function efficiently?

因此,_mm512_mask_compressstoreu_epi64_by_index 函数应该使用 adst 中的 64 位整数压缩到内存 index 中。写掩码 k 将在 a 中处于活动状态的元素存储到内存中。

这个函数的结果如下:

dst = [10,7,9,0 ...]

元素 10、7 和 9 相应地存储在索引 0、2 和 4 之后。

我尝试过 _mm512_mask_compressstoreu_epi64_mm512_mask_i64scatter_epi64 内在函数,但这些指令以不同的方式保存元素。他们会给你以下结果:

_mm512_mask_compressstoreu_epi64( dst,a ) 产生:dst = [ 10,... ]

_mm512_mask_i64scatter_epi64 ( dst,a,8 ) 产生:dst = [ 0,...]

我想要的是 _mm512_mask_compressstoreu_epi64_by_index( dst,a ) 结果 dst = [10,0 ...]

我该如何解决这个问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)