Re: [eigen] Matrix multiplication much slower on MSVC than on g++/clang |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Matrix multiplication much slower on MSVC than on g++/clang
- From: Edward Lam <edward@xxxxxxxxxx>
- Date: Thu, 8 Feb 2018 14:14:39 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sidefx.com; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=YLL+R3B+odfMss48lXsM7AV129M2tpJ2f62VlLjFYCQ=; b=i0mOqj1eJcQQSfy7o54GxNiWdsqJXcQ89RYf5UywL7wHyWXD+Pk/wWI+XBr9wqmnMx 4kedm70QjWP4rfh6r50M3Xqq4ZkBU/FBWmNC7SQa/qyFOUOYerqI7kRQOKfY1vnplrgW LsFHyUiqWg3Ek8u8wkZlNQjyjhGSwWad+lIt+UHK1s9/QMgzbyU1J/iT48bcOAwZwvlL gvVBgZ6Aoxq73tVDRCAeo78hBKBOe0xmdNnZAoxd1PXnyVup4Pp7TAE3w4PdZSQzbb/y vaH0u+35t7H82Dqq9yhgfdU9qFODGvBvMbsO3dwy3GsLW/apz1C1C4QBNvkMYsLJ37dU DI6g==
On 2/8/2018 10:19 AM, Christoph Hertzberg wrote:
Could you try writing a small AVX program which uses the
`_mm256_fmadd_ps(a,b,c)` intrinsic and see if it compiles with MSVC? Perhaps
only our `#ifdef __FMA__` test does not work with MSVC. (It would be interesting
to know how to detect FMA support then)
That works! For detection, the documentation at
https://msdn.microsoft.com/en-us/library/b0084kay.aspx suggests that perhaps
this will work:
#if defined(_MSC_VER) && defined(__AVX2__)
#define __FMA__
#endif
For reference, recompiling the earlier test with the best options plus -D__FMA__
produces:
$ ./gemm_test # 325 fmadd instructions produced
1124 1215 1465
col major (checksum: 0) elapsed_ms: 962
row major (checksum: 0) elapsed_ms: 1021
--------
1730 1235 1758
col major (checksum: 0) elapsed_ms: 1798
row major (checksum: 0) elapsed_ms: 1805
--------
1116 1736 868
col major (checksum: 0) elapsed_ms: 712
row major (checksum: 0) elapsed_ms: 712
--------
1278 1323 788
col major (checksum: 0) elapsed_ms: 578
row major (checksum: 0) elapsed_ms: 584
--------
Compared to the same compiler options *without* -D__FMA__ :
$ ./gemm_test # 125 fmadd instructions produced
1124 1215 1465
col major (checksum: 0) elapsed_ms: 1245
row major (checksum: 0) elapsed_ms: 1160
--------
1730 1235 1758
col major (checksum: 0) elapsed_ms: 2071
row major (checksum: 0) elapsed_ms: 2066
--------
1116 1736 868
col major (checksum: 0) elapsed_ms: 905
row major (checksum: 0) elapsed_ms: 905
--------
1278 1323 788
col major (checksum: 0) elapsed_ms: 711
row major (checksum: 0) elapsed_ms: 720
--------
Cheers,
-Edward