4

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.

valiano
  • 16,433
  • 7
  • 64
  • 79
einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • gcc7.3 is pretty good; I'd recommend that if you need to manually upgrade your gcc. gcc7 has some nice stuff, like store coalescing (adjacent narrow stores done with one `mov` instruction), great for structs with narrow members. – Peter Cordes Jun 12 '18 at 16:58
  • @PeterCordes: I was talking about my distribution's default. Of course I can use another version of GCC when relevant - but you can't really "upgrade" - all compiled libraries were built with the distro default version. – einpoklum Jun 12 '18 at 17:05
  • Compiler upgrades don't change the C ABI, so you can use a newer compiler without rebuilding system libraries. IDK about the C++ABI, though. gcc5 is pretty old, so if you're actually using AVX512 you probably want a newer gcc to get better code-gen. – Peter Cordes Jun 12 '18 at 17:13
  • @PeterCordes: Think CUDA 8. – einpoklum Jun 12 '18 at 17:19

1 Answers1

3

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.

einpoklum
  • 118,144
  • 57
  • 340
  • 684