Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #59431
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Forth-94 vs. Forth-2012 FP data (long) |
| Date | 2017-05-17 15:02 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2017May17.170216@mips.complang.tuwien.ac.at> (permalink) |
| References | <2017May13.093451@mips.complang.tuwien.ac.at> <a561c81c-8478-4528-ad63-7c3524bef94c@googlegroups.com> <591c2dab.599913139@news.eternal-september.org> |
stephen@mpeforth.com (Stephen Pelc) writes:
>On Tue, 16 May 2017 22:48:04 -0700 (PDT), Joel Rees
><joel.rees@gmail.com> wrote:
>
>>> daxpy would produce better performance; I show this version to show
>>> what a compiler can do and to get a feeling for how close to the limit
>>> the Forth results are):
>>>
>>> VFX Forth-2012 VFX Forth-94 gcc (faxpy)
>>> FLD ST MOV EDX, [EBP] movsd (%rdi),%xmm1
>>> MOV EDX, [EBP] FLD TBYTE 0 [EDX] add %rsi,%rdi
>>> FLD TBYTE 0 [EDX] FLD TBYTE [080A3460] mulsd %xmm0,%xmm1
>>> FMULP ST(1), ST FMULP ST(1), ST addsd (%rdx),%xmm1
>>> FLD TBYTE 0 [EBX] FLD TBYTE 0 [EBX] movsd %xmm1,(%rdx)
>>> FADDP ST(1), ST FADDP ST(1), ST add %rcx,%rdx
>>> FSTP TBYTE 0 [EBX] FSTP TBYTE 0 [EBX] sub $0x1,%r8
>>> ADD EBX, 0A ADD EBX, 0A jne 0x4180b8 <faxpy+8>
>>> MOV EDX, [EBP] MOV EDX, [EBP]
>>> ADD EDX, 0A ADD EDX, 0A
>>> ADD [ESP], 01 ADD [ESP], 01
>>> ADD [ESP+04], 01 ADD [ESP+04], 01
>>> MOV [EBP], EDX MOV [EBP], EDX
>>> JNO 080C6D78 JNO 080C6DB8
>>>
>>> So VFX works nicely for optimizing the PICKs, DUPs etc. away here,
>
>Note also that ?DO ... LOOP is not optimal here as it maintains two
>items in memory. See the last four instructions in the VFX listings.
>A simple BEGIN ... UNTIL may be better.
There is nothing in ?DO...LOOP that prevents a compiler from
generating as good code for it as from BEGIN...WHILE...REPEAT
(BEGIN...UNTIL would be more appropriate for DO...LOOP). Moreover,
DO...LOOP is a way to reduce stack load, and is therefore usually
preferred by programmers when they program counted loops. But you can
try to convince me otherwise
> If you have 16 or more registers
>using two for DO ... LOOP may be more effective.
My suggestion is to use one register (containing the index) and one
memory location (containing the limit) on Intel/AMD CPUs, even with
only 8 registers. I.e., something like:
inc ecx
cmp ecx, [esp]
jne right-after-do
This means that you can LOOP at up to one iteration per cycle (instead
of 1 per 5 or 6 cycles with the current scheme). You may worry about
the [esp] memory access, but it does not depend on anything in the
loop, so it can be executed early by out-of-order execution. And if
you don't put anything else between the cmp and the jne, recent Intel
CPUs will combine (macro-fuse) them, reducing resource consumption,
and maybe increasing performance.
Anyway, as I described in the posting, I unrolled the loop (by a
factor of 4) to reduce the impact of loop overhead.
- 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 | Find similar | Unroll thread
Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-13 07:34 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-13 11:16 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-13 11:49 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-13 13:38 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) mhx@iae.nl - 2017-05-13 15:08 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-14 00:51 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-14 07:32 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) mhx@iae.nl - 2017-05-14 02:46 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-14 14:57 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) krishna.myneni@ccreweb.org - 2017-05-15 19:11 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-14 08:14 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) Paul Rubin <no.email@nospam.invalid> - 2017-05-13 15:58 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-14 07:01 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) krishna.myneni@ccreweb.org - 2017-05-14 19:04 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-15 06:10 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) krishna.myneni@ccreweb.org - 2017-05-15 01:49 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-15 14:33 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) "HAA" <someone@microsoft.com> - 2017-05-15 13:44 +1000
Re: Forth-94 vs. Forth-2012 FP data (long) Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-15 04:43 -0500
Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-15 15:03 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) "HAA" <someone@microsoft.com> - 2017-05-17 00:10 +1000
Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-16 09:04 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-17 15:54 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) mhx@iae.nl - 2017-05-17 10:29 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-17 23:53 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) pahihu <pahihu@gmail.com> - 2017-05-19 02:34 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) Joel Rees <joel.rees@gmail.com> - 2017-05-16 22:48 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-17 06:51 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) Joel Rees <joel.rees@gmail.com> - 2017-05-17 09:29 -0700
Re: Forth-94 vs. Forth-2012 FP data (long) stephen@mpeforth.com (Stephen Pelc) - 2017-05-17 11:07 +0000
Re: Forth-94 vs. Forth-2012 FP data (long) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-17 15:02 +0000
csiph-web