Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

No more blah, blah, blah! -- Kirk, "Miri", stardate 2713.6


devel / comp.lang.forth / Optimizing #

SubjectAuthor
* Optimizing #Anton Ertl
+- Re: Optimizing #Ron AARON
+* Re: Optimizing #Krishna Myneni
|+* Re: Optimizing #minf...@arcor.de
||+- Re: Optimizing #Krishna Myneni
||+* Re: Optimizing #Anton Ertl
|||+* Re: Optimizing #Marcel Hendrix
||||`- Re: Optimizing #Marcel Hendrix
|||`- Re: Optimizing #Hans Bezemer
||+- Re: Optimizing #Rick C
||`* Re: Optimizing #dxforth
|| `- Re: Optimizing #Rick C
|`* Re: Optimizing #Krishna Myneni
| +- Re: Optimizing #Krishna Myneni
| `* Re: Optimizing #dxforth
|  +* Re: Optimizing #Krishna Myneni
|  |`* Re: Optimizing #dxforth
|  | `* Re: Optimizing #Heinrich Hohl
|  |  +* Re: Optimizing #Heinrich Hohl
|  |  |`- Re: Optimizing #dxforth
|  |  +- Re: Optimizing #Hans Bezemer
|  |  +- Re: Optimizing #Hans Bezemer
|  |  `- Re: Optimizing #dxforth
|  `- Re: Optimizing #Hans Bezemer
+* Re: Optimizing #Brian Fox
|+* Re: Optimizing #Anton Ertl
||`* Re: Optimizing #Paul Rubin
|| +* Re: Optimizing #dxforth
|| |`- Re: Optimizing #Paul Rubin
|| `* Re: Optimizing #Anton Ertl
||  `* Re: Optimizing #Paul Rubin
||   +- Re: Optimizing #dxforth
||   `* Re: Optimizing #minf...@arcor.de
||    `* Re: Optimizing #Paul Rubin
||     `* Re: Optimizing #minf...@arcor.de
||      +* Re: Optimizing #Marcel Hendrix
||      |+* Re: Optimizing #Marcel Hendrix
||      ||`- Re: Optimizing #Marcel Hendrix
||      |`* Re: Optimizing #minf...@arcor.de
||      | +- Re: Optimizing #Paul Rubin
||      | +- Re: Optimizing #minf...@arcor.de
||      | `* Re: Optimizing #Paul Rubin
||      |  `* Re: Optimizing #minf...@arcor.de
||      |   `- Re: Optimizing #Anton Ertl
||      +* Re: Optimizing #dxforth
||      |`* Re: Optimizing #Paul Rubin
||      | `* Re: Optimizing #dxforth
||      |  +* Re: Optimizing #minf...@arcor.de
||      |  |`- Re: Optimizing #dxforth
||      |  `* Re: Optimizing #Anton Ertl
||      |   `- Re: Optimizing #dxforth
||      `- Re: Optimizing # , float conv & BigNums,Jan Coombs
|+- Re: Optimizing #Rick C
|`- Re: Optimizing #dxforth
+- Re: Optimizing #Anton Ertl
`* Re: Optimizing #dxforth
 `* Re: Optimizing #Anton Ertl
  +- Re: Optimizing #Anton Ertl
  `* Re: Optimizing #dxforth
   `* Re: Optimizing #Anton Ertl
    `* Re: Optimizing #dxforth
     `* Re: Optimizing #Brian Fox
      `* Re: Optimizing #dxforth
       `* Re: Optimizing #Brian Fox
        `* Re: Optimizing #Anton Ertl
         `* Re: Optimizing #Anton Ertl
          `* Re: Optimizing #minf...@arcor.de
           `* Re: Optimizing #Hans Bezemer
            +* Re: Optimizing #Anton Ertl
            |`* Re: Optimizing #Hans Bezemer
            | `* Re: Optimizing #Paul Rubin
            |  `* Re: Optimizing #Marcel Hendrix
            |   `* Re: Optimizing #dxforth
            |    `* Re: Optimizing #Anton Ertl
            |     `- Re: Optimizing #dxforth
            `* Re: Optimizing #dxforth
             `* Re: Optimizing #Hans Bezemer
              `* Re: Optimizing #minf...@arcor.de
               `* Re: Optimizing #Hans Bezemer
                `* Re: Optimizing #minf...@arcor.de
                 `* Re: Optimizing #Hans Bezemer
                  `* Re: Optimizing #dxforth
                   `- Re: Optimizing #Hans Bezemer

Pages:1234
Optimizing #

<2022Mar11.130937@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17165&group=comp.lang.forth#17165

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Optimizing #
Date: Fri, 11 Mar 2022 12:09:37 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 125
Message-ID: <2022Mar11.130937@mips.complang.tuwien.ac.at>
Injection-Info: reader02.eternal-september.org; posting-host="692505a5a4264c87f4943b78f81172b7";
logging-data="18871"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+OhadkX5k0FFi3xBjRXEn3"
Cancel-Lock: sha1:3otgTNkksXDOqA5jL0qZnIJIbkI=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 11 Mar 2022 12:09 UTC

The folloing description applies to Gforth, but I think that it
applies to many Forth systems, because this aspect is derived from a
common ancestor (probably one of Forth, Inc.'s early systems):

The word # (used in, e.g., ".") internally calls UD/MOD, which
requires two double-by-single divisions:

: ud/mod ( ud1 u2 -- urem udquot ) \ gforth
\G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
\G quotient @i{udquot} and a single remainder @i{urem}.
>r 0 r@ um/mod r> swap >r
um/mod r> ;

: # ( ud1 -- ud2 )
base @ ud/mod rot dup 9 u>
[ char A char 9 1+ - ] Literal and +
'0' + hold ;

Division is slow on many CPUs, and many architectures don't have a
double-by-single division instruction. So I had the idea that we
could optimize # by

1) Dealing with the case where the high word is 0 as a special case.

2) Dealing with the case where BASE contains #10 as a special case.

Using only 1) results in:

: # ( ud1 -- ud2 )
?dup-if
base @ ud/mod
else
base @ u/mod 0
then
rot dup 9 u>
[ char A char 9 1+ - ] Literal and +
'0' + hold ;

Using 1) and 2) results in:

: # ( ud1 -- ud2 )
?dup-if
base @ ud/mod
else
base @ 10 <> if
base @ u/mod 0
else
10 u/mod 0
then
then
rot dup 9 u>
[ char A char 9 1+ - ] Literal and +
'0' + hold ;

You may be wondering about the sequence "10 u/mod". Why should it be
any faster than "base @ u/mod"? Because Gforth optimizes the division
by a constant into multiplication by the reciprocal value. If you
decompile the code above, you find:

