Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

1: No code table for op: ++post


devel / comp.arch / Rounding mode

SubjectAuthor
* Rounding modeJames Harris
+* Re: Rounding modePaul A. Clayton
|`* Re: Rounding modeIvan Godard
| +* Re: Rounding modeJohn Dallman
| |`* Re: Rounding modeMitchAlsup
| | `* Re: Rounding modeTerje Mathisen
| |  `- Re: Rounding modeJohn Dallman
| `* Re: Rounding modeBernd Linsel
|  `- Re: Rounding modeMitchAlsup
+* Re: Rounding modeBGB
|`- Re: Rounding modeJames Harris
+* Re: Rounding modeMitchAlsup
|`* Re: Rounding modeJames Harris
| +- Re: Rounding modeMitchAlsup
| `- Re: Rounding modeBGB
`- Re: Rounding modeJosh Vanderhoof

1
Rounding mode

<sa4lr6$eie$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17676&group=comp.arch#17676

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: james.ha...@gmail.com (James Harris)
Newsgroups: comp.arch
Subject: Rounding mode
Date: Sun, 13 Jun 2021 11:15:02 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <sa4lr6$eie$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 13 Jun 2021 10:15:02 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3422ae2ca16b6746b68a2584234c7526";
logging-data="14926"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XfuFRa3Dti5ZPEaxcR8vvUCeoV2tLnZE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
Cancel-Lock: sha1:UyPBxqIgCxJItzuGTjDsxxQ+NhE=
Content-Language: en-US
X-Mozilla-News-Host: snews://news.eternal-september.org:563
 by: James Harris - Sun, 13 Jun 2021 10:15 UTC

Is there any consensus among CPU producers (or programmers, for that
matter) as to what rounding modes to have as defaults?

The potential rounding options I can think of are:

round down
round up
round towards zero
round away from zero
round nearest

Further, there are variants of the latter where a decision has to be
made as to what to do when two valid values are equally near. That leads
to six 'round nearest' options:

round nearest down
round nearest up
round nearest towards zero
round nearest away from zero
round nearest even
round nearest odd

meaning that a value should be rounded to the nearest acceptable value
but if a true value is exactly midway between two such values it should
be rounded as stated.

So I make it ten potential rounding modes altoegether. Any more?

As a guess, perhaps the most useful would be to use

round down for integer
round nearest even for floating point

but what are the defaults for various CPUs?

--
James Harris

Re: Rounding mode

<f3b6eb3c-ba7d-4e91-909e-334caaf7066en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17682&group=comp.arch#17682

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:a3cc:: with SMTP id m195mr12489083qke.433.1623592071803;
Sun, 13 Jun 2021 06:47:51 -0700 (PDT)
X-Received: by 2002:aca:33d4:: with SMTP id z203mr19112538oiz.51.1623592071606;
Sun, 13 Jun 2021 06:47:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sun, 13 Jun 2021 06:47:51 -0700 (PDT)
In-Reply-To: <sa4lr6$eie$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=96.241.172.78; posting-account=6JNn0QoAAAD-Scrkl0ClrfutZTkrOS9S
NNTP-Posting-Host: 96.241.172.78
References: <sa4lr6$eie$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f3b6eb3c-ba7d-4e91-909e-334caaf7066en@googlegroups.com>
Subject: Re: Rounding mode
From: paaroncl...@gmail.com (Paul A. Clayton)
Injection-Date: Sun, 13 Jun 2021 13:47:51 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Paul A. Clayton - Sun, 13 Jun 2021 13:47 UTC

On Sunday, June 13, 2021 at 6:15:05 AM UTC-4, James Harris wrote:
> Is there any consensus among CPU producers (or programmers, for that
> matter) as to what rounding modes to have as defaults?
>
> The potential rounding options I can think of are:
>
> round down
> round up
> round towards zero
> round away from zero
> round nearest
>
> Further, there are variants of the latter where a decision has to be
> made as to what to do when two valid values are equally near. That leads
> to six 'round nearest' options:
>
> round nearest down
> round nearest up
> round nearest towards zero
> round nearest away from zero
> round nearest even
> round nearest odd
>
> meaning that a value should be rounded to the nearest acceptable value
> but if a true value is exactly midway between two such values it should
> be rounded as stated.
>
> So I make it ten potential rounding modes altoegether. Any more?

