Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在SSE中进行比较时的奇怪行为_C++_Sse_Simd - Fatal编程技术网

C++ 在SSE中进行比较时的奇怪行为

C++ 在SSE中进行比较时的奇怪行为,c++,sse,simd,C++,Sse,Simd,我的代码中没有错误。我尝试将无符号字符值的缓冲区与常量进行比较。然后根据比较结果存储1或0。以下是我的代码(在结构中): 但我的比较是错误的: 214 100 199 203 232 50 85 195 70 141 121 160 93 130 242 233 0 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0 我真的不知道错误在哪里 SHOW宏是: #define SHOW(t, r)

我的代码中没有错误。我尝试将无符号字符值的缓冲区与常量进行比较。然后根据比较结果存储1或0。以下是我的代码(在结构中):

但我的比较是错误的:

214 100 199 203 232  50  85 195  70 141 121 160  93 130 242 233
  0   0   0   0   0   0   0   0   0   0 255   0   0   0   0   0
我真的不知道错误在哪里

SHOW
宏是:

#define SHOW(t, r)                  \
  _mm_storeu_si128((__m128i*)t, r); \
  printf("%3d", (int32)t[0]);       \
  for (int32 k = 1; k < 16; ++k)    \
    printf(" %3d", (int32)t[k]);    \
  printf("\n")
#定义显示(t,r)\
_mm_-storeu-si128((_-m128i*)t,r\
printf(“%3d”,(int32)t[0])\
对于(int32 k=1;k<16;++k)\
printf(“%3d”,(int32)t[k])\
printf(“\n”)

您正在将
s
数组中的元素与
数组进行比较

value
数组中的所有值都是100。 您的
s
数组中混合了多个值

但是,
\u mm\u cmpgt\u epi8
对有符号值起作用,因为这些是字节,所以它考虑从-128到+127的值

因此,唯一可能大于100的值是101到127范围内的值

因为在这个范围(121)中只有1个值,这是唯一一个设置了掩码的值


要看到这一点,请更改
uint8t[16]
int8t[16]
您应该会得到更预期的结果。

您正在将
s
数组中的元素与
数组进行比较

value
数组中的所有值都是100。 您的
s
数组中混合了多个值

但是,
\u mm\u cmpgt\u epi8
对有符号值起作用,因为这些是字节,所以它考虑从-128到+127的值

因此,唯一可能大于100的值是101到127范围内的值

因为在这个范围(121)中只有1个值,这是唯一一个设置了掩码的值


要看到这一点,请更改
uint8t[16]
int8t[16]
您应该会得到更期望的结果。

对我来说;最明显的错误是您没有使用std::vector(或std::array),因为这意味着您不能;从功能上看;知道传递给它的内存是否有效;最明显的错误是您没有使用std::vector(或std::array),因为这意味着您不能;从功能上看;知道传递给它的内存是否有效。查看是否正确。我发现这个问题解释了如何为感兴趣的人比较未签名字符。谢谢这是正确的。我发现这个问题解释了如何为感兴趣的人比较未签名字符。谢谢
214 100 199 203 232  50  85 195  70 141 121 160  93 130 242 233
  0   0   0   0   0   0   0   0   0   0 255   0   0   0   0   0
#define SHOW(t, r)                  \
  _mm_storeu_si128((__m128i*)t, r); \
  printf("%3d", (int32)t[0]);       \
  for (int32 k = 1; k < 16; ++k)    \
    printf(" %3d", (int32)t[k]);    \
  printf("\n")