Disabling all AVX512 extensions

Viewed 3265

I need to disable all AVX512 extensions in gcc-compiled code. The reason is that Valgrind chokes on AVX512 instructions. Is there a way to do it with a single flag?

I know how to disable each extension individually (-mno-avx512f, -mno-avx512pf etc) but this is troublesome because different gcc versions support different subsets of those.

I use CMake. If there is a way to automate the flags with CMake machinery, this would also work for me.

1 Answers

gcc -mno-avx512f also implies no other AVX512 extensions. AVX512F is the "foundation", and disabling it tells GCC the machine doesn't decode EVEX prefixes.

Similarly, -mno-avx disables AVX2, FMA3, and so on because they all build off of AVX. (Because of the way GCC works, -mavx512f -mno-avx might even disable AVX512F as well.)


e.g. gcc -march=icelake-client -mno-avx512f will reject intrinsics for AVX512DQ or AVX512VL instructions and so on, as well as not using them when auto-vectorizing.

Related