c++inteliccavx2avx512

Does icc -xCORE-AVX2 force the non-utilisation of AVX512 instructions on Xeon Gold if -O3 is on?


As per the title,

Will programs compiled with the intel compiler under

icc -O3 -xCORE-AVX2 program.cpp

Generate AVX512 instructions on a Xeon Gold 61XX?

Our assembler analysis doesn't seem to find one, but that is no guarantee.

Thanks!


Solution

  • In ICC classic, no, you can use intrinsics for any instruction without telling the compiler to enable it. (Unlike GCC or clang where you have to enable instruction sets to use their intrinsics, like the LLVM-based Intel OneAPI compiler.)

    But the compiler won't emit AVX-512 instructions other than from intrinsics (or inline asm), without enabling a -march=skylake-avx512 or -march=native (aka -xHOST) or similar option that implies -mavx512f. Or a pragma or __attribute__((target("string"))) to enable AVX-512 for a single function.

    This is true for all the major x86 compilers, AVX-512 is not on by default.

    Use -O3 -march=native if you want to make code optimized for the machine you're running on, just like with GCC or clang.


    In ICC classic, you can also let the compiler use certain instruction-sets on a per-function basis, with _allow_cpu_features(_FEATURE_AVX512F|_FEATURE_BMI); which works more like a pragma, affecting compile-time code-gen. See the docs.

    Also related: The Effect of Architecture When Using SSE / AVX Intrinisics re: gcc/clang vs. MSVC vs. ICC.