Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #59743
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: ANN: matmul package available |
| Date | 2017-05-23 10:06 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2017May23.120638@mips.complang.tuwien.ac.at> (permalink) |
| References | (4 earlier) <655b323d-90ac-4de0-8b05-593b5b2a3171@googlegroups.com> <2017May21.155236@mips.complang.tuwien.ac.at> <c3561bad-f27f-4f38-ac7f-302abf03aa13@googlegroups.com> <2017May22.115008@mips.complang.tuwien.ac.at> <131a2d50-713e-4324-ba66-08af72052556@googlegroups.com> |
pahihu <pahihu@gmail.com> writes:
>2017. m=C3=A1jus 22., h=C3=A9tf=C5=91 13:22:09 UTC+2 id=C5=91pontban Anton =
>Ertl a k=C3=B6vetkez=C5=91t =C3=ADrta:
>> And of course auto-vectorization looks attractive to managers with
>> lots of existing code. It promises speedups for free, while the real
>> cure requires an investment in programmers who know how to vectorize.
>>=20
>
>I've got GCC 4.9.4 on my machine and tried auto vectorization.
>I compiled this dumb C routine with it:
>
>void daxpy(double ra,double *x,double *y,unsigned n)
>{
> unsigned i;
>
> for (i =3D 0; i < n; i++)
> y[i] +=3D ra * x[i];
>}
That's actually daxpy_nostride; a real daxpy is
daxpy (N, DA, DX, INCX, DY, INCY)
<http://www.netlib.org/lapack/explore-html/d9/dcd/daxpy_8f.html>
On AMD64, already gcc -O3 produces vectorized SSE2 code for
this function; the function is compiled into a 229-byte machine-code
routine, with the inner loop being:
83: 66 0f 10 0c 08 movupd (%rax,%rcx,1),%xmm1
88: 41 83 c0 01 add $0x1,%r8d
8c: 66 0f 59 ca mulpd %xmm2,%xmm1
90: 66 41 0f 58 0c 0a addpd (%r10,%rcx,1),%xmm1
96: 41 0f 29 0c 0a movaps %xmm1,(%r10,%rcx,1)
9b: 48 83 c1 10 add $0x10,%rcx
9f: 45 39 c8 cmp %r9d,%r8d
a2: 72 df jb 83 <xdaxpy+0x83>
If I compile it with gcc -O3 -mavx2, I get a 385-byte routine, with
the inner code being
ca: c4 a1 79 10 0c 00 vmovupd (%rax,%r8,1),%xmm1
d0: 41 83 c3 01 add $0x1,%r11d
d4: c4 a3 75 18 4c 00 10 vinsertf128 $0x1,0x10(%rax,%r8,1),%ymm1,%ymm1
db: 01
dc: c5 f5 59 ca vmulpd %ymm2,%ymm1,%ymm1
e0: c4 81 75 58 0c 04 vaddpd (%r12,%r8,1),%ymm1,%ymm1
e6: c4 81 7d 29 0c 04 vmovapd %ymm1,(%r12,%r8,1)
ec: 49 83 c0 20 add $0x20,%r8
f0: 45 39 cb cmp %r9d,%r11d
f3: 72 d5 jb ca <xdaxpy+0xca>
The xmm registers are 128-bits (2 C doubles) wide, the ymm registers
256 bits (4 C doubles).
However, wrt to the part of my posting you cited, the question is how
much of the code is like the C code above, and how much contains
various stumbling blocks for vectorization. E.g., gcc 4.9 does not
vectorize faxpy (which is much closer to the real daxpy than the
function above). Another question is how much of the code where the
stumbling blocks can be overcome is actually vectorized by gcc.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2017: http://www.euroforth.org/ef17/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ANN: matmul package available anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-19 10:43 +0000
Re: ANN: matmul package available krishna.myneni@ccreweb.org - 2017-05-19 05:20 -0700
Re: ANN: matmul package available anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-19 14:16 +0000
Re: ANN: matmul package available pahihu <pahihu@gmail.com> - 2017-05-19 08:28 -0700
Re: ANN: matmul package available pahihu <pahihu@gmail.com> - 2017-05-20 05:25 -0700
Re: ANN: matmul package available anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-20 13:23 +0000
Re: ANN: matmul package available pahihu <pahihu@gmail.com> - 2017-05-20 08:43 -0700
Re: ANN: matmul package available anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-20 16:02 +0000
Re: ANN: matmul package available pahihu <pahihu@gmail.com> - 2017-05-20 11:36 -0700
Re: ANN: matmul package available anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-21 07:52 +0000
Re: ANN: matmul package available mhx@iae.nl - 2017-05-21 03:28 -0700
Re: ANN: matmul package available pahihu <pahihu@gmail.com> - 2017-05-21 05:32 -0700
Re: ANN: matmul package available mhx@iae.nl - 2017-05-21 05:52 -0700
Re: ANN: matmul package available pahihu <pahihu@gmail.com> - 2017-05-21 07:54 -0700
Re: ANN: matmul package available mhx@iae.nl - 2017-05-21 08:32 -0700
Re: ANN: matmul package available pahihu <pahihu@gmail.com> - 2017-05-21 11:24 -0700
Re: ANN: matmul package available anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-21 13:52 +0000
Re: ANN: matmul package available mhx@iae.nl - 2017-05-21 08:47 -0700
Re: ANN: matmul package available anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-22 09:50 +0000
Re: ANN: matmul package available pahihu <pahihu@gmail.com> - 2017-05-22 07:14 -0700
Re: ANN: matmul package available mhx@iae.nl - 2017-05-22 07:39 -0700
Re: ANN: matmul package available anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-23 10:06 +0000
Re: ANN: matmul package available albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-05-19 17:00 +0200
Re: ANN: matmul package available anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-20 13:59 +0000
csiph-web