gcccompiler-errorsintrinsicsavx512gcc5

AVX512 intrinsics header produces many errors after distro upgrades GCC to 5.5.0


My Linux distribution upgraded my GCC version to 5.5.0 (damned if I know why). Now, when I try to build code which includes avx512fintrin.h, I get a slew of compiler errors:

/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512fintrin.h(9220): error: argument of type "const void *" is incompatible with parameter of type "const float *"
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512fintrin.h(9231): error: argument of type "const void *" is incompatible with parameter of type "const float *"
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512fintrin.h(9244): error: argument of type "const void *" is incompatible with parameter of type "const double *"
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512fintrin.h(9255): error: argument of type "const void *" is incompatible with parameter of type "const double *"

and so on. Why is this happening and is there a way (that's not too distribution specific hopefully) to resolve or circumvent this issue?

PS - In case it matters, I use GNU/Linux Mint 18.3.


Solution

  • Apparently, there's a GCC bug involved:

    Bug 76731 - [AVX512] _mm512_i32gather_epi32 and other scatter/gather routines have incorrect signature

    It seems like GCC 5.5 shipped with some avx512?intrin.h headers that switched to using void* and const void*, but without switching the builtins to do the same. This was resolved in a post-release version of GCC 5. About GCC 6.x - I'm not sure.

    A way to get around this is discussed on this forum thread: Downloading the patched headers from the GNU servers.

    Shell script for use with GCC 5 (on a Linux system):

    for f in avx512fintrin.h avx512pfintrin.h avx512vlintrin.h; do
       curl -H "User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36" -o $f "https://gcc.gnu.org/viewcvs/gcc/branches/gcc-5-branch/gcc/config/i386/${f}?view=co&revision=245536&content-type=text%2Fplain&pathrev=245536"
    done && mv avx512*intrin.h  /usr/lib/gcc/x86_64-linux-gnu/5/include/
    

    Actually, the files might be identical for all 3 versions, but I haven't checked.

    Note: If you're wondering why the user-agent string - it's to avoid the server from turning away clients it doesn't like with a "Forbidden" response. Of course it doesn't have to be this specific UA string.