GCC support for Intel AVX instrinsics (dvec.h)

Go To StackoverFlow.com

1

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.

2015-09-29 12:28
by Aleksandr Dubinsky
I think you're out of luck - you'll need to replace usage of the Intel SIMD classes with equivalent intrinsics - Paul R 2015-09-29 13:09
@PaulR Do you have a recommendation for how it is done in GCC - Aleksandr Dubinsky 2015-09-29 14:19
It really depends on how the classes are being used - if you haven't written SIMD code before though then you have something of a learning curve ahead of you - Paul R 2015-09-29 14:25
@PaulR I have, but I am not familiar with GCC. It seems that GCC Vector Extensions is a close analog for dvec.h and has some support in ICC - Aleksandr Dubinsky 2015-09-29 14:35
Yes, you might be able to use the GCC vector extensions, although if you want maximum portability then you might want to consider either (a) using intrinsics (works with all compilers), or even (b) reverse-engineering back to scalar code and then let the compiler auto-vectorize your scalar code (easiest solution, but performance may not be as good) - the choice depends on how performance-critical the code is and how much you care about portability, future-proofing, etc - Paul R 2015-09-29 14:42
Are you interested in C or C++ - Z boson 2015-09-30 08:16


1

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.

2015-09-30 08:39
by Z boson
Excellent. VCL+GCC gave me 4x the performance of dvec+ICC. No incompatibilities either (unlike GCC's vector extensions). Is Yeppp a library of high-level routines or low-level ones? How does it replace intrinsics - Aleksandr Dubinsky 2015-10-01 15:49
Yeppp! is a low level library as far as I understand. At least, it's not a high level BLAS library like Eigen. I have only downloaded it, installed, compiled it and ran some of the benchmarks. I l also browsed through some of the source code. The author of Yeppp! writes some of the best answers on SIMD on SO - Z boson 2015-10-02 07:37
Ads