One could generalize the rounding modes by declaring an offset to
be added. The offset could be fixed (in terms of relative magnitude,
probably with some consideration for denormals), sign-matching, or
sign-inverting.

One could then imagine a random offset with a linear or quasi-guassian
distribution. (I do not know if quasi-guassian rounding would be
useful, but it seems interesting and 'fitting' for approximation with
multiple partially independent error factors.)

The nature of the random number generation would also be considered
with reproducability (including detecting hardware errors) and regularity
(distance from quantum-style randomness).

I am not well-informed about numerical analysis, applications of
floating point, and other factors related to rounding modes, but the
above seems a comment worth posting until those with some expertise
respond.

Re: Rounding mode

<sa5b66$fld$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17688&group=comp.arch#17688

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: iva...@millcomputing.com (Ivan Godard)
Newsgroups: comp.arch
Subject: Re: Rounding mode
Date: Sun, 13 Jun 2021 09:19:19 -0700
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <sa5b66$fld$1@dont-email.me>
References: <sa4lr6$eie$1@dont-email.me>
<f3b6eb3c-ba7d-4e91-909e-334caaf7066en@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 13 Jun 2021 16:19:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bd7a90a9ee0fe45e179c466ca57568da";
logging-data="16045"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BMuFNXsRxLinLcJWMvWwJ"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:GXWvpLHBsBVE0tOMFCR9WTAOKIA=
In-Reply-To: <f3b6eb3c-ba7d-4e91-909e-334caaf7066en@googlegroups.com>
Content-Language: en-US
 by: Ivan Godard - Sun, 13 Jun 2021 16:19 UTC

On 6/13/2021 6:47 AM, Paul A. Clayton wrote:
> On Sunday, June 13, 2021 at 6:15:05 AM UTC-4, James Harris wrote:
>> Is there any consensus among CPU producers (or programmers, for that
>> matter) as to what rounding modes to have as defaults?
>>
>> The potential rounding options I can think of are:
>>
>> round down
>> round up
>> round towards zero
>> round away from zero
>> round nearest
>>
>> Further, there are variants of the latter where a decision has to be
>> made as to what to do when two valid values are equally near. That leads
>> to six 'round nearest' options:
>>
>> round nearest down
>> round nearest up
>> round nearest towards zero
>> round nearest away from zero
>> round nearest even
>> round nearest odd
>>
>> meaning that a value should be rounded to the nearest acceptable value
>> but if a true value is exactly midway between two such values it should
>> be rounded as stated.
>>
>> So I make it ten potential rounding modes altoegether. Any more?
>
> One could generalize the rounding modes by declaring an offset to
> be added. The offset could be fixed (in terms of relative magnitude,
> probably with some consideration for denormals), sign-matching, or
> sign-inverting.
>
> One could then imagine a random offset with a linear or quasi-guassian
> distribution. (I do not know if quasi-guassian rounding would be
> useful, but it seems interesting and 'fitting' for approximation with
> multiple partially independent error factors.)
>
> The nature of the random number generation would also be considered
> with reproducability (including detecting hardware errors) and regularity
> (distance from quantum-style randomness).
>
> I am not well-informed about numerical analysis, applications of
> floating point, and other factors related to rounding modes, but the
> above seems a comment worth posting until those with some expertise
> respond.
>