: #
?DUP-IF useraddr #112 @ ud/mod
ELSE useraddr #112 @ #10 <>
IF useraddr #112 @ u/mod #0
ELSE $7FDBE8D435F0 u/mod-stage2m
THEN
THEN #0
rot dup #9 u> #7 and + #48 + hold ;

and the "$7FDBE8D435F0 u/mod-stage2m" performs the multiplication by
the reciprocal.

Of course, the quetion is if these optimizations pay off, and on which
CPUs. To put this optimization into Gforth, first I made # a deferred
word, and measured that step separately; the original code is variant
a), the one with deferred # is b), the one optimizing just the high
word is c), and the one that special-cases base #10 is d). Also, we
optimize the high word without converting # into a deferred word; this
is e).

Measurement with:

perf stat -e cycles:u -e instructions:u -r 10 gforth-fast -e ': print-nums 0 do i . loop ; [: 1000000 print-nums ;] >string-execute type bye' >/dev/null
for i in '(#)' '(#1)' '(#2)'; do perf stat -e cycles:u -e instructions:u -r 10 gforth-fast -e "' $i is # : print-nums 0 do i . loop ; [: 1000000 print-nums ;] >string-execute type bye" >/dev/null; done

This benchmark is the best case for these optimizations, but I think
it is representative of how # is used.

Results (in Million cycles user time):

Skylake Rocket Zen3 A72 U74
979 736 798 1506 6482 a) Original
1001 745 817 1488 6521 b) deferred #
839 653 722 1052 3772 c) special-case high=0
825 732 816 1466 3903 d) also special-case base=#10
836 650 725 1064 3563 e) special-case high=0, no deferred #

Skylake: Core i5-6600K
Rocket: Xeon W-1370P
Zen3: Ryzen 7 5800X
A72: RockPro64
U74: Starfive Visonfive

Making # deferred costs quite a bit more than I had expected (I had
actually expected that there would be no cost on the out-of-order CPUs
(the first four); when eliminating the deferred word, I see no real
speedups on the OoO CPUs, which supports my expectation, but is in
contradiction to the results I saw when making # deferred. Strange.

Special-casing high=0 is beneficial in all cases.

Special-casing base=#10 only helps the Skylake. On the other CPUs
apparently division is cheap enough and the overhead of separating
this case is expensive enough that separating this case does not pay
off. The slowdown from this special case on the A72 is surprisingly
large.

Overall, my conclusion is to keep the high=0 special case, and forget
about the base=#10 one.

- 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 2021: https://euro.theforth.net/2021

Re: Optimizing #

<t0fj9r$vib$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17166&group=comp.lang.forth#17166

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Fri, 11 Mar 2022 15:36:57 +0200
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <t0fj9r$vib$1@dont-email.me>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 11 Mar 2022 13:37:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="80f922ff02be5a30213654c84402436a";
logging-data="32331"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BjYL+LWrQDoUBakhTPqC0"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.7.0
Cancel-Lock: sha1:DZ5P3O/z32XRHpMK0EkmkzoZ8hs=
In-Reply-To: <2022Mar11.130937@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ron AARON - Fri, 11 Mar 2022 13:36 UTC

On 2022-03-11 14:09, Anton Ertl wrote:
> The folloing description applies to Gforth, but I think that it
> applies to many Forth systems, because this aspect is derived from a
> common ancestor (probably one of Forth, Inc.'s early systems):
....
> Measurement with:
>
> perf stat -e cycles:u -e instructions:u -r 10 gforth-fast -e ': print-nums 0 do i . loop ; [: 1000000 print-nums ;] >string-execute type bye' >/dev/null
> for i in '(#)' '(#1)' '(#2)'; do perf stat -e cycles:u -e instructions:u -r 10 gforth-fast -e "' $i is # : print-nums 0 do i . loop ; [: 1000000 print-nums ;] >string-execute type bye" >/dev/null; done
>
> This benchmark is the best case for these optimizations, but I think
> it is representative of how # is used.
>
> Results (in Million cycles user time):
>
> Skylake Rocket Zen3 A72 U74
> 979 736 798 1506 6482 a) Original
> 1001 745 817 1488 6521 b) deferred #
> 839 653 722 1052 3772 c) special-case high=0
> 825 732 816 1466 3903 d) also special-case base=#10
> 836 650 725 1064 3563 e) special-case high=0, no deferred #
>
> Skylake: Core i5-6600K
> Rocket: Xeon W-1370P
> Zen3: Ryzen 7 5800X
> A72: RockPro64
> U74: Starfive Visonfive
>
> Making # deferred costs quite a bit more than I had expected (I had
> actually expected that there would be no cost on the out-of-order CPUs
> (the first four); when eliminating the deferred word, I see no real
> speedups on the OoO CPUs, which supports my expectation, but is in
> contradiction to the results I saw when making # deferred. Strange.
>
> Special-casing high=0 is beneficial in all cases.
>
> Special-casing base=#10 only helps the Skylake. On the other CPUs
> apparently division is cheap enough and the overhead of separating
> this case is expensive enough that separating this case does not pay
> off. The slowdown from this special case on the A72 is surprisingly
> large.
>
> Overall, my conclusion is to keep the high=0 special case, and forget
> about the base=#10 one.
>
> - anton

Thank you. I have to say I enjoy your very detailed perf analyses. And
the counter-intuitive results are what I have come to expect, TBH, from
my own investigations.

Optimizing isn't for the faint-hearted or those who don't measure results.

Re: Optimizing #

<t0fjr2$6h3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17168&group=comp.lang.forth#17168

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Fri, 11 Mar 2022 07:46:08 -0600
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <t0fjr2$6h3$1@dont-email.me>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 11 Mar 2022 13:46:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="db31e90da6e9c7696dc2434fffd4f8ec";
logging-data="6691"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CwK574VJYtFbCJykxsQnC"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.4.0
Cancel-Lock: sha1:uV5znFQMKpjCvxgPCSMoJ9rBjCs=
In-Reply-To: <2022Mar11.130937@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Krishna Myneni - Fri, 11 Mar 2022 13:46 UTC

