【问题标题】:SSE intrinsics compiling MSDN code with GCC error?SSE内在函数编译带有GCC错误的MSDN代码?
【发布时间】:2013-07-07 21:37:40
【问题描述】:

我想知道 Microsofts SSE intrinsics 是否与标准有所不同,因为我尝试使用带有标志 -msse -msse2 -msse3 -msse4 的 GCC 编译此代码

#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;
}

它给了我以下错误:

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'|

在我看来,我需要为__m128i 创建struct,尽管如果其他人知道这个问题可能会有更好的解决方案。

【问题讨论】:

    标签: gcc struct sse intrinsics


    【解决方案1】:

    诸如__m128i 之类的 SSE 类型 的定义在 Microsoft 领域与世界其他地区不同。如果您想编写可移植的 SSE 代码,请坚持所有平台共有的内在函数,并且不要对 SSE 向量类型的定义方式做出任何假设(即将它们视为或多或少不透明的数据类型)。您可以使用适当的 _mm_set_xxx 内在函数来实现您问题中的代码。

    【讨论】:

    • 这是我向微软伸出援手的另一个原因。顺便说一句,他们的土地正在侵蚀。
    • @user2555139:微软的向量扩展比 GNU 少得多,所以你的评论有点奇怪。
    猜你喜欢
    • 2014-04-02
    • 1970-01-01
    • 1970-01-01
    • 2021-06-10
    • 2011-12-29
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    相关资源
    最近更新 更多