This is stochastic rounding
(https://en.wikipedia.org/wiki/Rounding#Stochastic_rounding), which has
been proposed many times, and I put it in the initial Mill. Then I
joined the 754 committee and they explained that it was a bad idea, and
I took it out.

Re: Rounding mode

<sa5bl1$lip$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17690&group=comp.arch#17690

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Rounding mode
Date: Sun, 13 Jun 2021 11:25:56 -0500
Organization: A noiseless patient Spider
Lines: 124
Message-ID: <sa5bl1$lip$1@dont-email.me>
References: <sa4lr6$eie$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 13 Jun 2021 16:27:13 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a42d2b92cadaeedce829b80789d1e739";
logging-data="22105"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SnUPBKYhpLSAhm4Qbn5QL"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:RjCgsyxAfUgyY8jMCTSVLPiQ4Ec=
In-Reply-To: <sa4lr6$eie$1@dont-email.me>
Content-Language: en-US
 by: BGB - Sun, 13 Jun 2021 16:25 UTC

On 6/13/2021 5:15 AM, James Harris wrote:
> Is there any consensus among CPU producers (or programmers, for that
> matter) as to what rounding modes to have as defaults?
>
> The potential rounding options I can think of are:
>
>   round down
>   round up
>   round towards zero
>   round away from zero
>   round nearest
>

In my CPU core, at present FPU ops are hard-wired to round-to-nearest
(for Double ops), with a modestly small probability of an incorrectly
rounded result. Probably for 99% of code it does not matter.

For FP SIMD ops (single or half precision), generally round-towards-zero
(truncate) is used, since this allows for cheaper / lower-latency format
converters (combined with denormal-as-zero semantics).

One possible merit of round towards zero (over round towards nearest):
Hard wired round towards zero is potentially cheaper;
Exactly reproducible when implemented with partial precision (*);
...

With the drawback:
Typically, computations will tend to drift towards zero.

*: Approximate round-to-nearest is not strictly reproducible, since
rounding may depend on things like number of bits which exist sub-ULP,
or if the rounding imposes a limit in terms of carry propagation (it may
not always be practical to round if doing so would result in a large
carry propagation).

Usual practice is to assume that FP results are not strictly
reproducible between systems or implementations, which avoids a lot of
issues here.

Some values are checked against fixed values for boot time sanity
checks, but these tend to be cases where my CPU core, main PC, and
theoretical value, tend to all agree with each other. These will
generally trigger if rounding behavior breaks in ways more significant
than the existing set of compromises.

A few game consoles had FPUs set to round towards zero, which can
apparently lead to slight deviations when emulated on systems with the
FPU set to "round to nearest". Generally effects "low%" speedruns or
similar (where one may aim to beat the game by doing as little as
possible, which frequently involves things like standing in one spot for
hours and waiting for rounding errors or similar to slowly push them
through a wall or similar).

For float to integer conversion, the general rule tends to be "round
toward negative infinity". However, this tends to have a more obvious
effect on the results.

There is also a potential difference when it comes to overflow behavior.
The more traditional behavior for overflow is to either clamp the value
to the integer range, or produce a special sentinel value (typically
0x80000000 or similar).

For many applications though, it may be more useful to produce a value
which follows modular wraparound semantics (as with integer wraparound).

Some ISA's have ended up with separate conversion ops for these cases.

In BJX2, currently, the integer conversion op produces a 64-bit integer
value. For narrower types, the compiler can generate code to can clamp
it themselves (or use a sign or zero extension operation if this is the
desired behavior).

The current implementation is neither saturate nor wrap, in that from
the way it is implemented, the result will more just "go wonky" if it
goes too far out of the 64-bit integer range (though, will behave as
wrap within this range). Effectively, the converter aligns the mantissa
by adding the FP value against a "gigantic zero" (larger than the
largest possible 64-bit integer), but the mantissa may become misaligned
if the FP value is larger than this "zero" (result is then "undefined").

In practice it doesn't seem like too much of an issue though. Most cases
which involve FP<->Integer conversion are also within the range where
the FP value can represent discrete integer values (which is a lot
smaller than the "giant zero" limit).

> Further, there are variants of the latter where a decision has to be
> made as to what to do when two valid values are equally near. That leads
> to six 'round nearest' options:
>
>   round nearest down
>   round nearest up
>   round nearest towards zero
>   round nearest away from zero
>   round nearest even
>   round nearest odd
>
> meaning that a value should be rounded to the nearest acceptable value
> but if a true value is exactly midway between two such values it should
> be rounded as stated.
>
> So I make it ten potential rounding modes altoegether. Any more?
>
> As a guess, perhaps the most useful would be to use
>
>   round down           for integer
>   round nearest even   for floating point
>
> but what are the defaults for various CPUs?
>
>

If the CPU were to implement IEEE rounding modes, then presumably the
default is:
Whatever the C library prefers;
Whatever happens to be 0 in whatever control-register is used to control
this;
....

Re: Rounding mode

<a539ffce-5ada-4d79-8b08-54b5d41f3955n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17691&group=comp.arch#17691

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:a3cc:: with SMTP id m195mr13332935qke.433.1623607018692;
Sun, 13 Jun 2021 10:56:58 -0700 (PDT)
X-Received: by 2002:a9d:7d05:: with SMTP id v5mr9582309otn.240.1623607018437;
Sun, 13 Jun 2021 10:56:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sun, 13 Jun 2021 10:56:58 -0700 (PDT)
In-Reply-To: <sa4lr6$eie$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:7916:6f80:6291:31c9;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:7916:6f80:6291:31c9
References: <sa4lr6$eie$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a539ffce-5ada-4d79-8b08-54b5d41f3955n@googlegroups.com>
Subject: Re: Rounding mode
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sun, 13 Jun 2021 17:56:58 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: MitchAlsup - Sun, 13 Jun 2021 17:56 UTC

On Sunday, June 13, 2021 at 5:15:05 AM UTC-5, James Harris wrote:
> Is there any consensus among CPU producers (or programmers, for that
> matter) as to what rounding modes to have as defaults?
>
> The potential rounding options I can think of are:
>
> round down
> round up
> round towards zero
> round away from zero
> round nearest
<
Round nearest even is the IEEE std.
<
Round nearest even has the unique property that if the result is ½ way
between the last representable value in a binade and the first representable
value in the higher binade, that one chooses the first of the next binade to
loose the lease amount of significance.
<
>
> Further, there are variants of the latter where a decision has to be
> made as to what to do when two valid values are equally near. That leads
> to six 'round nearest' options:
>
> round nearest down
> round nearest up
> round nearest towards zero
> round nearest away from zero
> round nearest even
> round nearest odd
<
These are not round nearest, but directed roundings.
>
> meaning that a value should be rounded to the nearest acceptable value
> but if a true value is exactly midway between two such values it should
> be rounded as stated.
>
> So I make it ten potential rounding modes altoegether. Any more?
>
> As a guess, perhaps the most useful would be to use
>
> round down for integer
> round nearest even for floating point
>
> but what are the defaults for various CPUs?
>
Round nearest even is the RM most (?ALL?) CPU default to.
>
> --
> James Harris

Re: Rounding mode

<ygn7dixebkm.fsf@y.z>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17700&group=comp.arch#17700

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx40.iad.POSTED!not-for-mail
From: x...@y.z (Josh Vanderhoof)
Newsgroups: comp.arch
Subject: Re: Rounding mode
References: <sa4lr6$eie$1@dont-email.me>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)
Reply-To: Josh Vanderhoof <jlv@mxsimulator.com>
Message-ID: <ygn7dixebkm.fsf@y.z>
Cancel-Lock: sha1:gJTwieTN2v1TuqlA7bsz+B/t5PA=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 32
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sun, 13 Jun 2021 20:47:38 UTC
Date: Sun, 13 Jun 2021 16:47:37 -0400
X-Received-Bytes: 1672
 by: Josh Vanderhoof - Sun, 13 Jun 2021 20:47 UTC

