使用sse的快速紧凑寄存器 [英] fast compact register using sse

查看:195
本文介绍了使用sse的快速紧凑寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用sse _mm_shuffle_epi8来压缩一个128位的寄存器。

I am trying to figure out how to use sse _mm_shuffle_epi8 to compact a 128-bit register.

假设我有一个输入变量

__m128i target

它基本上是8个16位,表示为:

which is basically 8 16-bits, indicated as:

a[0], a[1] ... a[7].  // each slot is 16 bits

我的输出被调用:

__m128i output

大小为8的位向量:

char bit_mask // 8 bits, i-th bit each indicate if
              // the corresponding a[i] should be included

OK,我如何获得最终结果bit_mask和输入目标?

OK, how can I get the final result based on the bit_mask and the input target?

假设我的位元是:

[0 1 1 0 0 0 0 0]

那么我想成为: p>

then I want to result to be:

output = [a1, a2 , ... ]

使用_mm_shuffle_epi8执行此操作的任何已知方法?

Any known way to do this using _mm_shuffle_epi8?

假设我使用查找数组:
_mm_shuffle_epi8 ,mask_lookup [bitvector]);

Assume I use a lookup array: _mm_shuffle_epi8(a, mask_lookup[bitvector]);

如何创建数组?

推荐答案

简单而快速,但需要4KB的表空间:

Simple and very fast, but requires 4KB of table space:

_mm_shuffle_epi8(a, mask_lookup[bitvector]);

其中只需将所有256个可能的shuffle mask存储在由bitvector索引的表中。

where you simply store all 256 possible shuffle masks in a table indexed by the bitvector.

这篇关于使用sse的快速紧凑寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