SSE内在函数编译带有GCC错误的MSDN代码? [英] SSE intrinsics compiling MSDN code with GCC error?

查看:229
本文介绍了SSE内在函数编译带有GCC错误的MSDN代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否微软SSE内部函数与标准有点不同,因为我试着用GCC编译这段代码,标记为 -msse -msse2 -msse3 -msse4

  #include< stdio.h> 
#include< smmintrin.h>

int main()
{
__m128i a,b;

a.m128i_u64 [0] = 0x000000000000000;
b.m128i_u64 [0] = 0xFFFFFFFFFFFFFFF;

a.m128i_u64 [1] = 0x000000000000000;
b.m128i_u64 [1] = 0x000000000000000;

int res1 = _mm_testnzc_si128(a,b);

a.m128i_u64 [0] = 0x000000000000001;

int res2 = _mm_testnzc_si128(a,b);
$ b printf_s(第一个结果应该是0:%d \ n第二个结果应该是1:%d \ n,
res1,res2);

返回0;
}

,它给了我以下错误:

  sse_test_not_zero.c ||函数'main':| 
sse_test_not_zero.c | 8 | error:成员'm128i_u64'的请求不是结构或联合|
sse_test_not_zero.c | 9 | error:成员'm128i_u64'的请求不是结构或联合的东西|
sse_test_not_zero.c | 9 |警告:整数常量对于'long'类型来说太大|
sse_test_not_zero.c | 11 | error:成员'm128i_u64'的请求不是结构或联合的东西|
sse_test_not_zero.c | 12 | error:成员'm128i_u64'的请求不是结构或联合的东西|
sse_test_not_zero.c | 16 | error:成员'm128i_u64'的请求不是结构或联合的东西|
sse_test_not_zero.c | 20 |警告:函数'printf_s'的隐式声明|

在我看来,我需要创建 struct for __ m128i 尽管如果别人知道这个问题可能会有更好的解决方案。 $ c>在微软的土地上与其他地区不同。如果你想编写可移植的SSE代码,那么坚持使用所有平台通用的内在函数,并且不要对SSE矢量类型是如何定义的(即将它们视为或多或少的不透明数据类型)做出任何假设。您可以使用适当的 _mm_set_xxx intrinsics在您的问题中实现代码。


I'm wondering if Microsofts SSE intrinsics are a little different than the norm because I tried compiling this code with GCC with flags -msse -msse2 -msse3 -msse4

#include <stdio.h>
#include <smmintrin.h>

int main ()
{
    __m128i a, b;

    a.m128i_u64[0] = 0x000000000000000;
    b.m128i_u64[0] = 0xFFFFFFFFFFFFFFF;

    a.m128i_u64[1] = 0x000000000000000;
    b.m128i_u64[1] = 0x000000000000000;

    int res1 = _mm_testnzc_si128(a, b);

    a.m128i_u64[0] = 0x000000000000001;

    int res2 = _mm_testnzc_si128(a, b);

    printf_s("First result should be 0: %d\nSecond result should be 1: %d\n",
                res1, res2);

    return 0;
}

and it gave me the following errors:

sse_test_not_zero.c||In function 'main':|
sse_test_not_zero.c|8|error: request for member 'm128i_u64' in something not a structure or union|
sse_test_not_zero.c|9|error: request for member 'm128i_u64' in something not a structure or union|
sse_test_not_zero.c|9|warning: integer constant is too large for 'long' type|
sse_test_not_zero.c|11|error: request for member 'm128i_u64' in something not a structure or union|
sse_test_not_zero.c|12|error: request for member 'm128i_u64' in something not a structure or union|
sse_test_not_zero.c|16|error: request for member 'm128i_u64' in something not a structure or union|
sse_test_not_zero.c|20|warning: implicit declaration of function 'printf_s'|

It seems to me that I need to create struct for __m128i although there might be a better solution to this problem if someone else knows of one.

解决方案

The definition of SSE types such as __m128i is different in Microsoft-land than in the rest of the world. If you want to write portable SSE code then stick with the intrinsics that are common to all platforms and don't make any assumptions about how the SSE vector types are defined (i.e. treat them as more-or-less opaque data types). You can implement the code in your question just using appropriate _mm_set_xxx intrinsics.

这篇关于SSE内在函数编译带有GCC错误的MSDN代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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