未声明C++内部函数



我正在学习使用内部函数而不是asm内联。昨天,他们在工作,但我今天总是出错。什么都没改变。

#include <iostream>
#include <intrin.h> // immintrin.h, smmintrin.h ... tried all, never worked
using namespace std;
    int main()
    {
        _m256_zeroupper(); // __mm256_zeroupper(); does not work too
        _mm128 x; // __mm128 x; does not work too
        _mm256 y; // __mm256 y; does not work too
        _m256_zeroupper(); // __mm256_zeroupper();  does not work too
        cout << "Hello world!" << endl;
        return 0;
    }

以下是错误。我尝试了不同内部函数的所有头文件,但错误是相同的。还重新安装了gcc,但没有工作。

我哪里错了?我需要添加什么才能真正声明这些内在变量和函数?

C:indirmeDenemesihello_intrinmain.cpp||In function 'int main()':|
C:indirmeDenemesihello_intrinmain.cpp|8|error: '_mm256_zeroupper' was not declared in this scope|
C:indirmeDenemesihello_intrinmain.cpp|9|error: '_mm128' was not declared in this scope|
C:indirmeDenemesihello_intrinmain.cpp|9|error: expected ';' before 'x'|
C:indirmeDenemesihello_intrinmain.cpp|10|error: '_mm256' was not declared in this scope|
C:indirmeDenemesihello_intrinmain.cpp|10|error: expected ';' before 'y'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|

在64位cpu和64位窗口上使用64位最新版本的gcc。CPU为FX8150。尝试-march=bdver1-mtune=bdver1,它产生了数百个垃圾错误。

所有这些都意味着我的CPU快死了吗?

编辑:其他一些项目正在运行,但我没有更改任何内容。这一定是一个特定于项目的事情。使用代码::块,当我右键单击标题并选择"打开"时,它会给出错误"找不到",但在编译时不会给出任何与此相关的错误,只是intrinsinc命令的错误。工作项目也是如此(它们编译所有内容并工作,但右键单击并单击打开时找不到头文件)。也许其他一些windows服务正在干扰?我不知道,但编译器错误正在消失,而且还会时不时地出现。重新安装代码块也没有解决问题。只有一些项目可以使用内部函数,而其他项目则不能(即使所有项目都有相同的头)

下面的代码也不起作用。

#include <iostream>
#include <immintrin.h>
using namespace std;
int main()
{
    _m256_zeroupper();
    __mm128 x;
    __mm256 y;
    _m256_zeroupper();
    cout << "Hello world!" << endl;
    return 0;
}

有三件事应该使您的代码工作:

  1. 请确保您使用的是-mavx编译标志。

  2. 您的变量应声明为__m256,而不是_mm256

  3. 确保包含immintrin.h

最新更新