On 3/11/22 06:09, Anton Ertl wrote:
> The folloing description applies to Gforth, but I think that it
> applies to many Forth systems, because this aspect is derived from a
> common ancestor (probably one of Forth, Inc.'s early systems):
>
> The word # (used in, e.g., ".") internally calls UD/MOD, which
> requires two double-by-single divisions:
>
> : ud/mod ( ud1 u2 -- urem udquot ) \ gforth
> \G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
> \G quotient @i{udquot} and a single remainder @i{urem}.
> >r 0 r@ um/mod r> swap >r
> um/mod r> ;
>
> : # ( ud1 -- ud2 )
> base @ ud/mod rot dup 9 u>
> [ char A char 9 1+ - ] Literal and +
> '0' + hold ;
>
....

Interesting. UD/MOD is not present in kForth. When I looked at the
implementation of "#" it uses the non-standard word UTM/ to perform the
division, which should be far more expensive. So there's a significant
speedup to be had for number to string conversion here.

>
> Special-casing high=0 is beneficial in all cases.
>
> Special-casing base=#10 only helps the Skylake. On the other CPUs
> apparently division is cheap enough and the overhead of separating
> this case is expensive enough that separating this case does not pay
> off. The slowdown from this special case on the A72 is surprisingly
> large.
>
> Overall, my conclusion is to keep the high=0 special case, and forget
> about the base=#10 one.
>

Good to know. Thanks.

--
Krishna

Re: Optimizing #

<a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17169&group=comp.lang.forth#17169

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ae9:ed8a:0:b0:67d:6a0d:2a82 with SMTP id c132-20020ae9ed8a000000b0067d6a0d2a82mr4638853qkg.561.1647015283865;
Fri, 11 Mar 2022 08:14:43 -0800 (PST)
X-Received: by 2002:a05:620a:1a95:b0:67d:4f43:a44a with SMTP id
bl21-20020a05620a1a9500b0067d4f43a44amr6146451qkb.56.1647015283680; Fri, 11
Mar 2022 08:14:43 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 11 Mar 2022 08:14:43 -0800 (PST)
In-Reply-To: <2022Mar11.130937@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=99.242.210.36; posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 99.242.210.36
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
Subject: Re: Optimizing #
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Fri, 11 Mar 2022 16:14:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 12
 by: Brian Fox - Fri, 11 Mar 2022 16:14 UTC

On Friday, March 11, 2022 at 8:04:20 AM UTC-5, Anton Ertl wrote:

> Overall, my conclusion is to keep the high=0 special case, and forget
> about the base=#10 one.
>
I have been noodling on this myself.
It makes me wonder if we are breaking a rule of Forth by having one word, '#' used for two purposes:
- Printing single cell integers
- printing double integers

# goes back a long way and was probably a compromise to save space in those days. (?)

And like Ron I too enjoy your detailed analysis. Thanks.

Re: Optimizing #

<2022Mar11.183346@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17172&group=comp.lang.forth#17172

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Fri, 11 Mar 2022 17:33:46 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 33
Message-ID: <2022Mar11.183346@mips.complang.tuwien.ac.at>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="692505a5a4264c87f4943b78f81172b7";
logging-data="6773"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192xyuPXZk/GBYt+OkQ3pOJ"
Cancel-Lock: sha1:/zWABvjGEMfmT8nwR8mvV/u9V28=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 11 Mar 2022 17:33 UTC

Brian Fox <brian.fox@brianfox.ca> writes:
>I have been noodling on this myself.
>It makes me wonder if we are breaking a rule of Forth by having one word, '#' used for two purposes:
>- Printing single cell integers
>- printing double integers
>
># goes back a long way and was probably a compromise to save space in those days. (?)

I expect that that's the case. I also guess that the common case was
to output the result of # to some relatively slow device, like a
serial terminal or a printer, so optimizing # for speed was not
important, while space was at a premium.

And even when RAM became plentiful, the performance of # was never
enough of a problem that the relatively simple optimization of
special-casing high=0 was applied (not in Gforth, and looking at
SwiftForth, not in SwiftForth, either).

As for breaking a rule of Forth, the result of always dealing with
doubles is simpler than that of having an additional separate set of
words good only for single-cell numbers. So I don't see which rule
you mean.

I also expect that my special-casing of the high=0 case gives most of
the benefit of a single-cell variant of # (and friends) at a minimal
cost in code size.

- 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 2021: https://euro.theforth.net/2021

Re: Optimizing #

<f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17173&group=comp.lang.forth#17173

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:1210:b0:2e0:6e26:23a8 with SMTP id y16-20020a05622a121000b002e06e2623a8mr9593337qtx.267.1647027385618;
Fri, 11 Mar 2022 11:36:25 -0800 (PST)
X-Received: by 2002:ad4:5d44:0:b0:435:b4f0:5c3c with SMTP id
jk4-20020ad45d44000000b00435b4f05c3cmr9262396qvb.25.1647027385435; Fri, 11
Mar 2022 11:36:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 11 Mar 2022 11:36:25 -0800 (PST)
In-Reply-To: <t0fjr2$6h3$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t0fjr2$6h3$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com>
Subject: Re: Optimizing #
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Fri, 11 Mar 2022 19:36:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 47
 by: minf...@arcor.de - Fri, 11 Mar 2022 19:36 UTC

Krishna Myneni schrieb am Freitag, 11. März 2022 um 14:46:12 UTC+1:
> On 3/11/22 06:09, Anton Ertl wrote:
> > The folloing description applies to Gforth, but I think that it
> > applies to many Forth systems, because this aspect is derived from a
> > common ancestor (probably one of Forth, Inc.'s early systems):
> >
> > The word # (used in, e.g., ".") internally calls UD/MOD, which
> > requires two double-by-single divisions:
> >
> > : ud/mod ( ud1 u2 -- urem udquot ) \ gforth
> > \G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
> > \G quotient @i{udquot} and a single remainder @i{urem}.
> > >r 0 r@ um/mod r> swap >r
> > um/mod r> ;
> >
> > : # ( ud1 -- ud2 )
> > base @ ud/mod rot dup 9 u>
> > [ char A char 9 1+ - ] Literal and +
> > '0' + hold ;
> >
> ...
>
> Interesting. UD/MOD is not present in kForth. When I looked at the
> implementation of "#" it uses the non-standard word UTM/ to perform the
> division, which should be far more expensive. So there's a significant
> speedup to be had for number to string conversion here.
> >
> > Special-casing high=0 is beneficial in all cases.
> >
> > Special-casing base=#10 only helps the Skylake. On the other CPUs
> > apparently division is cheap enough and the overhead of separating
> > this case is expensive enough that separating this case does not pay
> > off. The slowdown from this special case on the A72 is surprisingly
> > large.
> >
> > Overall, my conclusion is to keep the high=0 special case, and forget
> > about the base=#10 one.
> >
> Good to know. Thanks.
>

I was wondering whether there is much to be won by making #
faster and thus more complex. I don't want negativity in here
but # is practically always followed by some terminal output
which is by magnitudes slower than #.

Re: Optimizing #

<t0gemh$g99$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17174&group=comp.lang.forth#17174

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Fri, 11 Mar 2022 15:24:31 -0600
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <t0gemh$g99$1@dont-email.me>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<t0fjr2$6h3$1@dont-email.me>
<f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 11 Mar 2022 21:24:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="db31e90da6e9c7696dc2434fffd4f8ec";
logging-data="16681"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190Oi0L09GfgrjqZJZOCAvF"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.4.0
Cancel-Lock: sha1:K9PBXF91CtHovgpIeie+PF8c3lc=
In-Reply-To: <f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com>
Content-Language: en-US
 by: Krishna Myneni - Fri, 11 Mar 2022 21:24 UTC

On 3/11/22 13:36, minf...@arcor.de wrote:
> Krishna Myneni schrieb am Freitag, 11. März 2022 um 14:46:12 UTC+1:
>> On 3/11/22 06:09, Anton Ertl wrote:
>>> The folloing description applies to Gforth, but I think that it
....
>>> The word # (used in, e.g., ".") internally calls UD/MOD, which
>>> requires two double-by-single divisions:
>>>
>>> : ud/mod ( ud1 u2 -- urem udquot ) \ gforth
>>> \G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
>>> \G quotient @i{udquot} and a single remainder @i{urem}.
>>>> r 0 r@ um/mod r> swap >r
>>> um/mod r> ;
>>>
>>> : # ( ud1 -- ud2 )
>>> base @ ud/mod rot dup 9 u>
>>> [ char A char 9 1+ - ] Literal and +
>>> '0' + hold ;
>>>
>> ...
>>
>> Interesting. UD/MOD is not present in kForth. When I looked at the
>> implementation of "#" it uses the non-standard word UTM/ to perform the
>> division, which should be far more expensive. So there's a significant
>> speedup to be had for number to string conversion here.
>>>
>>> Special-casing high=0 is beneficial in all cases.
>>>
....
>>> Overall, my conclusion is to keep the high=0 special case, and forget
>>> about the base=#10 one.
>>>
....
>
> I was wondering whether there is much to be won by making #
> faster and thus more complex. I don't want negativity in here
> but # is practically always followed by some terminal output
> which is by magnitudes slower than #.

It's often true that number to string conversion may be followed by
terminal output, but it could also be file output (a case which I use
often). Some testing with file output will reveal whether the efficiency
gain is significant.

The reverse problem is usually more important, parsing a string and
converting to numeric fields. This can be slow if the parsing and
conversion is not optimized! I've been working on speeding this up in
the kForth string library (there's room for significant improvement
here). A recent need has been to export a spreadsheet (OpenOffice or
Excel) to a csv file, from which I want to extract specific columns and
write them out to a separate text file. There are command line tools for
this but I want a Forth tool which can be specialized for handling
specific cases.

--
Krishna

Re: Optimizing #

<2022Mar11.233731@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17175&group=comp.lang.forth#17175

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Fri, 11 Mar 2022 22:37:31 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 37
Message-ID: <2022Mar11.233731@mips.complang.tuwien.ac.at>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t0fjr2$6h3$1@dont-email.me> <f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="692505a5a4264c87f4943b78f81172b7";
logging-data="3395"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ff3JvFHoi1XqSS4Yc0DJC"
Cancel-Lock: sha1:2e7KvpfaLwgV4GFSxc1Z2WRn+d4=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 11 Mar 2022 22:37 UTC

"minf...@arcor.de" <minforth@arcor.de> writes:
>I was wondering whether there is much to be won by making #
>faster and thus more complex. I don't want negativity in here
>but # is practically always followed by some terminal output
>which is by magnitudes slower than #.

Let's test the latter claim first:

time gforth-fast -e ": foo 1000000 0 do 1111111111 . loop ; foo bye" >/dev/null
real 0m0.310s
user 0m0.310s
sys 0m0.000s
time gforth-fast -e ': foo 1000000 0 do ." 1111111111 " loop ; foo bye'
....
real 0m1.267s
user 0m0.298s
sys 0m0.692s

So # is indeed faster than output on an xterm, although not by a
magnitude, much less magnitudes.

Anyway, occasionally the cost of # has been relevant for performance,
e.g., when writing the result to a file, or when using it in a hash
table.

The classic way to deal with such problems is to design a hand-written
special-purpose conversion routine. If you compare such routines with
the effort required for a faster #, the faster # usually has much less
complexity; if its performance is good enough, it's probably the
better solution.

- 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 2021: https://euro.theforth.net/2021

Re: Optimizing #

<4d057f4b-2f5c-48b5-bb50-e418a9895304n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17176&group=comp.lang.forth#17176

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5751:0:b0:2de:b81:4c00 with SMTP id 17-20020ac85751000000b002de0b814c00mr10281963qtx.190.1647039231361;
Fri, 11 Mar 2022 14:53:51 -0800 (PST)
X-Received: by 2002:a05:6214:e6a:b0:435:cb88:d111 with SMTP id
jz10-20020a0562140e6a00b00435cb88d111mr9986323qvb.46.1647039231150; Fri, 11
Mar 2022 14:53:51 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 11 Mar 2022 14:53:50 -0800 (PST)
In-Reply-To: <f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=65.207.89.54; posting-account=I-_H_woAAAA9zzro6crtEpUAyIvzd19b
NNTP-Posting-Host: 65.207.89.54
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t0fjr2$6h3$1@dont-email.me>
<f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4d057f4b-2f5c-48b5-bb50-e418a9895304n@googlegroups.com>
Subject: Re: Optimizing #
From: gnuarm.d...@gmail.com (Rick C)
Injection-Date: Fri, 11 Mar 2022 22:53:51 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 65
 by: Rick C - Fri, 11 Mar 2022 22:53 UTC

On Friday, March 11, 2022 at 2:36:26 PM UTC-5, minf...@arcor.de wrote:
> Krishna Myneni schrieb am Freitag, 11. März 2022 um 14:46:12 UTC+1:
> > On 3/11/22 06:09, Anton Ertl wrote:
> > > The folloing description applies to Gforth, but I think that it
> > > applies to many Forth systems, because this aspect is derived from a
> > > common ancestor (probably one of Forth, Inc.'s early systems):
> > >
> > > The word # (used in, e.g., ".") internally calls UD/MOD, which
> > > requires two double-by-single divisions:
> > >
> > > : ud/mod ( ud1 u2 -- urem udquot ) \ gforth
> > > \G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
> > > \G quotient @i{udquot} and a single remainder @i{urem}.
> > > >r 0 r@ um/mod r> swap >r
> > > um/mod r> ;
> > >
> > > : # ( ud1 -- ud2 )
> > > base @ ud/mod rot dup 9 u>
> > > [ char A char 9 1+ - ] Literal and +
> > > '0' + hold ;
> > >
> > ...
> >
> > Interesting. UD/MOD is not present in kForth. When I looked at the
> > implementation of "#" it uses the non-standard word UTM/ to perform the
> > division, which should be far more expensive. So there's a significant
> > speedup to be had for number to string conversion here.
> > >
> > > Special-casing high=0 is beneficial in all cases.
> > >
> > > Special-casing base=#10 only helps the Skylake. On the other CPUs
> > > apparently division is cheap enough and the overhead of separating
> > > this case is expensive enough that separating this case does not pay
> > > off. The slowdown from this special case on the A72 is surprisingly
> > > large.
> > >
> > > Overall, my conclusion is to keep the high=0 special case, and forget
> > > about the base=#10 one.
> > >
> > Good to know. Thanks.
> >
> I was wondering whether there is much to be won by making #
> faster and thus more complex. I don't want negativity in here
> but # is practically always followed by some terminal output
> which is by magnitudes slower than #.

I thought # is commonly used in formatting strings which may or may not be coupled with terminal I/O, which is not always slow. I/O is not always on serial ports these days. Even if it were, once in a buffer, the I/O can be interrupt driven, with the main process having other things to do.

--

Rick C.

- Get 1,000 miles of free Supercharging
- Tesla referral code - https://ts.la/richard11209

Re: Optimizing #

<37739434-0ce8-45ed-978c-80924ea68898n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17177&group=comp.lang.forth#17177

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:4ee5:0:b0:435:4480:58da with SMTP id dv5-20020ad44ee5000000b00435448058damr9677803qvb.131.1647039714403;
Fri, 11 Mar 2022 15:01:54 -0800 (PST)
X-Received: by 2002:ac8:5a8f:0:b0:2e1:b34b:30f3 with SMTP id
c15-20020ac85a8f000000b002e1b34b30f3mr7892769qtc.77.1647039714245; Fri, 11
Mar 2022 15:01:54 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 11 Mar 2022 15:01:54 -0800 (PST)
In-Reply-To: <a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=65.207.89.54; posting-account=I-_H_woAAAA9zzro6crtEpUAyIvzd19b
NNTP-Posting-Host: 65.207.89.54
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <37739434-0ce8-45ed-978c-80924ea68898n@googlegroups.com>
Subject: Re: Optimizing #
From: gnuarm.d...@gmail.com (Rick C)
Injection-Date: Fri, 11 Mar 2022 23:01:54 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 22
 by: Rick C - Fri, 11 Mar 2022 23:01 UTC

On Friday, March 11, 2022 at 11:14:45 AM UTC-5, Brian Fox wrote:
> On Friday, March 11, 2022 at 8:04:20 AM UTC-5, Anton Ertl wrote:
>
> > Overall, my conclusion is to keep the high=0 special case, and forget
> > about the base=#10 one.
> >
> I have been noodling on this myself.
> It makes me wonder if we are breaking a rule of Forth by having one word, '#' used for two purposes:
> - Printing single cell integers
> - printing double integers
>
> # goes back a long way and was probably a compromise to save space in those days. (?)

When you say, two purposes, you mean to convert single precision words by making then double precision words before formatting? I suppose C does it with separate functions, but the print library code is pretty big from what I recall.

So # is used for double precision words. Would anything else need to change to work with single precision? I guess #> would also need to change. <# would not I think, but for consistency a synonym word would be appropriate.

--

Rick C.

+ Get 1,000 miles of free Supercharging
+ Tesla referral code - https://ts.la/richard11209

Re: Optimizing #

<c5c884f9-c26e-4eb9-a0ba-ce78c78340a3n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17179&group=comp.lang.forth#17179

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:1d0e:b0:43e:5905:e4ae with SMTP id e14-20020a0562141d0e00b0043e5905e4aemr1687873qvd.40.1647044887098;
Fri, 11 Mar 2022 16:28:07 -0800 (PST)
X-Received: by 2002:a05:622a:178b:b0:2e1:a5c3:e452 with SMTP id
s11-20020a05622a178b00b002e1a5c3e452mr10460260qtk.534.1647044886922; Fri, 11
Mar 2022 16:28:06 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 11 Mar 2022 16:28:06 -0800 (PST)
In-Reply-To: <2022Mar11.233731@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=84.30.53.30; posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 84.30.53.30
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t0fjr2$6h3$1@dont-email.me>
<f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com> <2022Mar11.233731@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c5c884f9-c26e-4eb9-a0ba-ce78c78340a3n@googlegroups.com>
Subject: Re: Optimizing #
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Sat, 12 Mar 2022 00:28:07 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 30
 by: Marcel Hendrix - Sat, 12 Mar 2022 00:28 UTC

On Friday, March 11, 2022 at 11:51:04 PM UTC+1, Anton Ertl wrote:
> "minf...@arcor.de" <minf...@arcor.de> writes:
> >I was wondering whether there is much to be won by making #
> >faster and thus more complex. I don't want negativity in here
> >but # is practically always followed by some terminal output
> >which is by magnitudes slower than #.
> Let's test the latter claim first:
>
> time gforth-fast -e ": foo 1000000 0 do 1111111111 . loop ; foo bye" >/dev/null
> real 0m0.310s
> user 0m0.310s
> sys 0m0.000s
> time gforth-fast -e ': foo 1000000 0 do ." 1111111111 " loop ; foo bye'
> ...
> real 0m1.267s
> user 0m0.298s
> sys 0m0.692s
>
> So # is indeed faster than output on an xterm, although not by a
> magnitude, much less magnitudes.
That depends on the OS, and on implementation preferences:

FORTH> : foo STD-I//O SET-IODEVICE cr timer-reset 1000000 0 do 1111111111 . loop STD-I/O SET-IODEVICE .elapsed ; foo
.... 1111111 1111111111 88.891 seconds elapsed. ok
( 2.184 seconds elapsed under the WSL2 )

FORTH> : foo FILE-I//O SET-IODEVICE cr timer-reset 1000000 0 do 1111111111 . loop STD-I//O SET-IODEVICE .elapsed ; foo 0.094 seconds elapsed. ok
( 0.092 seconds under the WSL2 )

-marcel

Re: Optimizing #

<t0h0h0$14p7$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17180&group=comp.lang.forth#17180

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sat, 12 Mar 2022 13:28:48 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t0h0h0$14p7$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<t0fjr2$6h3$1@dont-email.me>
<f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="37671"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sat, 12 Mar 2022 02:28 UTC

On 12/03/2022 06:36, minf...@arcor.de wrote:
> ...
> I was wondering whether there is much to be won by making #
> faster and thus more complex. I don't want negativity in here
> but # is practically always followed by some terminal output
> which is by magnitudes slower than #.

Agreed. I/O is slow. Perhaps the greatest application of numeric
string output is floating point and # does nothing for that.

Forth standards have largely ignored numeric string out, leaving it
as an exercise for users. Never mind it actually costs more to
implement that way. I recently replaced d. u. . in an Arduino forth
with (d.) (u.) (.) d. u. . The code for the latter occupied *less*
space than the original three.

Re: Optimizing #

<t0h15m$1c23$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17181&group=comp.lang.forth#17181

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sat, 12 Mar 2022 13:39:50 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t0h15m$1c23$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="45123"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sat, 12 Mar 2022 02:39 UTC

On 12/03/2022 03:14, Brian Fox wrote:
> On Friday, March 11, 2022 at 8:04:20 AM UTC-5, Anton Ertl wrote:
>
>> Overall, my conclusion is to keep the high=0 special case, and forget
>> about the base=#10 one.
>>
> I have been noodling on this myself.
> It makes me wonder if we are breaking a rule of Forth by having one word, '#' used for two purposes:
> - Printing single cell integers
> - printing double integers
>
> # goes back a long way and was probably a compromise to save space in those days. (?)

PolyForth offered doubles as an option. I don't recall whether # came
in single and double versions. For 16-bit forths, doubles is more
necessity than optional IMO.

Re: Optimizing #

<e43f4436-3635-4131-9863-ea0a5447a418n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17182&group=comp.lang.forth#17182

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5dcf:0:b0:2e1:baf1:502d with SMTP id e15-20020ac85dcf000000b002e1baf1502dmr5180272qtx.635.1647052829051;
Fri, 11 Mar 2022 18:40:29 -0800 (PST)
X-Received: by 2002:a05:6214:1cc2:b0:435:7195:784f with SMTP id
g2-20020a0562141cc200b004357195784fmr10155413qvd.59.1647052828868; Fri, 11
Mar 2022 18:40:28 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 11 Mar 2022 18:40:28 -0800 (PST)
In-Reply-To: <t0h0h0$14p7$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=65.207.89.54; posting-account=I-_H_woAAAA9zzro6crtEpUAyIvzd19b
NNTP-Posting-Host: 65.207.89.54
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t0fjr2$6h3$1@dont-email.me>
<f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com> <t0h0h0$14p7$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e43f4436-3635-4131-9863-ea0a5447a418n@googlegroups.com>
Subject: Re: Optimizing #
From: gnuarm.d...@gmail.com (Rick C)
Injection-Date: Sat, 12 Mar 2022 02:40:29 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 31
 by: Rick C - Sat, 12 Mar 2022 02:40 UTC

On Friday, March 11, 2022 at 9:28:55 PM UTC-5, dxforth wrote:
> On 12/03/2022 06:36, minf...@arcor.de wrote:
> > ...
> > I was wondering whether there is much to be won by making #
> > faster and thus more complex. I don't want negativity in here
> > but # is practically always followed by some terminal output
> > which is by magnitudes slower than #.
> Agreed. I/O is slow. Perhaps the greatest application of numeric
> string output is floating point and # does nothing for that.
>
> Forth standards have largely ignored numeric string out, leaving it
> as an exercise for users. Never mind it actually costs more to
> implement that way. I recently replaced d. u. . in an Arduino forth
> with (d.) (u.) (.) d. u. . The code for the latter occupied *less*
> space than the original three.

It is funny to think that relatively speaking, a small MCU has more powerful I/O than a PC. I have written code that would process serial I/O data via interrupt allowing the main code to continue on doing what it needs to get done. The serial interface caused virtually zero delay in the main code as long as there was enough horse power.

I also recall looking at a serial port handler under one of the early Windows, probably 3.1. It was so complex and convoluted that I could not understand what the guy was doing.

--

Rick C.

-- Get 1,000 miles of free Supercharging
-- Tesla referral code - https://ts.la/richard11209

Re: Optimizing #

<85bf6d00-490e-4f5d-963b-3d94aa860907n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17184&group=comp.lang.forth#17184

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:18a5:b0:2e1:920b:8b92 with SMTP id v37-20020a05622a18a500b002e1920b8b92mr11018169qtc.559.1647070564672;
Fri, 11 Mar 2022 23:36:04 -0800 (PST)
X-Received: by 2002:a05:620a:2481:b0:67b:39ef:b3eb with SMTP id
i1-20020a05620a248100b0067b39efb3ebmr8703021qkn.188.1647070564498; Fri, 11
Mar 2022 23:36:04 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 11 Mar 2022 23:36:04 -0800 (PST)
In-Reply-To: <c5c884f9-c26e-4eb9-a0ba-ce78c78340a3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:e5a0:bf6f:203c:e0b7;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:e5a0:bf6f:203c:e0b7
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t0fjr2$6h3$1@dont-email.me>
<f29a77fb-86d1-48d1-9283-0f359aa5cd1dn@googlegroups.com> <2022Mar11.233731@mips.complang.tuwien.ac.at>
<c5c884f9-c26e-4eb9-a0ba-ce78c78340a3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <85bf6d00-490e-4f5d-963b-3d94aa860907n@googlegroups.com>
Subject: Re: Optimizing #
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Sat, 12 Mar 2022 07:36:04 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 30
 by: Marcel Hendrix - Sat, 12 Mar 2022 07:36 UTC

On Saturday, March 12, 2022 at 1:28:08 AM UTC+1, Marcel Hendrix wrote:
> On Friday, March 11, 2022 at 11:51:04 PM UTC+1, Anton Ertl wrote:
> > "minf...@arcor.de" <minf...@arcor.de> writes:
> > >I was wondering whether there is much to be won by making #
> > >faster and thus more complex. I don't want negativity in here
> > >but # is practically always followed by some terminal output
> > >which is by magnitudes slower than #.
> > Let's test the latter claim first:
> >
> > time gforth-fast -e ": foo 1000000 0 do 1111111111 . loop ; foo bye" >/dev/null
> > real 0m0.310s
> > user 0m0.310s
> > sys 0m0.000s
> > time gforth-fast -e ': foo 1000000 0 do ." 1111111111 " loop ; foo bye'
> > ...
> > real 0m1.267s
> > user 0m0.298s
> > sys 0m0.692s
> >
> > So # is indeed faster than output on an xterm, although not by a
> > magnitude, much less magnitudes.
> That depends on the OS, and on implementation preferences:
>
> FORTH> : foo STD-I//O SET-IODEVICE cr timer-reset 1000000 0 do 1111111111 . loop STD-I/O SET-IODEVICE .elapsed ; foo
> ... 1111111 1111111111 88.891 seconds elapsed. ok
> ( 2.184 seconds elapsed under the WSL2 )
>
> FORTH> : foo FILE-I//O SET-IODEVICE cr timer-reset 1000000 0 do 1111111111 . loop STD-I//O SET-IODEVICE .elapsed ; foo 0.094 seconds elapsed. ok
> ( 0.092 seconds under the WSL2 )
>
> -marcel

Re: Optimizing #

<2022Mar12.084517@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17185&group=comp.lang.forth#17185

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sat, 12 Mar 2022 07:45:17 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 38
Message-ID: <2022Mar12.084517@mips.complang.tuwien.ac.at>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
Injection-Info: reader02.eternal-september.org; posting-host="0fe04f065c6dc0f3006a406de4fb4fc8";
logging-data="25197"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pxhD9qBCxrr6lSp6rAuqz"
Cancel-Lock: sha1:0fu9Kn90j6k4cm7NHJnu7kfvWlo=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sat, 12 Mar 2022 07:45 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>: ud/mod ( ud1 u2 -- urem udquot ) \ gforth
> \G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
> \G quotient @i{udquot} and a single remainder @i{urem}.
> >r 0 r@ um/mod r> swap >r
> um/mod r> ;

Looking at this again, I notice that the first um/mod is actually a
single-by-single division, so on Gforth (which has single-by-single
primitives) this can be improved:

: ud/mod ( ud1 u2 -- urem udquot ) \ gforth
\G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
\G quotient @i{udquot} and a single remainder @i{urem}.
dup >r u/mod r> swap >r
um/mod r> ;

On a Cortex-A72 (no double-by-single instructions on Aarch64) this
results in an improvement from:

2999656067 cycles:u
4916118703 instructions:u # 1.64 insns per cycle

to

2811393601 cycles:u
4604004500 instructions:u # 1.64 insns per cycle

Benchmark:

taskset -c 4 perf stat -e cycles:u -e instructions:u -r 10 gforth-fast -e ': print-nums 0 do 0 i <# #s #> 2drop loop ; 1000000 print-nums bye' >/dev/null

- 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 2021: https://euro.theforth.net/2021

Re: Optimizing #

<877d8zh5cd.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17188&group=comp.lang.forth#17188

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sat, 12 Mar 2022 01:45:22 -0800
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <877d8zh5cd.fsf@nightsong.com>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
<2022Mar11.183346@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="461ab813e257e477462da556fe6d0ea1";
logging-data="23544"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Us9dAuXJjFRPvl6TuckJy"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:1q4epGCR4LQxk3hNbztuBx+mFPM=
sha1:BHNw58Z5xR84qDNPOzXoH5//bKg=
 by: Paul Rubin - Sat, 12 Mar 2022 09:45 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> As for breaking a rule of Forth, the result of always dealing with
> doubles

Doubles were important when cells were 16 bits. With 32 or 64 bit
cells, do doubles matter as much as they once did? Singles are
important, and in some situations bignums are important.
Doubles... meh.

Re: Optimizing #

<t0htra$112s$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17191&group=comp.lang.forth#17191

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sat, 12 Mar 2022 21:49:15 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t0htra$112s$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
<2022Mar11.183346@mips.complang.tuwien.ac.at> <877d8zh5cd.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="33884"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sat, 12 Mar 2022 10:49 UTC

On 12/03/2022 20:45, Paul Rubin wrote:
> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> As for breaking a rule of Forth, the result of always dealing with
>> doubles
>
> Doubles were important when cells were 16 bits. With 32 or 64 bit
> cells, do doubles matter as much as they once did? Singles are
> important, and in some situations bignums are important.
> Doubles... meh.

How will you random access into files without doubles?

Re: Optimizing #

<2022Mar12.161440@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17197&group=comp.lang.forth#17197

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sat, 12 Mar 2022 15:14:40 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 27
Message-ID: <2022Mar12.161440@mips.complang.tuwien.ac.at>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com> <2022Mar11.183346@mips.complang.tuwien.ac.at> <877d8zh5cd.fsf@nightsong.com>
Injection-Info: reader02.eternal-september.org; posting-host="0fe04f065c6dc0f3006a406de4fb4fc8";
logging-data="21919"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9uX/+bc77YoT4uI8LaB01"
Cancel-Lock: sha1:gUlU1pApFCZ3mA7qz2uBEeE2ib0=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sat, 12 Mar 2022 15:14 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> As for breaking a rule of Forth, the result of always dealing with
>> doubles
>
>Doubles were important when cells were 16 bits. With 32 or 64 bit
>cells, do doubles matter as much as they once did?

For 32 bits, certainly. The number of cycles on my last 32-bit
computer overflowed an unsigned 32-bit cell in less than 4 seconds,
the number of instructions possibly even faster. The number of bytes
on my HDD overflowed an unsigned 32-bit value in the mid-90s.

Overflowing 64-bit cells is rare, though.

However, for any cell size I need double cells to implement division
through the multiplication with the reciprocal. See
<http://git.savannah.gnu.org/cgit/gforth.git/tree/stagediv.fs>

Bignums? What for?

- 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 2021: https://euro.theforth.net/2021

Re: Optimizing #

<87mthsgav3.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17234&group=comp.lang.forth#17234

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Mon, 14 Mar 2022 02:08:16 -0700
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <87mthsgav3.fsf@nightsong.com>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
<2022Mar11.183346@mips.complang.tuwien.ac.at>
<877d8zh5cd.fsf@nightsong.com>
<2022Mar12.161440@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="6c1e5e712540730ba042ff4a4d23f938";
logging-data="2516"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18R+lGXwQaXEq+I2baSd/lT"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:Wq7JGx7WdRobrSfJo3OfwZcl+08=
sha1:Hl3jhWki4c+5O+SWGcjxu6VFXzY=
 by: Paul Rubin - Mon, 14 Mar 2022 09:08 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> However, for any cell size I need double cells to implement division...
> Bignums? What for?

Bignums eliminate a whole class of bugs and headaches related to
integers being too narrow. Double cells to implement division, and iirc
M*/ requires triple cells. If you are computing with exact rationals,
the denominators often get pretty large. Bignums are also important in
cryptography. I seem to remember that there is a situation where to
accurately convert binary floating point numbers to decimal or vice
versa, you need bignums, so gcc incorporates a bigum library for that
purpose.

I would agree that most of this stuff doesn't come up in Forth that
often. Bignums would be out of place in traditional Forth.

Re: Optimizing #

<t0n2dc$1tad$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17235&group=comp.lang.forth#17235

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Mon, 14 Mar 2022 20:37:47 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t0n2dc$1tad$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
<2022Mar11.183346@mips.complang.tuwien.ac.at> <877d8zh5cd.fsf@nightsong.com>
<2022Mar12.161440@mips.complang.tuwien.ac.at> <87mthsgav3.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="62797"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Mon, 14 Mar 2022 09:37 UTC

On 14/03/2022 20:08, Paul Rubin wrote:
> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> However, for any cell size I need double cells to implement division...
>> Bignums? What for?
>
> Bignums eliminate a whole class of bugs and headaches related to
> integers being too narrow. Double cells to implement division, and iirc
> M*/ requires triple cells. If you are computing with exact rationals,
> the denominators often get pretty large. Bignums are also important in
> cryptography. I seem to remember that there is a situation where to
> accurately convert binary floating point numbers to decimal or vice
> versa, you need bignums, so gcc incorporates a bigum library for that
> purpose.
>
> I would agree that most of this stuff doesn't come up in Forth that
> often. Bignums would be out of place in traditional Forth.

'Accurate' f/p output display too it would seem. Just because something
was all the rage two decades ago doesn't mean one needed it then or now.
That Intel provided div/mul instructions which exactly mirrored UM/MOD UM*
suggests to me Forth got the basics right - at a time when C was telling
users they had to use either ints or longs.

Re: Optimizing #

<badc1dbd-45cc-4989-876e-c03ab667a13cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17236&group=comp.lang.forth#17236

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:58f:b0:2de:92c7:8859 with SMTP id c15-20020a05622a058f00b002de92c78859mr17608652qtb.191.1647251276177;
Mon, 14 Mar 2022 02:47:56 -0700 (PDT)
X-Received: by 2002:a05:620a:1722:b0:67d:8efe:d4e8 with SMTP id
az34-20020a05620a172200b0067d8efed4e8mr8462944qkb.327.1647251276009; Mon, 14
Mar 2022 02:47:56 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 14 Mar 2022 02:47:55 -0700 (PDT)
In-Reply-To: <87mthsgav3.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
<2022Mar11.183346@mips.complang.tuwien.ac.at> <877d8zh5cd.fsf@nightsong.com>
<2022Mar12.161440@mips.complang.tuwien.ac.at> <87mthsgav3.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <badc1dbd-45cc-4989-876e-c03ab667a13cn@googlegroups.com>
Subject: Re: Optimizing #
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Mon, 14 Mar 2022 09:47:56 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 12
 by: minf...@arcor.de - Mon, 14 Mar 2022 09:47 UTC

Paul Rubin schrieb am Montag, 14. März 2022 um 10:08:19 UTC+1:
>. I seem to remember that there is a situation where to
> accurately convert binary floating point numbers to decimal or vice
> versa, you need bignums, so gcc incorporates a bigum library for that
> purpose.

How come? F.ex. the mantissa of a IEEE754 float is 54 bit wide.
Conversion of all normalized floats with zero exponent to integer
and vice versa is lossless.

Out of that range it depends on the actual approximation definition.

Re: Optimizing #

<87ilsgg8no.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17237&group=comp.lang.forth#17237

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Mon, 14 Mar 2022 02:55:55 -0700
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <87ilsgg8no.fsf@nightsong.com>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
<2022Mar11.183346@mips.complang.tuwien.ac.at>
<877d8zh5cd.fsf@nightsong.com>
<2022Mar12.161440@mips.complang.tuwien.ac.at>
<87mthsgav3.fsf@nightsong.com>
<badc1dbd-45cc-4989-876e-c03ab667a13cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="6c1e5e712540730ba042ff4a4d23f938";
logging-data="31844"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QA5VarO3qeRLv88PhjpCT"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:lVc7l7sg+t+G+DTarJLDXenZ8n0=
sha1:JM6YByNsN0NQFdwC8p5UkV395bY=
 by: Paul Rubin - Mon, 14 Mar 2022 09:55 UTC

"minf...@arcor.de" <minforth@arcor.de> writes:
> Out of that range it depends on the actual approximation definition.

Well, you have to get the decimal digits right. I have never examined
this issue so don't know exactly why the bignums are required. I might
look into it sometime. It's possible I have some part of the story
wrong.

This seems to discuss it further down the page, but I haven't read it
all yet:

https://recompilermag.com/issues/issue-9/a-crash-course-on-floating-point-numbers-and-good-algorithms-for-printing-and-reading-them/

Decimal floating point seems like a good idea too, but that is more a
matter of wanting hardware support.

Re: Optimizing #

<87ee34g8j9.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17238&group=comp.lang.forth#17238

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Mon, 14 Mar 2022 02:58:34 -0700
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <87ee34g8j9.fsf@nightsong.com>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
<2022Mar11.183346@mips.complang.tuwien.ac.at>
<877d8zh5cd.fsf@nightsong.com> <t0htra$112s$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="6c1e5e712540730ba042ff4a4d23f938";
logging-data="31844"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19eC13shNeremslGswGlOgG"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:gBQPUxjTBHggMV6KnOTKFPBtmaE=
sha1:OlCY2lD41NG/a+XThRqgz5bMBBQ=
 by: Paul Rubin - Mon, 14 Mar 2022 09:58 UTC

dxforth <dxforth@gmail.com> writes:
> How will you random access into files without doubles?

lseek? :-) Although, if the files are > 4GB, the cpu these days
probably has 64 bit cells.

Re: Optimizing #

<1e52e23f-9643-4e7f-a44c-db85b920f0a4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17240&group=comp.lang.forth#17240

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:7dc8:0:b0:2e1:b3ec:6666 with SMTP id c8-20020ac87dc8000000b002e1b3ec6666mr15655382qte.556.1647253783821;
Mon, 14 Mar 2022 03:29:43 -0700 (PDT)
X-Received: by 2002:a05:622a:178b:b0:2e1:a5c3:e452 with SMTP id
s11-20020a05622a178b00b002e1a5c3e452mr17829026qtk.534.1647253783663; Mon, 14
Mar 2022 03:29:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 14 Mar 2022 03:29:43 -0700 (PDT)
In-Reply-To: <87ilsgg8no.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <a269ec26-32c1-4255-a611-4f68602e21edn@googlegroups.com>
<2022Mar11.183346@mips.complang.tuwien.ac.at> <877d8zh5cd.fsf@nightsong.com>
<2022Mar12.161440@mips.complang.tuwien.ac.at> <87mthsgav3.fsf@nightsong.com>
<badc1dbd-45cc-4989-876e-c03ab667a13cn@googlegroups.com> <87ilsgg8no.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1e52e23f-9643-4e7f-a44c-db85b920f0a4n@googlegroups.com>
Subject: Re: Optimizing #
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Mon, 14 Mar 2022 10:29:43 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 21
 by: minf...@arcor.de - Mon, 14 Mar 2022 10:29 UTC

Paul Rubin schrieb am Montag, 14. März 2022 um 10:55:58 UTC+1:
> "minf...@arcor.de" <minf...@arcor.de> writes:
> > Out of that range it depends on the actual approximation definition.
> Well, you have to get the decimal digits right. I have never examined
> this issue so don't know exactly why the bignums are required. I might
> look into it sometime. It's possible I have some part of the story
> wrong.
>
> This seems to discuss it further down the page, but I haven't read it
> all yet:
>
> https://recompilermag.com/issues/issue-9/a-crash-course-on-floating-point-numbers-and-good-algorithms-for-printing-and-reading-them/
>
> Decimal floating point seems like a good idea too, but that is more a
> matter of wanting hardware support.

We know that fp-numbers are mostly stored with base 2 and that conversion
to/from base 10 representation is not always possible without rounding.

But why slow fat bignum packages are required to do that rounding is beyond me.

Pages:1234
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor