Re: [eigen] Matrix multiplication much slower on MSVC than on g++/clang

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On 2018-02-09 14:56, Edward Lam wrote:
On 2/9/2018 3:16 AM, Gael Guennebaud wrote:

    That works! For detection, the documentation at
    https://msdn.microsoft.com/en-us/library/b0084kay.aspx
    <https://msdn.microsoft.com/en-us/library/b0084kay.aspx> suggests that
    perhaps this will work:

    #if defined(_MSC_VER) && defined(__AVX2__)
    #define __FMA__
    #endif

To implement that we need to make sure that on all architectures AVX2 => FMA. This seems to be true for Intel's ones, but I'm not sure about AMD.


According to https://stackoverflow.com/questions/16348909/how-do-i-know-if-i-can-compile-with-fma-instruction-sets , all AMD processors which support AVX2 support FMA. Unfortunately, I couldn't easily confirm through official online resources. The wikipedia page on Advanced_Vector_Extensions notes that only AMD Excavactor processors (and up) support AVX2, and those definitely support FMA (double-checked at https://support.amd.com/TechDocs/47414_15h_sw_opt_guide.pdf).

It seems that there are AMD architectures which support FMA3, but not AVX2. This would make the check above safe, but not optimal.
https://en.wikipedia.org/wiki/Piledriver_(microarchitecture)

Bulldozer supports FMA4 (and AVX1), but not FMA3 (nor AVX2).
https://en.wikipedia.org/wiki/Bulldozer_(microarchitecture)

It seems, Eigen generally only supports FMA3, even though FMA4 should be relatively easy (just the name of the intrinsic should be different).

That said, I'm ok with the hack suggested above. We should probably still document how to make sure that FMA is enabled (if AVX2 is not available).


Christoph



-Edward




--
 Dr.-Ing. Christoph Hertzberg

 Besuchsadresse der Nebengeschäftsstelle:
 DFKI GmbH
 Robotics Innovation Center
 Robert-Hooke-Straße 5
 28359 Bremen, Germany

 Postadresse der Hauptgeschäftsstelle Standort Bremen:
 DFKI GmbH
 Robotics Innovation Center
 Robert-Hooke-Straße 1
 28359 Bremen, Germany

 Tel.:     +49 421 178 45-4021
 Zentrale: +49 421 178 45-0
 E-Mail:   christoph.hertzberg@xxxxxxx

 Weitere Informationen: http://www.dfki.de/robotik
 -----------------------------------------------------------------------
 Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
 Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
 Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
 (Vorsitzender) Dr. Walter Olthoff
 Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
 Amtsgericht Kaiserslautern, HRB 2313
 Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
 USt-Id.Nr.:    DE 148646973
 Steuernummer:  19/672/50006
 -----------------------------------------------------------------------



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/