我尝试使用 AVX512 内在函数编译以下代码,但出现编译错误。
#include <immintrin.h>
static inline __attribute__((always_inline)) void
mov64(uint8_t *dst, const uint8_t *src)
{
__m512i zmm0;
zmm0 = _mm512_load_si512((const void *)src);
_mm512_store_si512((void *)dst, zmm0);
}
编译错误:
gcc -D_GNU_SOURCE -DINFO_LOG_DEBUG --std=c99 -march=native -O3 -DNDEBUG -m64 -mtune=native -Werror -Wall -Wundef -Wpointer-arith -Wstrict-prototypes -Wnested-externs -fomit-frame-pointer -DTRANSPORT_CONFIG_OPT_HDR='<ci/internal/transport_config_opt_extra.h>' -c src/main.c -o obj/main.o
src/main.c: In function ‘mov64’:
src/main.c:15:9: error: unknown type name ‘__m512i’
__m512i zmm0;
^
src/main.c:17:9: error: implicit declaration of function ‘_mm512_load_si512’ [-Werror=implicit-function-declaration]
zmm0 = _mm512_load_si512((const void *)src);
^
src/main.c:17:9: error: nested extern declaration of ‘_mm512_load_si512’ [-Werror=nested-externs]
src/main.c:18:9: error: implicit declaration of function ‘_mm512_store_si512’ [-Werror=implicit-function-declaration]
_mm512_store_si512((void *)dst, zmm0);
^
src/main.c:18:9: error: nested extern declaration of ‘_mm512_store_si512’ [-Werror=nested-externs]
cc1: all warnings being treated as errors
此外,如果我添加 -march=native,avx512f 或 -mavx512f 或 -march=skylake-avx512,则会出现以下错误:
src/main.c:1:0: error: bad value (skylake-avx512) for -march= switch
我的 GCC 版本是 4.8.5 20150623,CPU 是“Intel(R) Xeon(R) Gold 6154”。我应该怎么做才能克服这个问题?提前致谢..
最佳答案
GCC 4.8 不支持任何 AVX-512 变体。如果这是 Red Hat Enterprise Linux 7 的系统编译器,您可以使用 Red Hat Developer Toolset 中的新 GCC 版本。 ,为以后的CPU功能提供支持。 (DTS 也适用于 CentOS。)
关于avx512编译错误,是GCC问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57043592/