James Harris <james.harris.1@gmail.com> writes:

> Is there any consensus among CPU producers (or programmers, for that
> matter) as to what rounding modes to have as defaults?
>
> The potential rounding options I can think of are:
>
> round down
> round up
> round towards zero
> round away from zero
> round nearest
>
> Further, there are variants of the latter where a decision has to be
> made as to what to do when two valid values are equally near. That
> leads to six 'round nearest' options:
>
> round nearest down
> round nearest up
> round nearest towards zero
> round nearest away from zero
> round nearest even
> round nearest odd
>
> meaning that a value should be rounded to the nearest acceptable value
> but if a true value is exactly midway between two such values it
> should be rounded as stated.
>
> So I make it ten potential rounding modes altoegether. Any more?

I wouldn't mind a random rounding option where .1 has a 10% chance of
rounding up.

Re: Rounding mode

<memo.20210613225938.13980G@jgd.cix.co.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17702&group=comp.arch#17702

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jgd...@cix.co.uk (John Dallman)
Newsgroups: comp.arch
Subject: Re: Rounding mode
Date: Sun, 13 Jun 2021 22:59 +0100 (BST)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <memo.20210613225938.13980G@jgd.cix.co.uk>
References: <sa5b66$fld$1@dont-email.me>
Reply-To: jgd@cix.co.uk
Injection-Info: reader02.eternal-september.org; posting-host="e44ab2a858cca4d1647f652d8cf89c4d";
logging-data="624"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4aHrV+1zbEJLxwMsoTsxeimuDsTbK8tc="
Cancel-Lock: sha1:FdxEPAxbZciyY8hgtZ5Ye11QsQk=
 by: John Dallman - Sun, 13 Jun 2021 21:59 UTC

In article <sa5b66$fld$1@dont-email.me>, ivan@millcomputing.com (Ivan
Godard) wrote:

