Reputation: 119
I am trying to enable AVX instructions in my project. I can build it with gcc (gcc -mavx), but not with Intel compiler (icpc -maxv) which fails in avxintrin.h gcc header with the following errors:
Just for reference, here is the code from avxintrin.h:
extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_loadu_pd (double const *__P)
{
return (__m256d) __builtin_ia32_loadupd256 (__P);
}
As I understand it, those identifiers are built-in functions in gcc, which is why are not recognised by icc; and I guess I should somehow hide avxintrin.h header from icc and make it use its own built-ins ("intrinsics"). Am I correct, and how can I make icpc work?
gcc 4.4.7, icpc 17.0
Upvotes: 1
Views: 706
Reputation: 364180
Why are you using headers from such an old version of gcc with ICC? The GCC 4.4 series predates AVX. (4.4.7 is from 2012, but it's still relatively ancient). Current GCC is 8.2, or 7.4 for the old-stable. (If you care about how well GCC tunes for modern CPUs, especially with AVX, use a newer GCC that knows -march=skylake
and -march=znver1
).
ICC does depend on GCC headers for some reason, apparently including for immintrin.h
. IDK why ICC doesn't fully provide their own definitions for Intel intrinsics.
A working install of ICC17 does understand that GCC builtin, after you #include <immintrin.h>
. https://godbolt.org/z/PKumZx. But that's with a more recent immintrin.h
, I think.
And unlike ICC17, ICC19 will compile a __builtin_ia32_loadupd256(p)
for double*p
even with no declarations or includes.
ICC complains if you declare you own __m256d
unless you put the __attribute__
in the right order, etc. Anyway, try grabbing headers from a newer gcc, your ICC might be too new for that gcc.
Also, don't include avxintrin.h
directly, include immintrin.h
.
avxintrin.h from gcc8.2 has an ifdef for # error "Never use <avxintrin.h> directly; include <immintrin.h> instead."
. Maybe your old gcc version is missing that.
Upvotes: 3