[英]C++ Intrinsic not declared
我正在学习使用内在函数而不是 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:\indirmeDenemesi\hello_intrin\main.cpp||In function 'int main()':|
C:\indirmeDenemesi\hello_intrin\main.cpp|8|error: '_mm256_zeroupper' was not declared in this scope|
C:\indirmeDenemesi\hello_intrin\main.cpp|9|error: '_mm128' was not declared in this scope|
C:\indirmeDenemesi\hello_intrin\main.cpp|9|error: expected ';' before 'x'|
C:\indirmeDenemesi\hello_intrin\main.cpp|10|error: '_mm256' was not declared in this scope|
C:\indirmeDenemesi\hello_intrin\main.cpp|10|error: expected ';' before 'y'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|
在具有 64 位 Windows 的 64 位 CPU 上使用 64 位最新版本的 gcc。 CPU是FX8150。 试过 -march=bdver1 -mtune=bdver1 并且它产生了数百个垃圾错误。
所有这些是否意味着我的 CPU 快要死了?
编辑:其他一些项目现在正在运行,但我没有改变任何东西。 这必须是特定于项目的事情。 使用 code::blocks 并且当我右键单击标题并选择“打开”时,它会给出错误“找不到”,但在编译时不会给出任何错误,只是内在命令的错误。 对于工作项目也是如此(它们编译所有内容并工作,但在右键单击并单击打开时找不到头文件)。 也许其他一些 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;
}
三件事应该让你的代码工作:
确保您正在使用 -mavx 编译标志。
您的变量应声明为__m256
而不是_mm256
。
确保你包含immintrin.h
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.