我的编译器支持avx2,并且我在C++标志中添加了-mavx2,但是我的代码中没有定义__AVX2__宏。
#ifdef __AVX2__
#include <immintrin.h>
#endif在代码中显示为禁用。
编辑:
我的编译器版本是:
g++ (Ubuntu 8.3.0-6ubuntu1) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.发布于 2019-09-09 17:06:01
要使eclipse知道AVX2是可用的,可以转到下面的项目属性
C/C++ General
Preprocessor Include Paths, Macros etc.
Providers
CDT GCC Built-in Compiler Settings并将-mavx2或-march=native添加到“获取编译器规格的命令”中。
或者,您可以在下面的全局首选项中进行设置
C/C++
Build
Settings
Discovery
CDT GCC Built-in Compiler Settings注意:当您处于该设置时,您还可以添加诸如-std=c++17 (或您通常使用的任何标准)之类的内容。
https://stackoverflow.com/questions/57805600
复制相似问题