> This is stochastic rounding
> (https://en.wikipedia.org/wiki/Rounding#Stochastic_rounding), which
> has been proposed many times, and I put it in the initial Mill.
> Then I joined the 754 committee and they explained that it was a
> bad idea, and I took it out.

Unless I'm failing to understand something, stochastic rounding seems to
mean that calculations involving rounding aren't reliably repeatable.
This would make regression-testing software after changes a nightmare.

John

Re: Rounding mode

<544abe8c-c306-40f2-b530-d9fb569c5763n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17703&group=comp.arch#17703

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:a38d:: with SMTP id m135mr13518942qke.36.1623622079259;
Sun, 13 Jun 2021 15:07:59 -0700 (PDT)
X-Received: by 2002:a4a:8550:: with SMTP id l16mr10974691ooh.73.1623622079055;
Sun, 13 Jun 2021 15:07:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sun, 13 Jun 2021 15:07:58 -0700 (PDT)
In-Reply-To: <memo.20210613225938.13980G@jgd.cix.co.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:7916:6f80:6291:31c9;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:7916:6f80:6291:31c9
References: <sa5b66$fld$1@dont-email.me> <memo.20210613225938.13980G@jgd.cix.co.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <544abe8c-c306-40f2-b530-d9fb569c5763n@googlegroups.com>
Subject: Re: Rounding mode
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sun, 13 Jun 2021 22:07:59 +0000
Content-Type: text/plain; charset="UTF-8"
 by: MitchAlsup - Sun, 13 Jun 2021 22:07 UTC

On Sunday, June 13, 2021 at 4:59:41 PM UTC-5, John Dallman wrote:
> In article <sa5b66$fld$1...@dont-email.me>, iv...@millcomputing.com (Ivan
> Godard) wrote:
>
> > This is stochastic rounding
> > (https://en.wikipedia.org/wiki/Rounding#Stochastic_rounding), which
> > has been proposed many times, and I put it in the initial Mill.
> > Then I joined the 754 committee and they explained that it was a
> > bad idea, and I took it out.
> Unless I'm failing to understand something, stochastic rounding seems to
> mean that calculations involving rounding aren't reliably repeatable.
> This would make regression-testing software after changes a nightmare.
<
But it makes error analysis surveys easy !!
>
> John

Re: Rounding mode

<sa609m$e3a$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17706&group=comp.arch#17706

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2a0a-a544-189e-0-855f-b384-7a1e-79d.ipv6dyn.netcologne.de!not-for-mail
From: bl1-remo...@gmx.com (Bernd Linsel)
Newsgroups: comp.arch
Subject: Re: Rounding mode
Date: Mon, 14 Jun 2021 00:19:34 +0200
Organization: news.netcologne.de
Distribution: world
Message-ID: <sa609m$e3a$1@newsreader4.netcologne.de>
References: <sa4lr6$eie$1@dont-email.me>
<f3b6eb3c-ba7d-4e91-909e-334caaf7066en@googlegroups.com>
<sa5b66$fld$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 13 Jun 2021 22:19:34 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2a0a-a544-189e-0-855f-b384-7a1e-79d.ipv6dyn.netcologne.de:2a0a:a544:189e:0:855f:b384:7a1e:79d";
logging-data="14442"; mail-complaints-to="abuse@netcologne.de"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
In-Reply-To: <sa5b66$fld$1@dont-email.me>
 by: Bernd Linsel - Sun, 13 Jun 2021 22:19 UTC

On 13.06.2021 18:19, Ivan Godard wrote:
> On 6/13/2021 6:47 AM, Paul A. Clayton wrote:
>
> This is stochastic rounding
> (https://en.wikipedia.org/wiki/Rounding#Stochastic_rounding), which has
> been proposed many times, and I put it in the initial Mill. Then I
> joined the 754 committee and they explained that it was a bad idea, and
> I took it out.
May I ask you to outline shortly why it is a bad idea according to the
754 TC (expect for non-deterministically repeatable results)?

As far as I understand is the strength of stochastic rounding, that
rounding errors will outweigh each other in computing chains.

TIA
Bernd

Re: Rounding mode

<38c1201c-f8df-4c9c-92a8-22eb1b275dd6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17708&group=comp.arch#17708

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:252e:: with SMTP id gg14mr15741291qvb.55.1623625831202;
Sun, 13 Jun 2021 16:10:31 -0700 (PDT)
X-Received: by 2002:a05:6830:1d1:: with SMTP id r17mr11708197ota.5.1623625831011;
Sun, 13 Jun 2021 16:10:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sun, 13 Jun 2021 16:10:30 -0700 (PDT)
In-Reply-To: <sa609m$e3a$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:7916:6f80:6291:31c9;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:7916:6f80:6291:31c9
References: <sa4lr6$eie$1@dont-email.me> <f3b6eb3c-ba7d-4e91-909e-334caaf7066en@googlegroups.com>
<sa5b66$fld$1@dont-email.me> <sa609m$e3a$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <38c1201c-f8df-4c9c-92a8-22eb1b275dd6n@googlegroups.com>
Subject: Re: Rounding mode
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sun, 13 Jun 2021 23:10:31 +0000
Content-Type: text/plain; charset="UTF-8"
 by: MitchAlsup - Sun, 13 Jun 2021 23:10 UTC

On Sunday, June 13, 2021 at 5:19:36 PM UTC-5, Bernd Linsel wrote:
> On 13.06.2021 18:19, Ivan Godard wrote:
> > On 6/13/2021 6:47 AM, Paul A. Clayton wrote:
> >
> > This is stochastic rounding
> > (https://en.wikipedia.org/wiki/Rounding#Stochastic_rounding), which has
> > been proposed many times, and I put it in the initial Mill. Then I
> > joined the 754 committee and they explained that it was a bad idea, and
> > I took it out.
> May I ask you to outline shortly why it is a bad idea according to the
> 754 TC (expect for non-deterministically repeatable results)?
>
> As far as I understand is the strength of stochastic rounding, that
> rounding errors will outweigh each other in computing chains.
<
Stochastic is great for those situations where the numbers being manipulated
were derived by measurements (and include random errors therefrom).
<
Stochastic is terrible for those situations where the numbers are exact (pi,
e, ln2(e),....) or for those situations where Kahan is running test cases on your
implementation.
>
> TIA
> Bernd

Re: Rounding mode

<sa73mk$1ogn$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17725&group=comp.arch#17725

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!Z/OnjRNZ74xzNAVdC5cKTg.user.gioia.aioe.org.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Rounding mode
Date: Mon, 14 Jun 2021 10:23:49 +0200
Organization: Aioe.org NNTP Server
Lines: 28
Message-ID: <sa73mk$1ogn$1@gioia.aioe.org>
References: <sa5b66$fld$1@dont-email.me>
<memo.20210613225938.13980G@jgd.cix.co.uk>
<544abe8c-c306-40f2-b530-d9fb569c5763n@googlegroups.com>
NNTP-Posting-Host: Z/OnjRNZ74xzNAVdC5cKTg.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.7.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Mon, 14 Jun 2021 08:23 UTC

MitchAlsup wrote:
> On Sunday, June 13, 2021 at 4:59:41 PM UTC-5, John Dallman wrote:
>> In article <sa5b66$fld$1...@dont-email.me>, iv...@millcomputing.com (Ivan
>> Godard) wrote:
>>
>>> This is stochastic rounding
>>> (https://en.wikipedia.org/wiki/Rounding#Stochastic_rounding), which
>>> has been proposed many times, and I put it in the initial Mill.
>>> Then I joined the 754 committee and they explained that it was a
>>> bad idea, and I took it out.
>> Unless I'm failing to understand something, stochastic rounding seems to
>> mean that calculations involving rounding aren't reliably repeatable.
>> This would make regression-testing software after changes a nightmare.
> <
> But it makes error analysis surveys easy !!

It means that all verification work needs to be Monte Carlo, i.e. run a
bunch of times and verify that all the different results can be due to
rounding and that the final result has the expected distribution in the
lowest bits.

I.e. a lot more work than just a simple 8-byte compare.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Rounding mode

<memo.20210614105637.13980H@jgd.cix.co.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17728&group=comp.arch#17728

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jgd...@cix.co.uk (John Dallman)
Newsgroups: comp.arch
Subject: Re: Rounding mode
Date: Mon, 14 Jun 2021 10:56 +0100 (BST)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <memo.20210614105637.13980H@jgd.cix.co.uk>
References: <sa73mk$1ogn$1@gioia.aioe.org>
Reply-To: jgd@cix.co.uk
Injection-Info: reader02.eternal-september.org; posting-host="f17f766bf58742232e4b9b231f2532db";
logging-data="29682"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19C73NeS/gwWWnYnCrFZSlQhq+ebS09YdA="
Cancel-Lock: sha1:7kWAZdxUWknG58IuO81NGRhIHPA=
 by: John Dallman - Mon, 14 Jun 2021 09:56 UTC

In article <sa73mk$1ogn$1@gioia.aioe.org>, terje.mathisen@tmsw.no (Terje
Mathisen) wrote:

> It means that all verification work needs to be Monte Carlo, i.e.
> run a bunch of times and verify that all the different results can
> be due to rounding and that the final result has the expected
> distribution in the lowest bits.
>
> I.e. a lot more work than just a simple 8-byte compare.

Yes ... for some things, this is clearly impractical.

John

Re: Rounding mode

<sa7fsj$o7b$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17731&group=comp.arch#17731

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: james.ha...@gmail.com (James Harris)
Newsgroups: comp.arch
Subject: Re: Rounding mode
Date: Mon, 14 Jun 2021 12:51:46 +0100
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <sa7fsj$o7b$1@dont-email.me>
References: <sa4lr6$eie$1@dont-email.me>
<a539ffce-5ada-4d79-8b08-54b5d41f3955n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 14 Jun 2021 11:51:47 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="50b3367d838bd5b30a87477d98aa9bb9";
logging-data="24811"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18U0xSyVcz8WA1KXSGZR4BeQX9k9v+twfk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
Cancel-Lock: sha1:FqwNdzavZOhPzzgUBbd+w0a+lp8=
In-Reply-To: <a539ffce-5ada-4d79-8b08-54b5d41f3955n@googlegroups.com>
Content-Language: en-GB
 by: James Harris - Mon, 14 Jun 2021 11:51 UTC

On 13/06/2021 18:56, MitchAlsup wrote:
> On Sunday, June 13, 2021 at 5:15:05 AM UTC-5, James Harris wrote:

>> Is there any consensus among CPU producers (or programmers, for that
>> matter) as to what rounding modes to have as defaults?

....

> Round nearest even is the IEEE std.

....

> Round nearest even is the RM most (?ALL?) CPU default to.

Thanks, that's helpful to know. I take it you mean for floating point.

What about integers? Intel apparently chose for IDIV signed division:

Nonintegral quotients are truncated toward 0

Anyone know if it's the same for other processor architectures?

--
James Harris

Re: Rounding mode

<sa7gbu$spk$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17732&group=comp.arch#17732

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: james.ha...@gmail.com (James Harris)
Newsgroups: comp.arch
Subject: Re: Rounding mode
Date: Mon, 14 Jun 2021 12:59:58 +0100
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <sa7gbu$spk$1@dont-email.me>
References: <sa4lr6$eie$1@dont-email.me> <sa5bl1$lip$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 14 Jun 2021 11:59:58 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="50b3367d838bd5b30a87477d98aa9bb9";
logging-data="29492"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PjuZXD7ZFwtH6zK51esK2sP1OYkrN968="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
Cancel-Lock: sha1:IocyfMB56jYSWXRvEqcvJthR4Y0=
In-Reply-To: <sa5bl1$lip$1@dont-email.me>
Content-Language: en-GB
 by: James Harris - Mon, 14 Jun 2021 11:59 UTC

On 13/06/2021 17:25, BGB wrote:
> On 6/13/2021 5:15 AM, James Harris wrote:

>> Is there any consensus among CPU producers (or programmers, for that
>> matter) as to what rounding modes to have as defaults?

....

> For float to integer conversion, the general rule tends to be "round
> toward negative infinity". However, this tends to have a more obvious
> effect on the results.

Round towards negative infinity is, at least, easy for programmers to
deal with by adding 0.5.

--
James Harris

Re: Rounding mode

<8d354ac0-fe9d-417b-9d9d-da0c009c9b2bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17743&group=comp.arch#17743

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:5a44:: with SMTP id o4mr6206399qta.392.1623683522808; Mon, 14 Jun 2021 08:12:02 -0700 (PDT)
X-Received: by 2002:a9d:7612:: with SMTP id k18mr13525267otl.178.1623683522546; Mon, 14 Jun 2021 08:12:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!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.arch
Date: Mon, 14 Jun 2021 08:12:02 -0700 (PDT)
In-Reply-To: <sa7fsj$o7b$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:c61:3f99:736a:2902; posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:c61:3f99:736a:2902
References: <sa4lr6$eie$1@dont-email.me> <a539ffce-5ada-4d79-8b08-54b5d41f3955n@googlegroups.com> <sa7fsj$o7b$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8d354ac0-fe9d-417b-9d9d-da0c009c9b2bn@googlegroups.com>
Subject: Re: Rounding mode
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Mon, 14 Jun 2021 15:12:02 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 24
 by: MitchAlsup - Mon, 14 Jun 2021 15:12 UTC

On Monday, June 14, 2021 at 6:51:49 AM UTC-5, James Harris wrote:
> On 13/06/2021 18:56, MitchAlsup wrote:
> > On Sunday, June 13, 2021 at 5:15:05 AM UTC-5, James Harris wrote:
>
> >> Is there any consensus among CPU producers (or programmers, for that
> >> matter) as to what rounding modes to have as defaults?
> ...
> > Round nearest even is the IEEE std.
> ...
> > Round nearest even is the RM most (?ALL?) CPU default to.
> Thanks, that's helpful to know. I take it you mean for floating point.
>
> What about integers? Intel apparently chose for IDIV signed division:
>
> Nonintegral quotients are truncated toward 0
<
This makes MOD and REM straightforward.
>
> Anyone know if it's the same for other processor architectures?
<
The vast majority but not all.
>
>
> --
> James Harris

Re: Rounding mode

<sa7usf$qpt$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17753&group=comp.arch#17753

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Rounding mode
Date: Mon, 14 Jun 2021 11:06:26 -0500
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <sa7usf$qpt$1@dont-email.me>
References: <sa4lr6$eie$1@dont-email.me>
<a539ffce-5ada-4d79-8b08-54b5d41f3955n@googlegroups.com>
<sa7fsj$o7b$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 14 Jun 2021 16:07:44 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7a38c5fcca2554bde81b7affeb723955";
logging-data="27453"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GllOSlZgwqwRC+9J/sjwF"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:HIChv+vFMkUBqoks/JVFYhjJnVA=
In-Reply-To: <sa7fsj$o7b$1@dont-email.me>
Content-Language: en-US
 by: BGB - Mon, 14 Jun 2021 16:06 UTC

On 6/14/2021 6:51 AM, James Harris wrote:
> On 13/06/2021 18:56, MitchAlsup wrote:
>> On Sunday, June 13, 2021 at 5:15:05 AM UTC-5, James Harris wrote:
>
>>> Is there any consensus among CPU producers (or programmers, for that
>>> matter) as to what rounding modes to have as defaults?
>
> ...
>
>> Round nearest even is the IEEE std.
>
> ...
>
>> Round nearest even is the RM most (?ALL?) CPU default to.
>
> Thanks, that's helpful to know. I take it you mean for floating point.
>
> What about integers? Intel apparently chose for IDIV signed division:
>
>   Nonintegral quotients are truncated toward 0
>
> Anyone know if it's the same for other processor architectures?
>

Truncate toward zero is pretty much standard.
Similar to how modulo may be negative for negative values, ...

Not every architecture has hardware divide though.

For BJX2, I went the same direction as ARM / A32 and used a divider
implemented in software. I could in premise add special accelerator ops
(or potentially even a hardware divide instruction), but in common use,
divide is rare enough that the use of a pure software form is acceptable.

I can also note that on a few past PCs of mine (with a Phenom II and
Piledriver), the hardware divide instruction wasn't much faster than
doing the same basic divide loop in software.

Likewise, a few other options (such as using a lookup table of
reciprocals, which may then be shifted to accommodate a larger range),
can be somewhat faster (though, my own attempts at getting this approach
to be integer-exact had been unsuccessful, *).

It is possible to use this approach, followed by calculating the
remainder (R), and adjusting the result if (R>=Q), but this isn't free.

*: One might also expect this to be true of dividing by multiplying by a
constant reciprocal, but typically it is possible to fudge the
reciprocal upwards slightly such that the results come out correct.

For signed divide by reciprocal one may also need to conditionally add a
bias (based on the sign of the input value) such that the result rounds
towards zero (rather than towards negative infinity).

One generally wants to use constant-reciprocal when possible, as it
turns things like "x/1000" into an integer multiply and shift
(reasonably fast), vs using a C runtime call and divider loop (slow).

....

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor