Search code examples
gccintrinsicsavxicc

GCC support for Intel AVX instrinsics (dvec.h)


Does GCC support dvec.h, and if not, what can I do to port code written for ICC to work with GCC?

I am getting errors:

fatal error: dvec.h: No such file or directory
 #include <dvec.h>

Alternatively, GCC cannot find F32vec8.


Solution

  • See Agner Fog's manual Optimizing software in C++. See section 12.5 Using vector classes.

    enter image description here

    Agner's Vector Class Library (VCL) is far more powerful than Intel's dvec.h, it works on more compilers (including GCC and Clang), and it's free. However, it requires C++.

    Another option is to use Yeppp!. Yepp works for C, C++, C#, Java, and FORTRAN and not just C++. However, it's an actually library that you must link in. The VCL is only a set of header files.

    Another difference between the Yeppp! and the VCL is that Yeppp! is built from assembly whereas the VCL uses intrinsics. This is one reason Yeppp! needs to be linked in (MSVC 64-bit mode does not allow inline assembly).

    One disadvantage of intrinsics is that the compiler can implement them differently than you expect. This is not normally a problem with ICC and GCC. They are excellent when it comes to intrinsic. However, MSVC with AVX and especially FMA is disappointing (though with SSE it's normally fine). So the performance using the VCL with GCC compared to MSVC may be quite different with AVX and FMA.

    With assembly you always get what you want. However, since Yeppp! is not inline assembly you have to deal with the function calling overhead. In my case most of the time I want something like inline assembly which is what intrinsics mostly achieve.

    I don't know Yeppp! well but the documentation of the VCL library is excellent and the source code is very clear.