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.
-march=native
maybe? – Yonina-march=native
. – Glindaglinka-march=native -mno-avx512f
is guaranteed to also disable AVX512VL, AVX512DQ and so on? As the OP points out, my answer is right in current GCC but gcc.gnu.org/onlinedocs/gcc/x86-Options.html doesn't guarantee it. – Stock-mnative
offers. It is not easy to enable them one by one for different CPUs. – Glindaglinka-march=native -mno-avx512f
on a Skylake-SP or Cascade Lake is I think exactly identical to-march=skylake
. Possibly a different L2 cache size tuning parameter for the-mtune=native
part. However, going forward as more different CPUs come along there won't be easy equivalents; e.g. icelake-client / server both have AVX512 and might have some tune settings different from skylake. So I'd recommend using-march=native -mno-avx512f
. The only case it's a problem for you is when it breaks noisily in cachegrind, so if future GCC changes (unlikely) you can change your build. – Stock