This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, fortran] Enable FMA for AVX2 and AVX512F for matmul


Am 02.03.2017 um 08:32 schrieb Janne Blomqvist:
On Wed, Mar 1, 2017 at 11:00 PM, Thomas Koenig <tkoenig@netcologne.de> wrote:
Hello world,

the attached patch enables FMA for the AVX2 and AVX512F variants of
matmul.  This should bring a very nice speedup (although I have
been unable to run benchmarks due to lack of a suitable machine).

In lieu of benchmarks, have you looked at the generated asm to verify
that fma is actually used?

Yes, I did.

Here's something from the new matmul_r8_avx2:

    156c:       c4 62 e5 b8 fd          vfmadd231pd %ymm5,%ymm3,%ymm15
    1571:       c4 c1 79 10 04 06       vmovupd (%r14,%rax,1),%xmm0
    1577:       c4 62 dd b8 db          vfmadd231pd %ymm3,%ymm4,%ymm11
157c: c4 c3 7d 18 44 06 10 vinsertf128 $0x1,0x10(%r14,%rax,1),%ymm0,%ymm0
    1583:       01
    1584:       c4 62 ed b8 ed          vfmadd231pd %ymm5,%ymm2,%ymm13
    1589:       c4 e2 ed b8 fc          vfmadd231pd %ymm4,%ymm2,%ymm7
158e: c4 e2 fd a8 ad 30 ff vfmadd213pd -0x800d0(%rbp),%ymm0,%ymm5

... and here from matmul_r8_avx512f:

    1da8:       c4 a1 7b 10 14 d6       vmovsd (%rsi,%r10,8),%xmm2
    1dae:       c4 c2 b1 b9 f0          vfmadd231sd %xmm8,%xmm9,%xmm6
    1db3:       62 62 ed 08 b9 e5       vfmadd231sd %xmm5,%xmm2,%xmm28
    1db9:       62 62 ed 08 b9 ec       vfmadd231sd %xmm4,%xmm2,%xmm29
    1dbf:       62 62 ed 08 b9 f3       vfmadd231sd %xmm3,%xmm2,%xmm30
    1dc5:       c4 e2 91 99 e8          vfmadd132sd %xmm0,%xmm13,%xmm5
    1dca:       c4 e2 99 99 e0          vfmadd132sd %xmm0,%xmm12,%xmm4
    1dcf:       c4 e2 a1 99 d8          vfmadd132sd %xmm0,%xmm11,%xmm3
    1dd4:       c4 c2 a9 99 d1          vfmadd132sd %xmm9,%xmm10,%xmm2
    1dd9:       c4 c2 89 99 c1          vfmadd132sd %xmm9,%xmm14,%xmm0
1dde: 0f 8e d3 fe ff ff jle 1cb7 <matmul_r8_avx512f+0x1cb7>

... so this is looking pretty good.

Regards

	Thomas


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]