Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

All extremists should be taken out and shot.


devel / comp.arch / Re: Approximate reciprocals

SubjectAuthor
* Approximate reciprocalsMarcus
+* Re: Approximate reciprocalsTerje Mathisen
|+- Re: Approximate reciprocalsrobf...@gmail.com
|+* Re: Approximate reciprocalsMarcus
||+- Re: Approximate reciprocalsMitchAlsup
||`* Re: Approximate reciprocalsTerje Mathisen
|| +- Re: Approximate reciprocalsMarcus
|| `- Re: Approximate reciprocalsMitchAlsup
|`* Re: Approximate reciprocalsQuadibloc
| `- Re: Approximate reciprocalsTerje Mathisen
+* Re: Approximate reciprocalsMitchAlsup
|+* Re: Approximate reciprocalsMarcus
||`* Re: Approximate reciprocalsMitchAlsup
|| `- Re: Approximate reciprocalsBGB
|`* Re: Approximate reciprocalsThomas Koenig
| `* Re: Approximate reciprocalsMitchAlsup
|  `* Re: Approximate reciprocalsThomas Koenig
|   +* Re: Approximate reciprocalsMichael S
|   |`* Re: Approximate reciprocalsThomas Koenig
|   | `* Re: Approximate reciprocalsMichael S
|   |  `* Re: Approximate reciprocalsThomas Koenig
|   |   `* Re: Approximate reciprocalsMichael S
|   |    `* Re: Approximate reciprocalsThomas Koenig
|   |     `* Re: Approximate reciprocalsMichael S
|   |      `* Re: Approximate reciprocalsMichael S
|   |       +* Re: Approximate reciprocalsTerje Mathisen
|   |       |+* Re: Approximate reciprocalsMitchAlsup
|   |       ||`* Re: Approximate reciprocalsTerje Mathisen
|   |       || `* Re: Approximate reciprocalsMitchAlsup
|   |       ||  +- Re: Approximate reciprocalsTerje Mathisen
|   |       ||  `- Re: Approximate reciprocalsQuadibloc
|   |       |`- Re: Approximate reciprocalsMichael S
|   |       `* Re: Approximate reciprocalsThomas Koenig
|   |        `* Re: Approximate reciprocalsMichael S
|   |         `* Re: Approximate reciprocalsThomas Koenig
|   |          `* Re: Approximate reciprocalsMichael S
|   |           `* Re: Approximate reciprocalsMichael S
|   |            +* Re: Approximate reciprocalsMitchAlsup
|   |            |`* Re: Approximate reciprocalsJames Van Buskirk
|   |            | `- Re: Approximate reciprocalsMitchAlsup
|   |            `* Re: Approximate reciprocalsThomas Koenig
|   |             `* Re: Approximate reciprocalsMichael S
|   |              +- Re: Approximate reciprocalsMichael S
|   |              +* Re: Approximate reciprocalsMitchAlsup
|   |              |`* Re: Approximate reciprocalsTerje Mathisen
|   |              | `* Re: Approximate reciprocalsMitchAlsup
|   |              |  +- Re: Approximate reciprocalsMichael S
|   |              |  `* Re: Approximate reciprocalsTerje Mathisen
|   |              |   `* Re: Approximate reciprocalsMitchAlsup
|   |              |    +- Re: Approximate reciprocalsMichael S
|   |              |    +- Re: Approximate reciprocalsMichael S
|   |              |    `- Re: Approximate reciprocalsTerje Mathisen
|   |              +* Re: Approximate reciprocalsMichael S
|   |              |`* Re: Approximate reciprocalsThomas Koenig
|   |              | +- Re: Approximate reciprocalsMichael S
|   |              | `* Re: Approximate reciprocalsTerje Mathisen
|   |              |  +- Re: Approximate reciprocalsQuadibloc
|   |              |  +* Re: Approximate reciprocalsThomas Koenig
|   |              |  |+- Re: Approximate reciprocalsMichael S
|   |              |  |+- Re: Approximate reciprocalsTerje Mathisen
|   |              |  |`* Re: Approximate reciprocalsMichael S
|   |              |  | `* Re: Approximate reciprocalsThomas Koenig
|   |              |  |  +- Re: Approximate reciprocalsMichael S
|   |              |  |  `* Re: Approximate reciprocalsMichael S
|   |              |  |   `* Re: Approximate reciprocalsThomas Koenig
|   |              |  |    `* Re: Approximate reciprocalsMichael S
|   |              |  |     `* Re: Approximate reciprocalsMichael S
|   |              |  |      `* Re: Approximate reciprocalsThomas Koenig
|   |              |  |       `* Re: Approximate reciprocalsMichael S
|   |              |  |        +* Re: Approximate reciprocalsrobf...@gmail.com
|   |              |  |        |`* Useful floating point instructions (was: Approximate reciprocals)Thomas Koenig
|   |              |  |        | `* Re: Useful floating point instructionsTerje Mathisen
|   |              |  |        |  `* Re: Useful floating point instructionsStephen Fuld
|   |              |  |        |   `* Re: Useful floating point instructionsMitchAlsup
|   |              |  |        |    `* Re: Useful floating point instructionsStephen Fuld
|   |              |  |        |     +- Re: Useful floating point instructionsMitchAlsup
|   |              |  |        |     +* Re: Useful floating point instructionsMichael S
|   |              |  |        |     |+- Re: Useful floating point instructionsStephen Fuld
|   |              |  |        |     |`- Re: Useful floating point instructionsTerje Mathisen
|   |              |  |        |     `* Re: Useful floating point instructionsTerje Mathisen
|   |              |  |        |      `- Re: Useful floating point instructionsStefan Monnier
|   |              |  |        +* Re: Approximate reciprocalsMichael S
|   |              |  |        |`* Re: Approximate reciprocalsGeorge Neuner
|   |              |  |        | +* Re: Approximate reciprocalsAnton Ertl
|   |              |  |        | |+* Re: Approximate reciprocalsMichael S
|   |              |  |        | ||`* Re: Approximate reciprocalsAnton Ertl
|   |              |  |        | || `- Re: Approximate reciprocalsMichael S
|   |              |  |        | |`* Re: Approximate reciprocalsGeorge Neuner
|   |              |  |        | | `* Re: Approximate reciprocalsAnton Ertl
|   |              |  |        | |  `* Re: Approximate reciprocalsMichael S
|   |              |  |        | |   `* Re: Approximate reciprocalsTerje Mathisen
|   |              |  |        | |    `* Re: Approximate reciprocalsMichael S
|   |              |  |        | |     `* Re: Approximate reciprocalsTerje Mathisen
|   |              |  |        | |      `- Re: Approximate reciprocalsMitchAlsup
|   |              |  |        | +- Re: Approximate reciprocalsMichael S
|   |              |  |        | `* Re: Approximate reciprocalsJohn Dallman
|   |              |  |        |  +- Re: Approximate reciprocalsMitchAlsup
|   |              |  |        |  `* Re: Approximate reciprocalsGeorge Neuner
|   |              |  |        |   +* Re: Approximate reciprocalsMichael S
|   |              |  |        |   |+* Re: Approximate reciprocalsEricP
|   |              |  |        |   ||`* Re: Approximate reciprocalsAnton Ertl
|   |              |  |        |   |`* Re: Approximate reciprocalsAnton Ertl
|   |              |  |        |   `* Re: Approximate reciprocalsJohn Dallman
|   |              |  |        +- Re: Approximate reciprocalsMichael S
|   |              |  |        `- Re: Approximate reciprocalsMichael S
|   |              |  `* Re: Approximate reciprocalsMichael S
|   |              `- Re: Approximate reciprocalsMichael S
|   `- Re: Approximate reciprocalsTerje Mathisen
+* Re: Approximate reciprocalsElijah Stone
+* Re: Approximate reciprocalsMarcus
`* Re: Approximate reciprocalsMarcus

Pages:12345678910111213
Re: Approximate reciprocals

<a88eac4c-6e04-48cf-a1bd-858de9076ffcn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:5fd2:0:b0:2e1:b346:7505 with SMTP id k18-20020ac85fd2000000b002e1b3467505mr32101285qta.94.1648637920047;
Wed, 30 Mar 2022 03:58:40 -0700 (PDT)
X-Received: by 2002:a05:6830:2708:b0:5cd:a8c2:7665 with SMTP id
j8-20020a056830270800b005cda8c27665mr2894480otu.144.1648637919774; Wed, 30
Mar 2022 03:58:39 -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: Wed, 30 Mar 2022 03:58:39 -0700 (PDT)
In-Reply-To: <t20t87$1k64$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <t1c154$j5t$1@dont-email.me> <t1fmss$i30$2@newsreader4.netcologne.de>
<5991ffcb-7857-49ba-9204-7201850b64a6n@googlegroups.com> <t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com> <t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com> <5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de> <ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de> <c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com> <t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com> <cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com> <cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a88eac4c-6e04-48cf-a1bd-858de9076ffcn@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Wed, 30 Mar 2022 10:58:40 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Wed, 30 Mar 2022 10:58 UTC

On Wednesday, March 30, 2022 at 9:27:22 AM UTC+3, Terje Mathisen wrote:
> Thomas Koenig wrote:
> > Michael S <already...@yahoo.com> schrieb:
> >>
> >> Of course, it's 1ULP.
> >> But, according to my understanding, sqrt() is one of those very
> >> few primitives for which IEEE-754 not just recommends > correct
> >> rounding, but requires correct rounding.
> >
> > This is now https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105101 .
> >
> Exact rounding rules are easy: All 5 core primitives
> (FADD/FSUB/FMUL/FDIV/FSQRT) for which it was known back in 1978 that it
> was relatively easy to always provide exact rounding, are in fact
> required to do so.
>
> Having a square root (for any supported fp size) which does not obey
> this is in fact a breaking bug.
>

Also various conversions to/from integer, right?
Probably, also binary scaling, including cases of normal-to-subnormal?

BTW, does it mean that "optional core" primitives, in particular, FMADD and FRSQRT,
if provided, are allowed to give inexact rounding?

> It is of course perfectly legal to provide an alternative "fastmath"
> library which disobeys these rules, but at that point you are not
> providing IEEE 754 math. I.e. Cray did this at some point, right?
>
> Similar issues with IBM hex math, but both of them was before 1978.
> Terje
>
> --
> - <Terje.Mathisen at tmsw.no>
> "almost all programming can be viewed as an exercise in caching"

Re: Approximate reciprocals

<t21do0$17qo$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!vJugTCfiOlzVSBkFE1Pr8w.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Approximate reciprocals
Date: Wed, 30 Mar 2022 13:08:47 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t21do0$17qo$1@gioia.aioe.org>
References: <t1c154$j5t$1@dont-email.me>
<5991ffcb-7857-49ba-9204-7201850b64a6n@googlegroups.com>
<t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com>
<t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com>
<5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de>
<ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org>
<t215f3$9o7$1@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="40792"; posting-host="vJugTCfiOlzVSBkFE1Pr8w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.11.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Wed, 30 Mar 2022 11:08 UTC

Thomas Koenig wrote:
> Terje Mathisen <terje.mathisen@tmsw.no> schrieb:
>> Thomas Koenig wrote:
>>> Michael S <already5chosen@yahoo.com> schrieb:
>>>>
>>>> Of course, it's 1ULP.
>>>> But, according to my understanding, sqrt() is one of those very
>>>> few primitives for which IEEE-754 not just recommends > correct
>>>> rounding, but requires correct rounding.
>>>
>>> This is now https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105101 .
>>>
>>
>> Exact rounding rules are easy: All 5 core primitives
>> (FADD/FSUB/FMUL/FDIV/FSQRT) for which it was known back in 1978 that it
>> was relatively easy to always provide exact rounding, are in fact
>> required to do so.
>>
>> Having a square root (for any supported fp size) which does not obey
>> this is in fact a breaking bug.
>
> It's a wrong-code bug (and I have marked it as such). Compilers and
> libraries are known to have these, even thougn, in an ideal world,
> they should not exist.
>
> It is certainly too late to fix for gcc12 (regression-mode only),
> but gcc13 should be doable.
>
> Hmm... for those who are in the know about IEEE standards (which
> cost money :-(): Does sqrt need to follow rounding modes?
>
YES!

All those core ops have to abide by the current/actual rounding mode.

Trancendentals etc are different, there you will almost always try for
the best possible result, rounded according to nearest_or_even.

Terje

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

Re: Approximate reciprocals

<t21ei6$1ns1$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!vJugTCfiOlzVSBkFE1Pr8w.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Approximate reciprocals
Date: Wed, 30 Mar 2022 13:22:45 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t21ei6$1ns1$1@gioia.aioe.org>
References: <t1c154$j5t$1@dont-email.me>
<t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com>
<t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com>
<5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de>
<ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org>
<a88eac4c-6e04-48cf-a1bd-858de9076ffcn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="57217"; posting-host="vJugTCfiOlzVSBkFE1Pr8w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.11.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Wed, 30 Mar 2022 11:22 UTC

Michael S wrote:
> On Wednesday, March 30, 2022 at 9:27:22 AM UTC+3, Terje Mathisen wrote:
>> Thomas Koenig wrote:
>>> Michael S <already...@yahoo.com> schrieb:
>>>>
>>>> Of course, it's 1ULP.
>>>> But, according to my understanding, sqrt() is one of those very
>>>> few primitives for which IEEE-754 not just recommends > correct
>>>> rounding, but requires correct rounding.
>>>
>>> This is now https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105101 .
>>>
>> Exact rounding rules are easy: All 5 core primitives
>> (FADD/FSUB/FMUL/FDIV/FSQRT) for which it was known back in 1978 that it
>> was relatively easy to always provide exact rounding, are in fact
>> required to do so.
>>
>> Having a square root (for any supported fp size) which does not obey
>> this is in fact a breaking bug.
>>
>
> Also various conversions to/from integer, right?

Most int-to-FP conversions are exact, unless you are converting to float
or fp16, but if you have to round, then you must do so correctly.

float-to-int will by default use the current rounding mode, so usually
nearest-or-even, but due to very heavy use of C int casting most
architectures have special operations to do truncation or arbitrary
directed rounding.

> Probably, also binary scaling, including cases of normal-to-subnormal?

Converting from a normal double which becomes a subnormal float is an
example of those grandfathered "round either before or after discovering
that it is subnormal" exceptions, but the correct choise imho is to
first align the mantissa correctly, then round.
>
> BTW, does it mean that "optional core" primitives, in particular, FMADD and FRSQRT,
> if provided, are allowed to give inexact rounding?

FMAC/FMADD pretty much have to use the same rules as FADD/FMUL, i.e.
exact rounding but I don't remember if it is required. You could
obviously claim it as an extension, not part of the 754 instruction set.

See below:
>
>> It is of course perfectly legal to provide an alternative "fastmath"
>> library which disobeys these rules, but at that point you are not
>> providing IEEE 754 math. I.e. Cray did this at some point, right?

Terje

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

Re: Approximate reciprocals

<1b5bd111-40f0-41e7-9025-787e49f0fd02n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:622a:c3:b0:2e3:4bd0:16c2 with SMTP id p3-20020a05622a00c300b002e34bd016c2mr28989921qtw.575.1648640977345;
Wed, 30 Mar 2022 04:49:37 -0700 (PDT)
X-Received: by 2002:a05:6808:55:b0:2ec:a4ae:fdde with SMTP id
v21-20020a056808005500b002eca4aefddemr1548160oic.106.1648640977019; Wed, 30
Mar 2022 04:49:37 -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: Wed, 30 Mar 2022 04:49:36 -0700 (PDT)
In-Reply-To: <t20qrb$4lp$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:c157:5622:f280:8961;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:c157:5622:f280:8961
References: <t1c154$j5t$1@dont-email.me> <t1qf0u$oko$1@dont-email.me>
<t1qkql$ui0$1@newsreader4.netcologne.de> <394168eb-53ed-49c2-a349-4035c3177361n@googlegroups.com>
<t1rm34$pg9$1@gioia.aioe.org> <7029a173-963d-402b-a184-642120b5e1b8n@googlegroups.com>
<4bdfaba8-898f-4c1e-8ca1-234bf4d3ffc8n@googlegroups.com> <t1vd17$5bj$1@newsreader4.netcologne.de>
<1d99080f-3c84-4a44-b2cf-271c2f3f7e90n@googlegroups.com> <t1vkm4$ar2$1@newsreader4.netcologne.de>
<dc571956-dddd-469a-8b8e-30017e37d5bbn@googlegroups.com> <t20qrb$4lp$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1b5bd111-40f0-41e7-9025-787e49f0fd02n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Wed, 30 Mar 2022 11:49:37 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: MitchAlsup - Wed, 30 Mar 2022 11:49 UTC

On Wednesday, March 30, 2022 at 12:46:22 AM UTC-5, Thomas Koenig wrote:
> MitchAlsup <Mitch...@aol.com> schrieb:
> > On Tuesday, March 29, 2022 at 1:55:03 PM UTC-5, Thomas Koenig wrote:
> >> MitchAlsup <Mitch...@aol.com> schrieb:
> >> > On Tuesday, March 29, 2022 at 11:45:08 AM UTC-5, Thomas Koenig wrote:
> >>
> >> >> I've looked at the optimum Remez polynomial for 1/x in the range
> >> >> of 1..2. It is 70/33 - 16/11 * x + 32/99 * x**2, with a weight of x
> >> >> (so optimizing for the relative error).
> >> >>
> >> >> The maximum relative error is 1/99, reached at four points in the
> >> >> interval [1..2], so around 6.62 bits of minimum accuracy.
> >> ><
> >> > I stated way above::---------------------------------------------------------------------------------------
> >> > Equivalent to::
> >> ><
> >> > .33333×x^2 - 1.5×x + 2.1666
> >> ><
> >> > The Chebychev 2nd order Coefficients on the interval [1..2) are:
> >> ><
> >> > 0.32323232×x^2 -0.48484848×x + 0.66666667
> >> There is somethig wrong with your formula. f(1) would be
> >> 0.32323232 - 0.48484848 + 0.66666667 = 0.50505051, which does
> >> not even closely approximate 1/1 = 1. Is there some rescaling
> >> somewhere?
> >> ><
> >> > with 6.63 bits of accuracy.
> >> ><-------------------------------------------------------------------------------------------------------------------
> >> > Why does your Remez get less precision than Chebychev ?
> >> Absolute or relative precision? As I wrote above, I used relative
> ><
> > Mine was relative (too)
> Easy enough to check. What was the actual formula you
> arrived at? Not the one you wrote above, obviously.
<
=IF(AA29=0,-99,LOG(ABS(AA29),2))
>
> (And for 6.63 vs. 6.62 - I rounded down log[2](1/99) not to
> overstate the accuracy :-)
<
-6.630927

Re: Approximate reciprocals

<dd502a1c-07c6-40df-8d67-b7d07c6e3f88n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:cc3:b0:440:f5fc:f1ab with SMTP id 3-20020a0562140cc300b00440f5fcf1abmr29741095qvx.59.1648641426775;
Wed, 30 Mar 2022 04:57:06 -0700 (PDT)
X-Received: by 2002:a05:6870:9604:b0:de:a876:fbba with SMTP id
d4-20020a056870960400b000dea876fbbamr1794141oaq.239.1648641426498; Wed, 30
Mar 2022 04:57:06 -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: Wed, 30 Mar 2022 04:57:06 -0700 (PDT)
In-Reply-To: <t20sj1$1dtk$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:c157:5622:f280:8961;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:c157:5622:f280:8961
References: <t1c154$j5t$1@dont-email.me> <t1fmss$i30$2@newsreader4.netcologne.de>
<5991ffcb-7857-49ba-9204-7201850b64a6n@googlegroups.com> <t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com> <t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com> <5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de> <ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de> <c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com> <t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com> <cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com> <t1uvnn$1tc8$1@gioia.aioe.org>
<118dffef-fc0c-4607-9528-dc8afa64adafn@googlegroups.com> <t20sj1$1dtk$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dd502a1c-07c6-40df-8d67-b7d07c6e3f88n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Wed, 30 Mar 2022 11:57:06 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: MitchAlsup - Wed, 30 Mar 2022 11:57 UTC

On Wednesday, March 30, 2022 at 1:16:06 AM UTC-5, Terje Mathisen wrote:
> MitchAlsup wrote:
> >> Do you have a numeric example? Any error at all in FDIV is simply a bug,
> > <
> > https://www.cl.cam.ac.uk/~jrh13/slides/gelato-25may05/slides.pdf
> That pdf shows 0.50x accuracy for most of the trancendentals, but not a
> single mention of doing the same on FDIV, rather the opposite:
<
0.50x is not correctly rounded. 0.500... is correctly rounded.
<
I can't find the paper on FDIV and SQRT from Itanium by Markstein and somebody
that I read (Oh so many) years ago.
>
> > Exploiting non-atomic division
> > On Itanium, there’s no atomic division operation, but frcpa returns a
> > reciprocal approximation good to about 8 bits.
> > Techniques largely due to Markstein allow this to be refined to an
> > IEEE-correct quotient just using standard fma operations.
> Terje
>
> --
> - <Terje.Mathisen at tmsw.no>
> "almost all programming can be viewed as an exercise in caching"

Re: Approximate reciprocals

<fe487b40-477b-467b-a73b-a87ad6e1a4f4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:28ca:b0:67f:3f2b:c1e0 with SMTP id l10-20020a05620a28ca00b0067f3f2bc1e0mr23992860qkp.111.1648646317808;
Wed, 30 Mar 2022 06:18:37 -0700 (PDT)
X-Received: by 2002:a9d:6c58:0:b0:5cd:8ccb:c128 with SMTP id
g24-20020a9d6c58000000b005cd8ccbc128mr3200977otq.254.1648646317535; Wed, 30
Mar 2022 06:18:37 -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: Wed, 30 Mar 2022 06:18:37 -0700 (PDT)
In-Reply-To: <dd502a1c-07c6-40df-8d67-b7d07c6e3f88n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <t1c154$j5t$1@dont-email.me> <t1fmss$i30$2@newsreader4.netcologne.de>
<5991ffcb-7857-49ba-9204-7201850b64a6n@googlegroups.com> <t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com> <t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com> <5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de> <ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de> <c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com> <t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com> <cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com> <t1uvnn$1tc8$1@gioia.aioe.org>
<118dffef-fc0c-4607-9528-dc8afa64adafn@googlegroups.com> <t20sj1$1dtk$1@gioia.aioe.org>
<dd502a1c-07c6-40df-8d67-b7d07c6e3f88n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fe487b40-477b-467b-a73b-a87ad6e1a4f4n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Wed, 30 Mar 2022 13:18:37 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Michael S - Wed, 30 Mar 2022 13:18 UTC

On Wednesday, March 30, 2022 at 2:57:08 PM UTC+3, MitchAlsup wrote:
> On Wednesday, March 30, 2022 at 1:16:06 AM UTC-5, Terje Mathisen wrote:
> > MitchAlsup wrote:
> > >> Do you have a numeric example? Any error at all in FDIV is simply a bug,
> > > <
> > > https://www.cl.cam.ac.uk/~jrh13/slides/gelato-25may05/slides.pdf
> > That pdf shows 0.50x accuracy for most of the trancendentals, but not a
> > single mention of doing the same on FDIV, rather the opposite:
> <
> 0.50x is not correctly rounded. 0.500... is correctly rounded.
> <
> I can't find the paper on FDIV and SQRT from Itanium by Markstein and somebody
> that I read (Oh so many) years ago.

Did the book ever existed in electronic form? I mean, outside of HP?

> >
> > > Exploiting non-atomic division
> > > On Itanium, there’s no atomic division operation, but frcpa returns a
> > > reciprocal approximation good to about 8 bits.
> > > Techniques largely due to Markstein allow this to be refined to an
> > > IEEE-correct quotient just using standard fma operations.
> > Terje
> >
> > --
> > - <Terje.Mathisen at tmsw.no>
> > "almost all programming can be viewed as an exercise in caching"

Re: Approximate reciprocals

<5c800480-c18f-41a9-af17-253ac189e4adn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ae9:f444:0:b0:67e:7985:8331 with SMTP id z4-20020ae9f444000000b0067e79858331mr23457282qkl.465.1648646637609;
Wed, 30 Mar 2022 06:23:57 -0700 (PDT)
X-Received: by 2002:a05:6870:9590:b0:de:27ca:c60c with SMTP id
k16-20020a056870959000b000de27cac60cmr2161872oao.108.1648646637303; Wed, 30
Mar 2022 06:23:57 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!2.eu.feeder.erje.net!3.us.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.arch
Date: Wed, 30 Mar 2022 06:23:57 -0700 (PDT)
In-Reply-To: <fe487b40-477b-467b-a73b-a87ad6e1a4f4n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <t1c154$j5t$1@dont-email.me> <t1fmss$i30$2@newsreader4.netcologne.de>
<5991ffcb-7857-49ba-9204-7201850b64a6n@googlegroups.com> <t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com> <t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com> <5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de> <ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de> <c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com> <t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com> <cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com> <t1uvnn$1tc8$1@gioia.aioe.org>
<118dffef-fc0c-4607-9528-dc8afa64adafn@googlegroups.com> <t20sj1$1dtk$1@gioia.aioe.org>
<dd502a1c-07c6-40df-8d67-b7d07c6e3f88n@googlegroups.com> <fe487b40-477b-467b-a73b-a87ad6e1a4f4n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5c800480-c18f-41a9-af17-253ac189e4adn@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Wed, 30 Mar 2022 13:23:57 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 37
 by: Michael S - Wed, 30 Mar 2022 13:23 UTC

On Wednesday, March 30, 2022 at 4:18:39 PM UTC+3, Michael S wrote:
> On Wednesday, March 30, 2022 at 2:57:08 PM UTC+3, MitchAlsup wrote:
> > On Wednesday, March 30, 2022 at 1:16:06 AM UTC-5, Terje Mathisen wrote:
> > > MitchAlsup wrote:
> > > >> Do you have a numeric example? Any error at all in FDIV is simply a bug,
> > > > <
> > > > https://www.cl.cam.ac.uk/~jrh13/slides/gelato-25may05/slides.pdf
> > > That pdf shows 0.50x accuracy for most of the trancendentals, but not a
> > > single mention of doing the same on FDIV, rather the opposite:
> > <
> > 0.50x is not correctly rounded. 0.500... is correctly rounded.
> > <
> > I can't find the paper on FDIV and SQRT from Itanium by Markstein and somebody
> > that I read (Oh so many) years ago.
> Did the book ever existed in electronic form? I mean, outside of HP?

Or, may be, you mean that?
https://www.researchgate.net/publication/2413714_High_Precision_Division_and_Square_Root

> > >
> > > > Exploiting non-atomic division
> > > > On Itanium, there’s no atomic division operation, but frcpa returns a
> > > > reciprocal approximation good to about 8 bits.
> > > > Techniques largely due to Markstein allow this to be refined to an
> > > > IEEE-correct quotient just using standard fma operations.
> > > Terje
> > >
> > > --
> > > - <Terje.Mathisen at tmsw.no>
> > > "almost all programming can be viewed as an exercise in caching"

Re: Approximate reciprocals

<t21mrt$1sf6$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!vJugTCfiOlzVSBkFE1Pr8w.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Approximate reciprocals
Date: Wed, 30 Mar 2022 15:44:28 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t21mrt$1sf6$1@gioia.aioe.org>
References: <t1c154$j5t$1@dont-email.me>
<5991ffcb-7857-49ba-9204-7201850b64a6n@googlegroups.com>
<t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com>
<t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com>
<5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de>
<ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<t1uvnn$1tc8$1@gioia.aioe.org>
<118dffef-fc0c-4607-9528-dc8afa64adafn@googlegroups.com>
<t20sj1$1dtk$1@gioia.aioe.org>
<dd502a1c-07c6-40df-8d67-b7d07c6e3f88n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="61926"; posting-host="vJugTCfiOlzVSBkFE1Pr8w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.11.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Wed, 30 Mar 2022 13:44 UTC

MitchAlsup wrote:
> On Wednesday, March 30, 2022 at 1:16:06 AM UTC-5, Terje Mathisen wrote:
>> MitchAlsup wrote:
>>>> Do you have a numeric example? Any error at all in FDIV is simply a bug,
>>> <
>>> https://www.cl.cam.ac.uk/~jrh13/slides/gelato-25may05/slides.pdf
>> That pdf shows 0.50x accuracy for most of the trancendentals, but not a
>> single mention of doing the same on FDIV, rather the opposite:
> <
> 0.50x is not correctly rounded. 0.500... is correctly rounded.

Of course, wasn't that clear from what I wrote?

Trancendentals are OK with "best effort", core ops have to be perfect.

In fact, even 0.500... isn't automatically correct, you have to also
obey the "or_even" part of the rounding rule, but you know that at least
as well as me. :-)

Terje

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

Re: Approximate reciprocals

<a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:a24a:0:b0:67b:4836:fe95 with SMTP id l71-20020a37a24a000000b0067b4836fe95mr583730qke.109.1648661834773;
Wed, 30 Mar 2022 10:37:14 -0700 (PDT)
X-Received: by 2002:a05:6870:e9a7:b0:de:e59a:7376 with SMTP id
r39-20020a056870e9a700b000dee59a7376mr426774oao.194.1648661834519; Wed, 30
Mar 2022 10:37:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!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: Wed, 30 Mar 2022 10:37:14 -0700 (PDT)
In-Reply-To: <t215f3$9o7$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <t1c154$j5t$1@dont-email.me> <t1fmss$i30$2@newsreader4.netcologne.de>
<5991ffcb-7857-49ba-9204-7201850b64a6n@googlegroups.com> <t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com> <t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com> <5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de> <ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de> <c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com> <t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com> <cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com> <cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org> <t215f3$9o7$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Wed, 30 Mar 2022 17:37:14 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 94
 by: Michael S - Wed, 30 Mar 2022 17:37 UTC

On Wednesday, March 30, 2022 at 11:47:34 AM UTC+3, Thomas Koenig wrote:
> Terje Mathisen <terje.m...@tmsw.no> schrieb:
> > Thomas Koenig wrote:
> >> Michael S <already...@yahoo.com> schrieb:
> >>>
> >>> Of course, it's 1ULP.
> >>> But, according to my understanding, sqrt() is one of those very
> >>> few primitives for which IEEE-754 not just recommends > correct
> >>> rounding, but requires correct rounding.
> >>
> >> This is now https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105101 .
> >>
> >
> > Exact rounding rules are easy: All 5 core primitives
> > (FADD/FSUB/FMUL/FDIV/FSQRT) for which it was known back in 1978 that it
> > was relatively easy to always provide exact rounding, are in fact
> > required to do so.
> >
> > Having a square root (for any supported fp size) which does not obey
> > this is in fact a breaking bug.
> It's a wrong-code bug (and I have marked it as such). Compilers and
> libraries are known to have these, even thougn, in an ideal world,
> they should not exist.
>
> It is certainly too late to fix for gcc12 (regression-mode only),
> but gcc13 should be doable.
>
> Hmm... for those who are in the know about IEEE standards (which
> cost money :-(): Does sqrt need to follow rounding modes?

It seems, I found 100 times more serious quadmath bug than mere bad rounding in sqrtq().
On my system fmaq() call appears to change global rounding mode!

Demonstration:

// qsum.c
#include <quadmath.h>

__float128 qsum(__float128 a, __float128 b)
{ return a + b;
} // end of qsum.c

// qadd.c
#include <stdio.h>
#include <quadmath.h>

__float128 qsum(__float128 a, __float128 b);
int main(int argz, char** argv)
{ __float128 x[2];
int idx = 0;
for (int arg_i = 1; arg_i < argz; ++arg_i) {
char* arg = argv[arg_i];
char* endp;
x[idx % 2] = strtoflt128(arg, &endp);
if (arg != endp) {
++idx;
if ((idx % 2)==0) {
char buf[256];
__float128 dummy = 0;
__float128 sum0 = qsum(x[0], x[1]);
dummy = fmaq(x[0], x[0], x[0]);
__float128 sum1 = qsum(x[0], x[1]);
quadmath_snprintf(buf, sizeof(buf), "%-+46.36Qe", x[0]);
printf("%s x[0]\n", buf);
quadmath_snprintf(buf, sizeof(buf), "%-+46.36Qe", x[1]);
printf("%s x[1]\n", buf);
quadmath_snprintf(buf, sizeof(buf), "%-+46.36Qe", sum0);
printf("%s x[0]+x[1].\n", buf);
quadmath_snprintf(buf, sizeof(buf), "%-+46.36Qe", sum1);
printf("%s x[0]+x[1] after fmaq().\n", buf);
quadmath_snprintf(buf, sizeof(buf), "%-+46.36Qe", dummy);
printf("%s dummy\n", buf);
}
}
}
return 0;
} // end of qadd.c

Compile as
gcc -Wall -O2 qsum.c qadd.c -lquadmath

$ ./a 1 -1e-100
+1.000000000000000000000000000000000000e+00 x[0]
-1.000000000000000000000000000000000035e-100 x[1]
+1.000000000000000000000000000000000000e+00 x[0]+x[1].
+9.999999999999999999999999999999999037e-01 x[0]+x[1] after fmaq().
+2.000000000000000000000000000000000000e+00 dummy

Re: Approximate reciprocals

<t22705$2jl$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!news.freedyn.de!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd6-30bd-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Approximate reciprocals
Date: Wed, 30 Mar 2022 18:19:49 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <t22705$2jl$1@newsreader4.netcologne.de>
References: <t1c154$j5t$1@dont-email.me> <t1qf0u$oko$1@dont-email.me>
<t1qkql$ui0$1@newsreader4.netcologne.de>
<394168eb-53ed-49c2-a349-4035c3177361n@googlegroups.com>
<t1rm34$pg9$1@gioia.aioe.org>
<7029a173-963d-402b-a184-642120b5e1b8n@googlegroups.com>
<4bdfaba8-898f-4c1e-8ca1-234bf4d3ffc8n@googlegroups.com>
<t1vd17$5bj$1@newsreader4.netcologne.de>
<1d99080f-3c84-4a44-b2cf-271c2f3f7e90n@googlegroups.com>
<t1vkm4$ar2$1@newsreader4.netcologne.de>
<dc571956-dddd-469a-8b8e-30017e37d5bbn@googlegroups.com>
<t20qrb$4lp$1@newsreader4.netcologne.de>
<1b5bd111-40f0-41e7-9025-787e49f0fd02n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 30 Mar 2022 18:19:49 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd6-30bd-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd6:30bd:0:7285:c2ff:fe6c:992d";
logging-data="2677"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Wed, 30 Mar 2022 18:19 UTC

MitchAlsup <MitchAlsup@aol.com> schrieb:
> On Wednesday, March 30, 2022 at 12:46:22 AM UTC-5, Thomas Koenig wrote:
>> MitchAlsup <Mitch...@aol.com> schrieb:
>> > On Tuesday, March 29, 2022 at 1:55:03 PM UTC-5, Thomas Koenig wrote:
>> >> MitchAlsup <Mitch...@aol.com> schrieb:
>> >> > On Tuesday, March 29, 2022 at 11:45:08 AM UTC-5, Thomas Koenig wrote:
>> >>
>> >> >> I've looked at the optimum Remez polynomial for 1/x in the range
>> >> >> of 1..2. It is 70/33 - 16/11 * x + 32/99 * x**2, with a weight of x
>> >> >> (so optimizing for the relative error).
>> >> >>
>> >> >> The maximum relative error is 1/99, reached at four points in the
>> >> >> interval [1..2], so around 6.62 bits of minimum accuracy.
>> >> ><
>> >> > I stated way above::---------------------------------------------------------------------------------------
>> >> > Equivalent to::
>> >> ><
>> >> > .33333×x^2 - 1.5×x + 2.1666
>> >> ><
>> >> > The Chebychev 2nd order Coefficients on the interval [1..2) are:
>> >> ><
>> >> > 0.32323232×x^2 -0.48484848×x + 0.66666667

This is the formula we are discussing.

>> >> There is somethig wrong with your formula. f(1) would be
>> >> 0.32323232 - 0.48484848 + 0.66666667 = 0.50505051, which does
>> >> not even closely approximate 1/1 = 1. Is there some rescaling
>> >> somewhere?
>> >> ><
>> >> > with 6.63 bits of accuracy.
>> >> ><-------------------------------------------------------------------------------------------------------------------
>> >> > Why does your Remez get less precision than Chebychev ?
>> >> Absolute or relative precision? As I wrote above, I used relative
>> ><
>> > Mine was relative (too)
>> Easy enough to check. What was the actual formula you
>> arrived at? Not the one you wrote above, obviously.
><
>=IF(AA29=0,-99,LOG(ABS(AA29),2))

.... and this is a formula for calculating an error.

We seem to have a disconnect here somewhere.

We were discussing a second-degree polynomial approximation to 1/x.
The formula you gave doesn't have anything close to 6 bits of
accuracy, it has _zero_ bits of accuracy (as I showed for the case
of x=1 above).

So I'm not sure what you are in fact approximating. I would, however,
like to compare your Chebyshev formula for 1/x with the Remez formula
I gave above.

Could you give that Chebyshev formula for 1/x?

Re: Approximate reciprocals

<fabfec7e-27ab-45be-a728-3879b82da3a7n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:2487:b0:67b:3113:f83f with SMTP id i7-20020a05620a248700b0067b3113f83fmr1017133qkn.604.1648669723578;
Wed, 30 Mar 2022 12:48:43 -0700 (PDT)
X-Received: by 2002:a05:6808:55:b0:2ec:a4ae:fdde with SMTP id
v21-20020a056808005500b002eca4aefddemr814553oic.106.1648669723302; Wed, 30
Mar 2022 12:48:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.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.arch
Date: Wed, 30 Mar 2022 12:48:43 -0700 (PDT)
In-Reply-To: <t22705$2jl$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:69e5:44c4:61de:32b7;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:69e5:44c4:61de:32b7
References: <t1c154$j5t$1@dont-email.me> <t1qf0u$oko$1@dont-email.me>
<t1qkql$ui0$1@newsreader4.netcologne.de> <394168eb-53ed-49c2-a349-4035c3177361n@googlegroups.com>
<t1rm34$pg9$1@gioia.aioe.org> <7029a173-963d-402b-a184-642120b5e1b8n@googlegroups.com>
<4bdfaba8-898f-4c1e-8ca1-234bf4d3ffc8n@googlegroups.com> <t1vd17$5bj$1@newsreader4.netcologne.de>
<1d99080f-3c84-4a44-b2cf-271c2f3f7e90n@googlegroups.com> <t1vkm4$ar2$1@newsreader4.netcologne.de>
<dc571956-dddd-469a-8b8e-30017e37d5bbn@googlegroups.com> <t20qrb$4lp$1@newsreader4.netcologne.de>
<1b5bd111-40f0-41e7-9025-787e49f0fd02n@googlegroups.com> <t22705$2jl$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fabfec7e-27ab-45be-a728-3879b82da3a7n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Wed, 30 Mar 2022 19:48:43 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 68
 by: Michael S - Wed, 30 Mar 2022 19:48 UTC

On Wednesday, March 30, 2022 at 9:19:52 PM UTC+3, Thomas Koenig wrote:
> MitchAlsup <Mitch...@aol.com> schrieb:
> > On Wednesday, March 30, 2022 at 12:46:22 AM UTC-5, Thomas Koenig wrote:
> >> MitchAlsup <Mitch...@aol.com> schrieb:
> >> > On Tuesday, March 29, 2022 at 1:55:03 PM UTC-5, Thomas Koenig wrote:
> >> >> MitchAlsup <Mitch...@aol.com> schrieb:
> >> >> > On Tuesday, March 29, 2022 at 11:45:08 AM UTC-5, Thomas Koenig wrote:
> >> >>
> >> >> >> I've looked at the optimum Remez polynomial for 1/x in the range
> >> >> >> of 1..2. It is 70/33 - 16/11 * x + 32/99 * x**2, with a weight of x
> >> >> >> (so optimizing for the relative error).
> >> >> >>
> >> >> >> The maximum relative error is 1/99, reached at four points in the
> >> >> >> interval [1..2], so around 6.62 bits of minimum accuracy.
> >> >> ><
> >> >> > I stated way above::---------------------------------------------------------------------------------------
> >> >> > Equivalent to::
> >> >> ><
> >> >> > .33333×x^2 - 1.5×x + 2.1666
> >> >> ><
> >> >> > The Chebychev 2nd order Coefficients on the interval [1..2) are:
> >> >> ><
> >> >> > 0.32323232×x^2 -0.48484848×x + 0.66666667
> This is the formula we are discussing.
> >> >> There is somethig wrong with your formula. f(1) would be
> >> >> 0.32323232 - 0.48484848 + 0.66666667 = 0.50505051, which does
> >> >> not even closely approximate 1/1 = 1. Is there some rescaling
> >> >> somewhere?
> >> >> ><
> >> >> > with 6.63 bits of accuracy.
> >> >> ><-------------------------------------------------------------------------------------------------------------------
> >> >> > Why does your Remez get less precision than Chebychev ?
> >> >> Absolute or relative precision? As I wrote above, I used relative
> >> ><
> >> > Mine was relative (too)
> >> Easy enough to check. What was the actual formula you
> >> arrived at? Not the one you wrote above, obviously.
> ><
> >=IF(AA29=0,-99,LOG(ABS(AA29),2))
> ... and this is a formula for calculating an error.
>
> We seem to have a disconnect here somewhere.
>
> We were discussing a second-degree polynomial approximation to 1/x.
> The formula you gave doesn't have anything close to 6 bits of
> accuracy, it has _zero_ bits of accuracy (as I showed for the case
> of x=1 above).
>

He gave poly on interval [2:1] instead of [1:2].
After affine transformation (in Matlab/Octave polyaffine(pp, [3 -1]) ) it's
the same poly as yours, except that Mitch rounded coefficients to 8 decimal places.

> So I'm not sure what you are in fact approximating. I would, however,
> like to compare your Chebyshev formula for 1/x with the Remez formula
> I gave above.
>
> Could you give that Chebyshev formula for 1/x?

Re: Approximate reciprocals

<t22c73$5b4$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!news.freedyn.de!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd6-30bd-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Approximate reciprocals
Date: Wed, 30 Mar 2022 19:48:51 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <t22c73$5b4$1@newsreader4.netcologne.de>
References: <t1c154$j5t$1@dont-email.me>
<t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com>
<t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com>
<5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de>
<ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org>
<t215f3$9o7$1@newsreader4.netcologne.de>
<a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com>
Injection-Date: Wed, 30 Mar 2022 19:48:51 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd6-30bd-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd6:30bd:0:7285:c2ff:fe6c:992d";
logging-data="5476"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Wed, 30 Mar 2022 19:48 UTC

Michael S <already5chosen@yahoo.com> schrieb:

> On my system fmaq() call appears to change global rounding mode!

> Compile as
> gcc -Wall -O2 qsum.c qadd.c -lquadmath
>
> $ ./a 1 -1e-100
> +1.000000000000000000000000000000000000e+00 x[0]
> -1.000000000000000000000000000000000035e-100 x[1]
> +1.000000000000000000000000000000000000e+00 x[0]+x[1].
> +9.999999999999999999999999999999999037e-01 x[0]+x[1] after fmaq().
> +2.000000000000000000000000000000000000e+00 dummy

On Linux, I get

$ ./a.out 1 1e-100
+1.000000000000000000000000000000000000e+00 x[0]
+1.000000000000000000000000000000000035e-100 x[1]
+1.000000000000000000000000000000000000e+00 x[0]+x[1].
+1.000000000000000000000000000000000000e+00 x[0]+x[1] after fmaq().
+2.000000000000000000000000000000000000e+00 dummy

so the behavior appears to be platform-dependent. It might be
best to contact the maintainers of the platform you use on Windows
(Cygwin, MinGW or something else?)

Re: Approximate reciprocals

<b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:258e:b0:680:f33c:dbcd with SMTP id x14-20020a05620a258e00b00680f33cdbcdmr1049171qko.542.1648670484510;
Wed, 30 Mar 2022 13:01:24 -0700 (PDT)
X-Received: by 2002:a05:6870:1692:b0:dd:9dc0:1747 with SMTP id
j18-20020a056870169200b000dd9dc01747mr749697oae.205.1648670484206; Wed, 30
Mar 2022 13:01:24 -0700 (PDT)
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.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.arch
Date: Wed, 30 Mar 2022 13:01:24 -0700 (PDT)
In-Reply-To: <t22c73$5b4$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:69e5:44c4:61de:32b7;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:69e5:44c4:61de:32b7
References: <t1c154$j5t$1@dont-email.me> <t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com> <t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com> <5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de> <ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de> <c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com> <t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com> <cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com> <cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org>
<t215f3$9o7$1@newsreader4.netcologne.de> <a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com>
<t22c73$5b4$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Wed, 30 Mar 2022 20:01:24 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 30
 by: Michael S - Wed, 30 Mar 2022 20:01 UTC

On Wednesday, March 30, 2022 at 10:48:53 PM UTC+3, Thomas Koenig wrote:
> Michael S <already...@yahoo.com> schrieb:
> > On my system fmaq() call appears to change global rounding mode!
> > Compile as
> > gcc -Wall -O2 qsum.c qadd.c -lquadmath
> >
> > $ ./a 1 -1e-100
> > +1.000000000000000000000000000000000000e+00 x[0]
> > -1.000000000000000000000000000000000035e-100 x[1]
> > +1.000000000000000000000000000000000000e+00 x[0]+x[1].
> > +9.999999999999999999999999999999999037e-01 x[0]+x[1] after fmaq().
> > +2.000000000000000000000000000000000000e+00 dummy
> On Linux, I get
>
> $ ./a.out 1 1e-100
> +1.000000000000000000000000000000000000e+00 x[0]
> +1.000000000000000000000000000000000035e-100 x[1]
> +1.000000000000000000000000000000000000e+00 x[0]+x[1].
> +1.000000000000000000000000000000000000e+00 x[0]+x[1] after fmaq().
> +2.000000000000000000000000000000000000e+00 dummy
>

Wrong sign in command line parameter.
Should be './a.out 1 -1e-100'

> so the behavior appears to be platform-dependent. It might be
> best to contact the maintainers of the platform you use on Windows
> (Cygwin, MinGW or something else?)

Mingw64, a.k.a MSYS2.
I was never able to figure out who are maintainers.

Re: Approximate reciprocals

<10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:5c85:0:b0:2e2:3211:92e9 with SMTP id r5-20020ac85c85000000b002e2321192e9mr6694354qta.386.1648770653539;
Thu, 31 Mar 2022 16:50:53 -0700 (PDT)
X-Received: by 2002:a05:6871:810:b0:de:68ff:e846 with SMTP id
q16-20020a056871081000b000de68ffe846mr3945359oap.58.1648770653265; Thu, 31
Mar 2022 16:50:53 -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.arch
Date: Thu, 31 Mar 2022 16:50:53 -0700 (PDT)
In-Reply-To: <b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:19df:8c31:d539:f407;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:19df:8c31:d539:f407
References: <t1c154$j5t$1@dont-email.me> <t1helc$mtc$1@newsreader4.netcologne.de>
<b58e87e7-5cad-4867-835e-ea84b192b230n@googlegroups.com> <t1i106$4jp$1@newsreader4.netcologne.de>
<4a14747b-b131-4619-af63-e87caa1186cen@googlegroups.com> <5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de> <ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de> <c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com> <t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com> <cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com> <cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org>
<t215f3$9o7$1@newsreader4.netcologne.de> <a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com>
<t22c73$5b4$1@newsreader4.netcologne.de> <b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Thu, 31 Mar 2022 23:50:53 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 44
 by: Michael S - Thu, 31 Mar 2022 23:50 UTC

On Wednesday, March 30, 2022 at 11:01:26 PM UTC+3, Michael S wrote:
> On Wednesday, March 30, 2022 at 10:48:53 PM UTC+3, Thomas Koenig wrote:
> > Michael S <already...@yahoo.com> schrieb:
> > > On my system fmaq() call appears to change global rounding mode!
> > > Compile as
> > > gcc -Wall -O2 qsum.c qadd.c -lquadmath
> > >
> > > $ ./a 1 -1e-100
> > > +1.000000000000000000000000000000000000e+00 x[0]
> > > -1.000000000000000000000000000000000035e-100 x[1]
> > > +1.000000000000000000000000000000000000e+00 x[0]+x[1].
> > > +9.999999999999999999999999999999999037e-01 x[0]+x[1] after fmaq().
> > > +2.000000000000000000000000000000000000e+00 dummy
> > On Linux, I get
> >
> > $ ./a.out 1 1e-100
> > +1.000000000000000000000000000000000000e+00 x[0]
> > +1.000000000000000000000000000000000035e-100 x[1]
> > +1.000000000000000000000000000000000000e+00 x[0]+x[1].
> > +1.000000000000000000000000000000000000e+00 x[0]+x[1] after fmaq().
> > +2.000000000000000000000000000000000000e+00 dummy
> >
> Wrong sign in command line parameter.
> Should be './a.out 1 -1e-100'
> > so the behavior appears to be platform-dependent. It might be
> > best to contact the maintainers of the platform you use on Windows
> > (Cygwin, MinGW or something else?)
> Mingw64, a.k.a MSYS2.
> I was never able to figure out who are maintainers.

Today I spent way to many hours installing Linux with dev environment
on top of WSL on WS2019. Neither Debian nor Ubuntu were able to get
their development packages through corporate crapware (firewall, antvirii
and who knows what else). At the end I sort of succeeded with OpenSUSE.
Sort of, because in order to open basic bach I still need Windows Admin privilege.
But that's off topic. The bottom line is that I was to compile and both quadmath
and mpfr.

Indeed, under Linux I don't see a broken fmaq().
But I see quite horrible precision bugs in sqrtq().
E.g. 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024 delivers result that is off by 32 ULP!

Re: Approximate reciprocals

<t267e2$11p$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: not_va...@comcast.net (James Van Buskirk)
Newsgroups: comp.arch
Subject: Re: Approximate reciprocals
Date: Fri, 1 Apr 2022 00:51:34 -0600
Organization: A noiseless patient Spider
Lines: 1
Message-ID: <t267e2$11p$1@dont-email.me>
References: <t1c154$j5t$1@dont-email.me> <t1qf0u$oko$1@dont-email.me> <t1qkql$ui0$1@newsreader4.netcologne.de> <394168eb-53ed-49c2-a349-4035c3177361n@googlegroups.com> <t1rm34$pg9$1@gioia.aioe.org> <7029a173-963d-402b-a184-642120b5e1b8n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="UTF-8";
reply-type=original
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Apr 2022 06:51:46 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="25ad16b5a8a29f2470b297f771357c82";
logging-data="1081"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WsEO76sKTSpiNFQNzKvcA/hVwud7k2NA="
Cancel-Lock: sha1:1CFQYR/rx0Hs1b3YgfgOwECvdQw=
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
In-Reply-To: <7029a173-963d-402b-a184-642120b5e1b8n@googlegroups.com>
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
Importance: Normal
X-Priority: 3
X-MSMail-Priority: Normal
 by: James Van Buskirk - Fri, 1 Apr 2022 06:51 UTC

"Michael S" wrote in message
news:7029a173-963d-402b-a184-642120b5e1b8n@googlegroups.com...

> The reason for this is that Chebychev poly of order N is defined as the
> best
> approximation for poly of order N+1. So, when term N+1 in infinite Tailor
> series is much bigger than sum of terms N+2 to Infinity then Cheby is
> good, but
> when term N+1 is not dominant it is less good.

True if best means infinity norm, but there are other choices if your
standard is L1 norm or L2 norm.

Re: Approximate reciprocals

<43ef8109-9b9b-4114-800e-7b108c509fcen@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:622a:196:b0:2e0:705c:35b2 with SMTP id s22-20020a05622a019600b002e0705c35b2mr7770342qtw.567.1648804018706;
Fri, 01 Apr 2022 02:06:58 -0700 (PDT)
X-Received: by 2002:a05:6870:d249:b0:dd:ada6:736b with SMTP id
h9-20020a056870d24900b000ddada6736bmr4552713oac.27.1648804018495; Fri, 01 Apr
2022 02:06:58 -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.arch
Date: Fri, 1 Apr 2022 02:06:58 -0700 (PDT)
In-Reply-To: <t267e2$11p$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:f898:b5c9:4118:3b2a;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:f898:b5c9:4118:3b2a
References: <t1c154$j5t$1@dont-email.me> <t1qf0u$oko$1@dont-email.me>
<t1qkql$ui0$1@newsreader4.netcologne.de> <394168eb-53ed-49c2-a349-4035c3177361n@googlegroups.com>
<t1rm34$pg9$1@gioia.aioe.org> <7029a173-963d-402b-a184-642120b5e1b8n@googlegroups.com>
<t267e2$11p$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <43ef8109-9b9b-4114-800e-7b108c509fcen@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Fri, 01 Apr 2022 09:06:58 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 22
 by: Michael S - Fri, 1 Apr 2022 09:06 UTC

On Friday, April 1, 2022 at 9:51:49 AM UTC+3, James Van Buskirk wrote:
> "Michael S" wrote in message
> news:7029a173-963d-402b...@googlegroups.com...
>
> > The reason for this is that Chebychev poly of order N is defined as the
> > best
> > approximation for poly of order N+1. So, when term N+1 in infinite Tailor
> > series is much bigger than sum of terms N+2 to Infinity then Cheby is
> > good, but
> > when term N+1 is not dominant it is less good.
>
> True if best means infinity norm,

I am used to call it "the best approximation in the uniform sense" or minimax.

> but there are other choices if your
> standard is L1 norm or L2 norm.

In context of approximation of special functions to given fixed precision, i.e.
to 0.5 ULP for sqrt() or just a bit over 0.5ULP for trigs, the minimax norm is far
more relevant then the other norms, you mentioned.
For inner steps of rsqrt(), minimax is not the absolutely best norm, but quite
close to the best.

Re: Approximate reciprocals

<t2cbdf$srr$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-ec41-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Approximate reciprocals
Date: Sun, 3 Apr 2022 14:36:31 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <t2cbdf$srr$1@newsreader4.netcologne.de>
References: <t1c154$j5t$1@dont-email.me>
<5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de>
<ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org>
<t215f3$9o7$1@newsreader4.netcologne.de>
<a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com>
<t22c73$5b4$1@newsreader4.netcologne.de>
<b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com>
<10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com>
Injection-Date: Sun, 3 Apr 2022 14:36:31 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-ec41-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:ec41:0:7285:c2ff:fe6c:992d";
logging-data="29563"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 3 Apr 2022 14:36 UTC

Michael S <already5chosen@yahoo.com> schrieb:

> Indeed, under Linux I don't see a broken fmaq().
> But I see quite horrible precision bugs in sqrtq().
> E.g. 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024 delivers result that is off by 32 ULP!

Can you share your test program?

I have

$ cat xx.c
#include <quadmath.h>
#include <stdio.h>
#define MPFR_WANT_FLOAT128
#include <mpfr.h>

#define NDIG 113

int
main ()
{ volatile __float128 af = 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024Q, bf;
mpfr_t a, b, tst, diff;
mpfr_set_default_prec (NDIG);

mpfr_init (a); mpfr_init(b); mpfr_init(tst);
mpfr_set_float128 (a, af, MPFR_RNDN);
bf = sqrtq (af);
mpfr_sqrt (b, a, MPFR_RNDN);
mpfr_set_float128 (tst, bf, MPFR_RNDN);
mpfr_out_str (stdout, 10, 0, a, MPFR_RNDN);
printf ("\n");
mpfr_out_str (stdout, 10, 0, b, MPFR_RNDN);
printf ("\n");
mpfr_out_str (stdout, 10, 0, tst, MPFR_RNDN);
printf ("\n");
return 0;
} $ gcc xx.c -lmpfr -lgmp -lquadmath
$ ./a.out
5.70906089989805317627271688535438725e-309
7.55583277997736869996788472321132647e-155
7.55583277997736869996788472321132647e-155

which looks all right.

Re: Approximate reciprocals

<e3cd8ed7-de1d-40ee-a21d-798cd2d3a3b6n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:5ad6:0:b0:2e2:27b6:7b3e with SMTP id d22-20020ac85ad6000000b002e227b67b3emr15490191qtd.216.1649005741196;
Sun, 03 Apr 2022 10:09:01 -0700 (PDT)
X-Received: by 2002:aca:bb56:0:b0:2ef:6652:5581 with SMTP id
l83-20020acabb56000000b002ef66525581mr8844050oif.270.1649005740944; Sun, 03
Apr 2022 10:09:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!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: Sun, 3 Apr 2022 10:09:00 -0700 (PDT)
In-Reply-To: <t2cbdf$srr$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <t1c154$j5t$1@dont-email.me> <5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de> <ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de> <c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com> <t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com> <cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com> <cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org>
<t215f3$9o7$1@newsreader4.netcologne.de> <a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com>
<t22c73$5b4$1@newsreader4.netcologne.de> <b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com>
<10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com> <t2cbdf$srr$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e3cd8ed7-de1d-40ee-a21d-798cd2d3a3b6n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 03 Apr 2022 17:09:01 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 182
 by: Michael S - Sun, 3 Apr 2022 17:09 UTC

On Sunday, April 3, 2022 at 5:36:34 PM UTC+3, Thomas Koenig wrote:
> Michael S <already...@yahoo.com> schrieb:
> > Indeed, under Linux I don't see a broken fmaq().
> > But I see quite horrible precision bugs in sqrtq().
> > E.g. 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024 delivers result that is off by 32 ULP!
> Can you share your test program?
>

#include <stdio.h>
#include <stdlib.h>
#include <quadmath.h>
#include <gmp.h>
#include <mpfr.h>

static void to_mpfr(mpfr_t dst, __float128 src)
{ char buf[256];
quadmath_snprintf(buf, sizeof(buf), "%Qa", src);
mpfr_set_str(dst, buf, 0, GMP_RNDN);
}

static __float128 CalcULP(__float128 x, int dir)
{ if (dir < 0)
return x - nextafterq(x, 0.0q);
else
return nextafterq(x, FLT128_MAX) - x;
}

int main(int argz, char** argv)
{ const int MPFR_NBITS = 240;
mpfr_t xx, resx, ref, diff, ULPx, reldiff;
mpfr_init2(xx, MPFR_NBITS);
mpfr_init2(resx, MPFR_NBITS);
mpfr_init2(ref, MPFR_NBITS);
mpfr_init2(diff, MPFR_NBITS);
mpfr_init2(ULPx, MPFR_NBITS);
mpfr_init2(reldiff, MPFR_NBITS);

for (int arg_i = 1; arg_i < argz; ++arg_i) {
char* arg = argv[arg_i];
char* endp;
__float128 x = strtoflt128(arg, &endp);
if (arg != endp) {
char xebuf[256], yebuf[256];
char xhbuf[256], yhbuf[256];
__float128 y = sqrtq(x);
quadmath_snprintf(xebuf, sizeof(xebuf), "%-+50.38Qe", x);
quadmath_snprintf(yebuf, sizeof(yebuf), "%-+50.38Qe", y);

quadmath_snprintf(xhbuf, sizeof(xhbuf), "%-+40.28Qa", x);
quadmath_snprintf(yhbuf, sizeof(yhbuf), "%-+40.28Qa", y);

to_mpfr(xx, x);
to_mpfr(resx, y);
mpfr_sqrt(ref, xx, GMP_RNDN);

__float128 ULP = CalcULP(y, mpfr_cmp(ref, resx));
to_mpfr(ULPx ,ULP);

mpfr_sub(diff, resx, ref, GMP_RNDN);
mpfr_div(reldiff, diff, ULPx, GMP_RNDN);

mpfr_printf(
"arg %s\n"
"x %s %s\n"
"res %s %s\n"
"xx %-+50.38Re %-+50.38Ra\n"
"resx %-+50.38Re %-+50.38Ra\n"
"ref %-+50.38Re %-+50.38Ra\n"
"diff %-+50.38Re %-+50.38Ra\n"
"dULP %-+50.38Rf\n"
"\n"
, arg
, xebuf, xhbuf
, yebuf, yhbuf
, xx, xx
, resx, resx
, ref, ref
, diff, diff
, reldiff
);
}
}
return 0;
}

Compiled as:
gcc -Wall -O2 bug_rep.c -lquadmath -lmpfr -lgmp

On ws2019+WSL+OpenSUSE:
../a.out 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
arg 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
x +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
res +7.55583277997736869996788472321137243638e-155 +0x1.0358a8295b66c7fefb50c1298de4p-512
xx +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0ea0000000000p-1024
resx +7.55583277997736869996788472321137243638e-155 +0x1.0358a8295b66c7fefb50c1298de40000000000p-512
ref +7.55583277997736869996788472321132607621e-155 +0x1.0358a8295b66c7fefb50c1298dc3b9aca8e37ep-512
diff +4.63601724942796444562165627161223615263e-187 +0x2.04653571c81b52db61f9a0b94f6857b5c00000p-620
dULP +32.27470917173350947337067829258154575147

On Windows+MSYS2 this particular test case works fine:
./a 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
arg 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
x +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
res +7.55583277997736869996788472321132647080e-155 +0x1.0358a8295b66c7fefb50c1298dc4p-512
xx +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0ea0000000000p-1024
resx +7.55583277997736869996788472321132647080e-155 +0x1.0358a8295b66c7fefb50c1298dc40000000000p-512
ref +7.55583277997736869996788472321132607621e-155 +0x1.0358a8295b66c7fefb50c1298dc3b9aca8e37ep-512
diff +3.94598895362939939982164165850203162318e-189 +0x4.653571c81b52db61f9a0b94f6857b5c0000000p-628
dULP +0.27470917173350947337067829258154575147

It's hard to believe that the problem is in WSL.
According to my understanding, it does not affect user mode programs.

cat /etc/os-release
NAME="openSUSE Tumbleweed"
# VERSION="20211027"
ID="opensuse-tumbleweed"
ID_LIKE="opensuse suse"
VERSION_ID="20211027"
PRETTY_NAME="openSUSE Tumbleweed"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:tumbleweed:20211027"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed"
LOGO="distributor-logo-Tumbleweed"

uname -r
4.4.0-17763-Microsoft

> I have
>
> $ cat xx.c
> #include <quadmath.h>
> #include <stdio.h>
> #define MPFR_WANT_FLOAT128
> #include <mpfr.h>
>
> #define NDIG 113
>
> int
> main ()
> {
> volatile __float128 af = 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024Q, bf;
> mpfr_t a, b, tst, diff;
> mpfr_set_default_prec (NDIG);
>
> mpfr_init (a); mpfr_init(b); mpfr_init(tst);
> mpfr_set_float128 (a, af, MPFR_RNDN);
> bf = sqrtq (af);
> mpfr_sqrt (b, a, MPFR_RNDN);
> mpfr_set_float128 (tst, bf, MPFR_RNDN);
> mpfr_out_str (stdout, 10, 0, a, MPFR_RNDN);
> printf ("\n");
> mpfr_out_str (stdout, 10, 0, b, MPFR_RNDN);
> printf ("\n");
> mpfr_out_str (stdout, 10, 0, tst, MPFR_RNDN);
> printf ("\n");
> return 0;
> }
> $ gcc xx.c -lmpfr -lgmp -lquadmath
> $ ./a.out
> 5.70906089989805317627271688535438725e-309
> 7.55583277997736869996788472321132647e-155
> 7.55583277997736869996788472321132647e-155
>
> which looks all right.

Indeed, it's o.k.
But on my OpenSUSE I got:
5.70906089989805317627271688535438725e-309
7.55583277997736869996788472321132647e-155
7.55583277997736869996788472321137244e-155

Hardly o.k. :(

Re: Approximate reciprocals

<051bdc59-4b63-4a31-b898-fe9b700dbfc5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:622a:5d1:b0:2e0:70c7:1678 with SMTP id d17-20020a05622a05d100b002e070c71678mr15075551qtb.43.1649008460477;
Sun, 03 Apr 2022 10:54:20 -0700 (PDT)
X-Received: by 2002:a05:6870:a2d0:b0:d9:ae66:b8e2 with SMTP id
w16-20020a056870a2d000b000d9ae66b8e2mr8826765oak.7.1649008460231; Sun, 03 Apr
2022 10:54:20 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.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.arch
Date: Sun, 3 Apr 2022 10:54:20 -0700 (PDT)
In-Reply-To: <e3cd8ed7-de1d-40ee-a21d-798cd2d3a3b6n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <t1c154$j5t$1@dont-email.me> <5c553807-0d0a-45f4-8b4e-a52480359c8cn@googlegroups.com>
<t1mnc6$8lb$2@newsreader4.netcologne.de> <ae3841d6-c26f-4703-99f8-9893cb7c4701n@googlegroups.com>
<t1nqv2$2b2$1@newsreader4.netcologne.de> <c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com> <t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com> <cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com> <cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org>
<t215f3$9o7$1@newsreader4.netcologne.de> <a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com>
<t22c73$5b4$1@newsreader4.netcologne.de> <b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com>
<10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com> <t2cbdf$srr$1@newsreader4.netcologne.de>
<e3cd8ed7-de1d-40ee-a21d-798cd2d3a3b6n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <051bdc59-4b63-4a31-b898-fe9b700dbfc5n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 03 Apr 2022 17:54:20 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 177
 by: Michael S - Sun, 3 Apr 2022 17:54 UTC

On Sunday, April 3, 2022 at 8:09:02 PM UTC+3, Michael S wrote:
> On Sunday, April 3, 2022 at 5:36:34 PM UTC+3, Thomas Koenig wrote:
> > Michael S <already...@yahoo.com> schrieb:
> > > Indeed, under Linux I don't see a broken fmaq().
> > > But I see quite horrible precision bugs in sqrtq().
> > > E.g. 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024 delivers result that is off by 32 ULP!
> > Can you share your test program?
> >
> #include <stdio.h>
> #include <stdlib.h>
> #include <quadmath.h>
> #include <gmp.h>
> #include <mpfr.h>
> static void to_mpfr(mpfr_t dst, __float128 src)
> {
> char buf[256];
> quadmath_snprintf(buf, sizeof(buf), "%Qa", src);
> mpfr_set_str(dst, buf, 0, GMP_RNDN);
> }
> static __float128 CalcULP(__float128 x, int dir)
> {
> if (dir < 0)
> return x - nextafterq(x, 0.0q);
> else
> return nextafterq(x, FLT128_MAX) - x;
> }
>
> int main(int argz, char** argv)
> {
> const int MPFR_NBITS = 240;
> mpfr_t xx, resx, ref, diff, ULPx, reldiff;
> mpfr_init2(xx, MPFR_NBITS);
> mpfr_init2(resx, MPFR_NBITS);
> mpfr_init2(ref, MPFR_NBITS);
> mpfr_init2(diff, MPFR_NBITS);
> mpfr_init2(ULPx, MPFR_NBITS);
> mpfr_init2(reldiff, MPFR_NBITS);
> for (int arg_i = 1; arg_i < argz; ++arg_i) {
> char* arg = argv[arg_i];
> char* endp;
> __float128 x = strtoflt128(arg, &endp);
> if (arg != endp) {
> char xebuf[256], yebuf[256];
> char xhbuf[256], yhbuf[256];
> __float128 y = sqrtq(x);
> quadmath_snprintf(xebuf, sizeof(xebuf), "%-+50.38Qe", x);
> quadmath_snprintf(yebuf, sizeof(yebuf), "%-+50.38Qe", y);
>
> quadmath_snprintf(xhbuf, sizeof(xhbuf), "%-+40.28Qa", x);
> quadmath_snprintf(yhbuf, sizeof(yhbuf), "%-+40.28Qa", y);
>
> to_mpfr(xx, x);
> to_mpfr(resx, y);
> mpfr_sqrt(ref, xx, GMP_RNDN);
>
> __float128 ULP = CalcULP(y, mpfr_cmp(ref, resx));
> to_mpfr(ULPx ,ULP);
>
> mpfr_sub(diff, resx, ref, GMP_RNDN);
> mpfr_div(reldiff, diff, ULPx, GMP_RNDN);
>
> mpfr_printf(
> "arg %s\n"
> "x %s %s\n"
> "res %s %s\n"
> "xx %-+50.38Re %-+50.38Ra\n"
> "resx %-+50.38Re %-+50.38Ra\n"
> "ref %-+50.38Re %-+50.38Ra\n"
> "diff %-+50.38Re %-+50.38Ra\n"
> "dULP %-+50.38Rf\n"
> "\n"
> , arg
> , xebuf, xhbuf
> , yebuf, yhbuf
> , xx, xx
> , resx, resx
> , ref, ref
> , diff, diff
> , reldiff
> );
> }
> }
> return 0;
> }
>
>
> Compiled as:
> gcc -Wall -O2 bug_rep.c -lquadmath -lmpfr -lgmp
>
> On ws2019+WSL+OpenSUSE:
> ./a.out 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> arg 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> x +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> res +7.55583277997736869996788472321137243638e-155 +0x1.0358a8295b66c7fefb50c1298de4p-512
> xx +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0ea0000000000p-1024
> resx +7.55583277997736869996788472321137243638e-155 +0x1.0358a8295b66c7fefb50c1298de40000000000p-512
> ref +7.55583277997736869996788472321132607621e-155 +0x1.0358a8295b66c7fefb50c1298dc3b9aca8e37ep-512
> diff +4.63601724942796444562165627161223615263e-187 +0x2.04653571c81b52db61f9a0b94f6857b5c00000p-620
> dULP +32.27470917173350947337067829258154575147
>
> On Windows+MSYS2 this particular test case works fine:
> ./a 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> arg 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> x +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> res +7.55583277997736869996788472321132647080e-155 +0x1.0358a8295b66c7fefb50c1298dc4p-512
> xx +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0ea0000000000p-1024
> resx +7.55583277997736869996788472321132647080e-155 +0x1.0358a8295b66c7fefb50c1298dc40000000000p-512
> ref +7.55583277997736869996788472321132607621e-155 +0x1.0358a8295b66c7fefb50c1298dc3b9aca8e37ep-512
> diff +3.94598895362939939982164165850203162318e-189 +0x4.653571c81b52db61f9a0b94f6857b5c0000000p-628
> dULP +0.27470917173350947337067829258154575147
>
> It's hard to believe that the problem is in WSL.
> According to my understanding, it does not affect user mode programs.
>
> cat /etc/os-release
> NAME="openSUSE Tumbleweed"
> # VERSION="20211027"
> ID="opensuse-tumbleweed"
> ID_LIKE="opensuse suse"
> VERSION_ID="20211027"
> PRETTY_NAME="openSUSE Tumbleweed"
> ANSI_COLOR="0;32"
> CPE_NAME="cpe:/o:opensuse:tumbleweed:20211027"
> BUG_REPORT_URL="https://bugs.opensuse.org"
> HOME_URL="https://www.opensuse.org/"
> DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed"
> LOGO="distributor-logo-Tumbleweed"
>
> uname -r
> 4.4.0-17763-Microsoft
> > I have
> >
> > $ cat xx.c
> > #include <quadmath.h>
> > #include <stdio.h>
> > #define MPFR_WANT_FLOAT128
> > #include <mpfr.h>
> >
> > #define NDIG 113
> >
> > int
> > main ()
> > {
> > volatile __float128 af = 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024Q, bf;
> > mpfr_t a, b, tst, diff;
> > mpfr_set_default_prec (NDIG);
> >
> > mpfr_init (a); mpfr_init(b); mpfr_init(tst);
> > mpfr_set_float128 (a, af, MPFR_RNDN);
> > bf = sqrtq (af);
> > mpfr_sqrt (b, a, MPFR_RNDN);
> > mpfr_set_float128 (tst, bf, MPFR_RNDN);
> > mpfr_out_str (stdout, 10, 0, a, MPFR_RNDN);
> > printf ("\n");
> > mpfr_out_str (stdout, 10, 0, b, MPFR_RNDN);
> > printf ("\n");
> > mpfr_out_str (stdout, 10, 0, tst, MPFR_RNDN);
> > printf ("\n");
> > return 0;
> > }
> > $ gcc xx.c -lmpfr -lgmp -lquadmath
> > $ ./a.out
> > 5.70906089989805317627271688535438725e-309
> > 7.55583277997736869996788472321132647e-155
> > 7.55583277997736869996788472321132647e-155
> >
> > which looks all right.
> Indeed, it's o.k.
> But on my OpenSUSE I got:
> 5.70906089989805317627271688535438725e-309
> 7.55583277997736869996788472321132647e-155
> 7.55583277997736869996788472321137244e-155
>
> Hardly o.k. :(

I managed to install on the same server Fedora Remix for WSL (OT, unlike other distros, installing this one was painless).
It has exactly the same problem as OpenSUSE.
So, may be, the suggestion that bug is somehow related to WSL Linux kernel now appears to me less crazy than 30 minutes ago.

Re: Approximate reciprocals

<t2cp1n$6ji$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!news.freedyn.de!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-ec41-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Approximate reciprocals
Date: Sun, 3 Apr 2022 18:29:11 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <t2cp1n$6ji$1@newsreader4.netcologne.de>
References: <t1c154$j5t$1@dont-email.me>
<t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com>
<285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de>
<b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com>
<6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com>
<t1vnme$dhs$1@newsreader4.netcologne.de> <t20t87$1k64$1@gioia.aioe.org>
<t215f3$9o7$1@newsreader4.netcologne.de>
<a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com>
<t22c73$5b4$1@newsreader4.netcologne.de>
<b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com>
<10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com>
<t2cbdf$srr$1@newsreader4.netcologne.de>
<e3cd8ed7-de1d-40ee-a21d-798cd2d3a3b6n@googlegroups.com>
<051bdc59-4b63-4a31-b898-fe9b700dbfc5n@googlegroups.com>
Injection-Date: Sun, 3 Apr 2022 18:29:11 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-ec41-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:ec41:0:7285:c2ff:fe6c:992d";
logging-data="6770"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 3 Apr 2022 18:29 UTC

Michael S <already5chosen@yahoo.com> schrieb:
> On Sunday, April 3, 2022 at 8:09:02 PM UTC+3, Michael S wrote:

>> Compiled as:
>> gcc -Wall -O2 bug_rep.c -lquadmath -lmpfr -lgmp

Hmm.. what version of gcc are you using? Does "ldd a.out" point
to any strange places for libquadmath?

What you could try (clutching at straws here for a bit) is to link
the static version of the libquadmath library, i.e.

gcc -Wall -O2 bug_rep.c -lmpfr -lgmp /usr/lib/gcc/x86_64-linux-gnu/9/libquadmath.a

(or where you many find a static libquadmath).

>> On ws2019+WSL+OpenSUSE:
>> ./a.out 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
>> arg 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
>> x +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
>> res +7.55583277997736869996788472321137243638e-155 +0x1.0358a8295b66c7fefb50c1298de4p-512
>> xx +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0ea0000000000p-1024
>> resx +7.55583277997736869996788472321137243638e-155 +0x1.0358a8295b66c7fefb50c1298de40000000000p-512
>> ref +7.55583277997736869996788472321132607621e-155 +0x1.0358a8295b66c7fefb50c1298dc3b9aca8e37ep-512
>> diff +4.63601724942796444562165627161223615263e-187 +0x2.04653571c81b52db61f9a0b94f6857b5c00000p-620
>> dULP +32.27470917173350947337067829258154575147
>>
>> On Windows+MSYS2 this particular test case works fine:
>> ./a 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
>> arg 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
>> x +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
>> res +7.55583277997736869996788472321132647080e-155 +0x1.0358a8295b66c7fefb50c1298dc4p-512
>> xx +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0ea0000000000p-1024
>> resx +7.55583277997736869996788472321132647080e-155 +0x1.0358a8295b66c7fefb50c1298dc40000000000p-512
>> ref +7.55583277997736869996788472321132607621e-155 +0x1.0358a8295b66c7fefb50c1298dc3b9aca8e37ep-512
>> diff +3.94598895362939939982164165850203162318e-189 +0x4.653571c81b52db61f9a0b94f6857b5c0000000p-628
>> dULP +0.27470917173350947337067829258154575147
>>
>> It's hard to believe that the problem is in WSL.
>> According to my understanding, it does not affect user mode programs.

It should not.

>> cat /etc/os-release
>> NAME="openSUSE Tumbleweed"
>> # VERSION="20211027"
>> ID="opensuse-tumbleweed"
>> ID_LIKE="opensuse suse"
>> VERSION_ID="20211027"
>> PRETTY_NAME="openSUSE Tumbleweed"
>> ANSI_COLOR="0;32"
>> CPE_NAME="cpe:/o:opensuse:tumbleweed:20211027"
>> BUG_REPORT_URL="https://bugs.opensuse.org"
>> HOME_URL="https://www.opensuse.org/"
>> DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed"
>> LOGO="distributor-logo-Tumbleweed"

Tumbleweed is of course a bit experimental but it should certainly
not be this badly broken.

>> uname -r
>> 4.4.0-17763-Microsoft
>> > I have
>> >
>> > $ cat xx.c
>> > #include <quadmath.h>
>> > #include <stdio.h>
>> > #define MPFR_WANT_FLOAT128
>> > #include <mpfr.h>
>> >
>> > #define NDIG 113
>> >
>> > int
>> > main ()
>> > {
>> > volatile __float128 af = 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024Q, bf;
>> > mpfr_t a, b, tst, diff;
>> > mpfr_set_default_prec (NDIG);
>> >
>> > mpfr_init (a); mpfr_init(b); mpfr_init(tst);
>> > mpfr_set_float128 (a, af, MPFR_RNDN);
>> > bf = sqrtq (af);
>> > mpfr_sqrt (b, a, MPFR_RNDN);
>> > mpfr_set_float128 (tst, bf, MPFR_RNDN);
>> > mpfr_out_str (stdout, 10, 0, a, MPFR_RNDN);
>> > printf ("\n");
>> > mpfr_out_str (stdout, 10, 0, b, MPFR_RNDN);
>> > printf ("\n");
>> > mpfr_out_str (stdout, 10, 0, tst, MPFR_RNDN);
>> > printf ("\n");
>> > return 0;
>> > }
>> > $ gcc xx.c -lmpfr -lgmp -lquadmath
>> > $ ./a.out
>> > 5.70906089989805317627271688535438725e-309
>> > 7.55583277997736869996788472321132647e-155
>> > 7.55583277997736869996788472321132647e-155
>> >
>> > which looks all right.
>> Indeed, it's o.k.
>> But on my OpenSUSE I got:
>> 5.70906089989805317627271688535438725e-309
>> 7.55583277997736869996788472321132647e-155
>> 7.55583277997736869996788472321137244e-155
>>
>> Hardly o.k. :(

That is indeed really strange.

> I managed to install on the same server Fedora Remix for WSL
> (OT, unlike other distros, installing this one was painless).
> It has exactly the same problem as OpenSUSE.

> So, may be, the suggestion that bug is somehow related to WSL
> Linux kernel now appears to me less crazy than 30 minutes ago.

That would be _really_ weird.

Maybe you can submit a bug report against Fedora or OpenSUSE,
they are at least likely to not throw it out of the window
right away.

Re: Approximate reciprocals

<1196d0e2-98bd-4fb0-a98f-4c1662e75f0en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:4e88:0:b0:2e1:d573:325f with SMTP id 8-20020ac84e88000000b002e1d573325fmr15093915qtp.265.1649020239519;
Sun, 03 Apr 2022 14:10:39 -0700 (PDT)
X-Received: by 2002:a05:6830:25d6:b0:5c9:49ef:3c5b with SMTP id
d22-20020a05683025d600b005c949ef3c5bmr10912193otu.331.1649020239235; Sun, 03
Apr 2022 14:10:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.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.arch
Date: Sun, 3 Apr 2022 14:10:39 -0700 (PDT)
In-Reply-To: <t2cp1n$6ji$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=87.68.183.72; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 87.68.183.72
References: <t1c154$j5t$1@dont-email.me> <t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com> <285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de> <b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com> <6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com> <t1vnme$dhs$1@newsreader4.netcologne.de>
<t20t87$1k64$1@gioia.aioe.org> <t215f3$9o7$1@newsreader4.netcologne.de>
<a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com> <t22c73$5b4$1@newsreader4.netcologne.de>
<b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com> <10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com>
<t2cbdf$srr$1@newsreader4.netcologne.de> <e3cd8ed7-de1d-40ee-a21d-798cd2d3a3b6n@googlegroups.com>
<051bdc59-4b63-4a31-b898-fe9b700dbfc5n@googlegroups.com> <t2cp1n$6ji$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1196d0e2-98bd-4fb0-a98f-4c1662e75f0en@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 03 Apr 2022 21:10:39 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 124
 by: Michael S - Sun, 3 Apr 2022 21:10 UTC

On Sunday, April 3, 2022 at 9:29:14 PM UTC+3, Thomas Koenig wrote:
> Michael S <already...@yahoo.com> schrieb:
> > On Sunday, April 3, 2022 at 8:09:02 PM UTC+3, Michael S wrote:
>
> >> Compiled as:
> >> gcc -Wall -O2 bug_rep.c -lquadmath -lmpfr -lgmp
> Hmm.. what version of gcc are you using? Does "ldd a.out" point
> to any strange places for libquadmath?
>
> What you could try (clutching at straws here for a bit) is to link
> the static version of the libquadmath library, i.e.
>
> gcc -Wall -O2 bug_rep.c -lmpfr -lgmp /usr/lib/gcc/x86_64-linux-gnu/9/libquadmath.a
>
> (or where you many find a static libquadmath).

-lmpfr -lgmp /usr/lib/gcc/x86_64-redhat-linux/11/libquadmath.a /usr/lib64/libm.a

Same shite.

> >> On ws2019+WSL+OpenSUSE:
> >> ./a.out 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> >> arg 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> >> x +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> >> res +7.55583277997736869996788472321137243638e-155 +0x1.0358a8295b66c7fefb50c1298de4p-512
> >> xx +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0ea0000000000p-1024
> >> resx +7.55583277997736869996788472321137243638e-155 +0x1.0358a8295b66c7fefb50c1298de40000000000p-512
> >> ref +7.55583277997736869996788472321132607621e-155 +0x1.0358a8295b66c7fefb50c1298dc3b9aca8e37ep-512
> >> diff +4.63601724942796444562165627161223615263e-187 +0x2.04653571c81b52db61f9a0b94f6857b5c00000p-620
> >> dULP +32.27470917173350947337067829258154575147
> >>
> >> On Windows+MSYS2 this particular test case works fine:
> >> ./a 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> >> arg 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> >> x +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0eap-1024
> >> res +7.55583277997736869996788472321132647080e-155 +0x1.0358a8295b66c7fefb50c1298dc4p-512
> >> xx +5.70906089989805317627271688535438724887e-309 +0x1.06bc82f7b9d71dfcbddf2358a0ea0000000000p-1024
> >> resx +7.55583277997736869996788472321132647080e-155 +0x1.0358a8295b66c7fefb50c1298dc40000000000p-512
> >> ref +7.55583277997736869996788472321132607621e-155 +0x1.0358a8295b66c7fefb50c1298dc3b9aca8e37ep-512
> >> diff +3.94598895362939939982164165850203162318e-189 +0x4.653571c81b52db61f9a0b94f6857b5c0000000p-628
> >> dULP +0.27470917173350947337067829258154575147
> >>
> >> It's hard to believe that the problem is in WSL.
> >> According to my understanding, it does not affect user mode programs.
> It should not.
> >> cat /etc/os-release
> >> NAME="openSUSE Tumbleweed"
> >> # VERSION="20211027"
> >> ID="opensuse-tumbleweed"
> >> ID_LIKE="opensuse suse"
> >> VERSION_ID="20211027"
> >> PRETTY_NAME="openSUSE Tumbleweed"
> >> ANSI_COLOR="0;32"
> >> CPE_NAME="cpe:/o:opensuse:tumbleweed:20211027"
> >> BUG_REPORT_URL="https://bugs.opensuse.org"
> >> HOME_URL="https://www.opensuse.org/"
> >> DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed"
> >> LOGO="distributor-logo-Tumbleweed"
> Tumbleweed is of course a bit experimental but it should certainly
> not be this badly broken.
> >> uname -r
> >> 4.4.0-17763-Microsoft
> >> > I have
> >> >
> >> > $ cat xx.c
> >> > #include <quadmath.h>
> >> > #include <stdio.h>
> >> > #define MPFR_WANT_FLOAT128
> >> > #include <mpfr.h>
> >> >
> >> > #define NDIG 113
> >> >
> >> > int
> >> > main ()
> >> > {
> >> > volatile __float128 af = 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024Q, bf;
> >> > mpfr_t a, b, tst, diff;
> >> > mpfr_set_default_prec (NDIG);
> >> >
> >> > mpfr_init (a); mpfr_init(b); mpfr_init(tst);
> >> > mpfr_set_float128 (a, af, MPFR_RNDN);
> >> > bf = sqrtq (af);
> >> > mpfr_sqrt (b, a, MPFR_RNDN);
> >> > mpfr_set_float128 (tst, bf, MPFR_RNDN);
> >> > mpfr_out_str (stdout, 10, 0, a, MPFR_RNDN);
> >> > printf ("\n");
> >> > mpfr_out_str (stdout, 10, 0, b, MPFR_RNDN);
> >> > printf ("\n");
> >> > mpfr_out_str (stdout, 10, 0, tst, MPFR_RNDN);
> >> > printf ("\n");
> >> > return 0;
> >> > }
> >> > $ gcc xx.c -lmpfr -lgmp -lquadmath
> >> > $ ./a.out
> >> > 5.70906089989805317627271688535438725e-309
> >> > 7.55583277997736869996788472321132647e-155
> >> > 7.55583277997736869996788472321132647e-155
> >> >
> >> > which looks all right.
> >> Indeed, it's o.k.
> >> But on my OpenSUSE I got:
> >> 5.70906089989805317627271688535438725e-309
> >> 7.55583277997736869996788472321132647e-155
> >> 7.55583277997736869996788472321137244e-155
> >>
> >> Hardly o.k. :(
> That is indeed really strange.
> > I managed to install on the same server Fedora Remix for WSL
> > (OT, unlike other distros, installing this one was painless).
> > It has exactly the same problem as OpenSUSE.
>
> > So, may be, the suggestion that bug is somehow related to WSL
> > Linux kernel now appears to me less crazy than 30 minutes ago.
> That would be _really_ weird.
>
> Maybe you can submit a bug report against Fedora or OpenSUSE,
> they are at least likely to not throw it out of the window
> right away.

I think, throwing it out of the window is exactly what they are going to do.
Unlike WSL on later versions of Win10 and on Win11, WSL on WS2019 is
a ultimate red-headed step child. It is not supported by Microsoft themselves
so hard to expect that Red Hat (IBM) or SUSE care about it.

Re: Approximate reciprocals

<633e483f-007e-4d32-9b51-4e4727dfe495n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:7603:0:b0:2eb:ab0d:dc50 with SMTP id t3-20020ac87603000000b002ebab0ddc50mr5310281qtq.173.1649023158200;
Sun, 03 Apr 2022 14:59:18 -0700 (PDT)
X-Received: by 2002:a05:6808:2018:b0:2ec:c22b:15b8 with SMTP id
q24-20020a056808201800b002ecc22b15b8mr8953737oiw.136.1649023157978; Sun, 03
Apr 2022 14:59:17 -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.arch
Date: Sun, 3 Apr 2022 14:59:17 -0700 (PDT)
In-Reply-To: <1196d0e2-98bd-4fb0-a98f-4c1662e75f0en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2607:fea8:1dde:6a00:3131:2bcf:d024:e5b7;
posting-account=QId4bgoAAABV4s50talpu-qMcPp519Eb
NNTP-Posting-Host: 2607:fea8:1dde:6a00:3131:2bcf:d024:e5b7
References: <t1c154$j5t$1@dont-email.me> <t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com> <285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de> <b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com> <6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com> <t1vnme$dhs$1@newsreader4.netcologne.de>
<t20t87$1k64$1@gioia.aioe.org> <t215f3$9o7$1@newsreader4.netcologne.de>
<a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com> <t22c73$5b4$1@newsreader4.netcologne.de>
<b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com> <10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com>
<t2cbdf$srr$1@newsreader4.netcologne.de> <e3cd8ed7-de1d-40ee-a21d-798cd2d3a3b6n@googlegroups.com>
<051bdc59-4b63-4a31-b898-fe9b700dbfc5n@googlegroups.com> <t2cp1n$6ji$1@newsreader4.netcologne.de>
<1196d0e2-98bd-4fb0-a98f-4c1662e75f0en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <633e483f-007e-4d32-9b51-4e4727dfe495n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: robfi...@gmail.com (robf...@gmail.com)
Injection-Date: Sun, 03 Apr 2022 21:59:18 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 5
 by: robf...@gmail.com - Sun, 3 Apr 2022 21:59 UTC

Is there any use for approximately equals? And how to go about determining
approximate equality. I was thinking of an equality operator that takes in a
number of significant bits that must be equal. So, if there was a double
precision comparison, it could say equal to within 23 significant bits.

Re: Approximate reciprocals

<c65c0f4b-e939-43ea-ab44-c09af20ee4fbn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:caa:b0:441:2e8f:f398 with SMTP id s10-20020a0562140caa00b004412e8ff398mr15220227qvs.61.1649024554706;
Sun, 03 Apr 2022 15:22:34 -0700 (PDT)
X-Received: by 2002:a05:6808:1b11:b0:2da:73df:2dbd with SMTP id
bx17-20020a0568081b1100b002da73df2dbdmr8699309oib.293.1649024554435; Sun, 03
Apr 2022 15:22:34 -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.arch
Date: Sun, 3 Apr 2022 15:22:34 -0700 (PDT)
In-Reply-To: <1196d0e2-98bd-4fb0-a98f-4c1662e75f0en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:1fd:71eb:4ffc:4e9e;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:1fd:71eb:4ffc:4e9e
References: <t1c154$j5t$1@dont-email.me> <t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com> <285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de> <b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com> <6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com> <t1vnme$dhs$1@newsreader4.netcologne.de>
<t20t87$1k64$1@gioia.aioe.org> <t215f3$9o7$1@newsreader4.netcologne.de>
<a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com> <t22c73$5b4$1@newsreader4.netcologne.de>
<b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com> <10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com>
<t2cbdf$srr$1@newsreader4.netcologne.de> <e3cd8ed7-de1d-40ee-a21d-798cd2d3a3b6n@googlegroups.com>
<051bdc59-4b63-4a31-b898-fe9b700dbfc5n@googlegroups.com> <t2cp1n$6ji$1@newsreader4.netcologne.de>
<1196d0e2-98bd-4fb0-a98f-4c1662e75f0en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c65c0f4b-e939-43ea-ab44-c09af20ee4fbn@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 03 Apr 2022 22:22:34 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 26
 by: Michael S - Sun, 3 Apr 2022 22:22 UTC

On Monday, April 4, 2022 at 12:10:40 AM UTC+3, Michael S wrote:
> On Sunday, April 3, 2022 at 9:29:14 PM UTC+3, Thomas Koenig wrote:
> > Michael S <already...@yahoo.com> schrieb:
> > > On Sunday, April 3, 2022 at 8:09:02 PM UTC+3, Michael S wrote:
> >
> > >> Compiled as:
> > >> gcc -Wall -O2 bug_rep.c -lquadmath -lmpfr -lgmp
> > Hmm.. what version of gcc are you using? Does "ldd a.out" point
> > to any strange places for libquadmath?
> >
> > What you could try (clutching at straws here for a bit) is to link
> > the static version of the libquadmath library, i.e.
> >
> > gcc -Wall -O2 bug_rep.c -lmpfr -lgmp /usr/lib/gcc/x86_64-linux-gnu/9/libquadmath.a
> >
> > (or where you many find a static libquadmath).
> -lmpfr -lgmp /usr/lib/gcc/x86_64-redhat-linux/11/libquadmath.a /usr/lib64/libm.a
>
> Same shite.

I'm starting to understand the problem.
It is related to implementation of long double, more specifically, to settings of x87 control world.
Somehow, under WSL, x87 control world is set to 53-bit precision (default Windows settings).
Of course, quadmath, being Linux-originated, expects x87 control word to be set to 64-bit precision.
Who is at fault, kernel (Microsoft) or userland (Fedora/SUSE) ?
I'd guess, one is going to blame another and vice versa.

Re: Approximate reciprocals

<e823b5fe-89b7-4f09-91ca-410660be7f7cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:5c4d:0:b0:2e0:71b7:2829 with SMTP id j13-20020ac85c4d000000b002e071b72829mr15941760qtj.323.1649027344739;
Sun, 03 Apr 2022 16:09:04 -0700 (PDT)
X-Received: by 2002:aca:905:0:b0:2ee:f62a:e08e with SMTP id
5-20020aca0905000000b002eef62ae08emr8723205oij.54.1649027344482; Sun, 03 Apr
2022 16:09:04 -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.arch
Date: Sun, 3 Apr 2022 16:09:04 -0700 (PDT)
In-Reply-To: <c65c0f4b-e939-43ea-ab44-c09af20ee4fbn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:1fd:71eb:4ffc:4e9e;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:1fd:71eb:4ffc:4e9e
References: <t1c154$j5t$1@dont-email.me> <t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com> <285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de> <b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com> <6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com> <t1vnme$dhs$1@newsreader4.netcologne.de>
<t20t87$1k64$1@gioia.aioe.org> <t215f3$9o7$1@newsreader4.netcologne.de>
<a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com> <t22c73$5b4$1@newsreader4.netcologne.de>
<b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com> <10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com>
<t2cbdf$srr$1@newsreader4.netcologne.de> <e3cd8ed7-de1d-40ee-a21d-798cd2d3a3b6n@googlegroups.com>
<051bdc59-4b63-4a31-b898-fe9b700dbfc5n@googlegroups.com> <t2cp1n$6ji$1@newsreader4.netcologne.de>
<1196d0e2-98bd-4fb0-a98f-4c1662e75f0en@googlegroups.com> <c65c0f4b-e939-43ea-ab44-c09af20ee4fbn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e823b5fe-89b7-4f09-91ca-410660be7f7cn@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 03 Apr 2022 23:09:04 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 30
 by: Michael S - Sun, 3 Apr 2022 23:09 UTC

On Monday, April 4, 2022 at 1:22:36 AM UTC+3, Michael S wrote:
> On Monday, April 4, 2022 at 12:10:40 AM UTC+3, Michael S wrote:
> > On Sunday, April 3, 2022 at 9:29:14 PM UTC+3, Thomas Koenig wrote:
> > > Michael S <already...@yahoo.com> schrieb:
> > > > On Sunday, April 3, 2022 at 8:09:02 PM UTC+3, Michael S wrote:
> > >
> > > >> Compiled as:
> > > >> gcc -Wall -O2 bug_rep.c -lquadmath -lmpfr -lgmp
> > > Hmm.. what version of gcc are you using? Does "ldd a.out" point
> > > to any strange places for libquadmath?
> > >
> > > What you could try (clutching at straws here for a bit) is to link
> > > the static version of the libquadmath library, i.e.
> > >
> > > gcc -Wall -O2 bug_rep.c -lmpfr -lgmp /usr/lib/gcc/x86_64-linux-gnu/9/libquadmath.a
> > >
> > > (or where you many find a static libquadmath).
> > -lmpfr -lgmp /usr/lib/gcc/x86_64-redhat-linux/11/libquadmath.a /usr/lib64/libm.a
> >
> > Same shite.
> I'm starting to understand the problem.
> It is related to implementation of long double, more specifically, to settings of x87 control world.
> Somehow, under WSL, x87 control world is set to 53-bit precision (default Windows settings).
> Of course, quadmath, being Linux-originated, expects x87 control word to be set to 64-bit precision.
> Who is at fault, kernel (Microsoft) or userland (Fedora/SUSE) ?
> I'd guess, one is going to blame another and vice versa.

I think, it would be fare to say that the whole compiler environment is broken.
Having 'long double' with 15-bit exponent and 53-bit mantissa is, by itself, legal, if weird.
But then LDBL_MANT_DIG in float.h should be set to 53. An in this case it is set to 64.

Re: Approximate reciprocals

<56cb5552-3cd6-4b35-a8a5-827a8431b759n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:643:0:b0:67d:3188:24f2 with SMTP id 64-20020a370643000000b0067d318824f2mr13858275qkg.48.1649068854729;
Mon, 04 Apr 2022 03:40:54 -0700 (PDT)
X-Received: by 2002:a05:6808:9a9:b0:2ef:9f92:71b2 with SMTP id
e9-20020a05680809a900b002ef9f9271b2mr9331069oig.7.1649068854419; Mon, 04 Apr
2022 03:40:54 -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.arch
Date: Mon, 4 Apr 2022 03:40:54 -0700 (PDT)
In-Reply-To: <e823b5fe-89b7-4f09-91ca-410660be7f7cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <t1c154$j5t$1@dont-email.me> <t1nqv2$2b2$1@newsreader4.netcologne.de>
<c98cc15b-e3bf-4636-a2fc-0232aaf544f6n@googlegroups.com> <285f1ec1-4a48-4ab7-953a-1a4a2b4f8094n@googlegroups.com>
<t1o3sm$977$1@newsreader4.netcologne.de> <b48d1398-004f-4c6e-8c27-94c635d23c52n@googlegroups.com>
<cc1f77e5-2cfe-4d7d-b65b-4a2627818b43n@googlegroups.com> <6e7449c4-7134-44ea-a550-7c130d88b975n@googlegroups.com>
<cfd303cb-9107-4887-a71f-dd593d7698ebn@googlegroups.com> <t1vnme$dhs$1@newsreader4.netcologne.de>
<t20t87$1k64$1@gioia.aioe.org> <t215f3$9o7$1@newsreader4.netcologne.de>
<a86c92ab-149c-44f2-90e1-36496b35e9c4n@googlegroups.com> <t22c73$5b4$1@newsreader4.netcologne.de>
<b9a7bb45-110a-4652-8f99-d46f32691958n@googlegroups.com> <10f7aa7f-00db-4ade-9e2e-e71602654f49n@googlegroups.com>
<t2cbdf$srr$1@newsreader4.netcologne.de> <e3cd8ed7-de1d-40ee-a21d-798cd2d3a3b6n@googlegroups.com>
<051bdc59-4b63-4a31-b898-fe9b700dbfc5n@googlegroups.com> <t2cp1n$6ji$1@newsreader4.netcologne.de>
<1196d0e2-98bd-4fb0-a98f-4c1662e75f0en@googlegroups.com> <c65c0f4b-e939-43ea-ab44-c09af20ee4fbn@googlegroups.com>
<e823b5fe-89b7-4f09-91ca-410660be7f7cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <56cb5552-3cd6-4b35-a8a5-827a8431b759n@googlegroups.com>
Subject: Re: Approximate reciprocals
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 04 Apr 2022 10:40:54 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 39
 by: Michael S - Mon, 4 Apr 2022 10:40 UTC

On Monday, April 4, 2022 at 2:09:06 AM UTC+3, Michael S wrote:
> On Monday, April 4, 2022 at 1:22:36 AM UTC+3, Michael S wrote:
> > On Monday, April 4, 2022 at 12:10:40 AM UTC+3, Michael S wrote:
> > > On Sunday, April 3, 2022 at 9:29:14 PM UTC+3, Thomas Koenig wrote:
> > > > Michael S <already...@yahoo.com> schrieb:
> > > > > On Sunday, April 3, 2022 at 8:09:02 PM UTC+3, Michael S wrote:
> > > >
> > > > >> Compiled as:
> > > > >> gcc -Wall -O2 bug_rep.c -lquadmath -lmpfr -lgmp
> > > > Hmm.. what version of gcc are you using? Does "ldd a.out" point
> > > > to any strange places for libquadmath?
> > > >
> > > > What you could try (clutching at straws here for a bit) is to link
> > > > the static version of the libquadmath library, i.e.
> > > >
> > > > gcc -Wall -O2 bug_rep.c -lmpfr -lgmp /usr/lib/gcc/x86_64-linux-gnu/9/libquadmath.a
> > > >
> > > > (or where you many find a static libquadmath).
> > > -lmpfr -lgmp /usr/lib/gcc/x86_64-redhat-linux/11/libquadmath.a /usr/lib64/libm.a
> > >
> > > Same shite.
> > I'm starting to understand the problem.
> > It is related to implementation of long double, more specifically, to settings of x87 control world.
> > Somehow, under WSL, x87 control world is set to 53-bit precision (default Windows settings).
> > Of course, quadmath, being Linux-originated, expects x87 control word to be set to 64-bit precision.
> > Who is at fault, kernel (Microsoft) or userland (Fedora/SUSE) ?
> > I'd guess, one is going to blame another and vice versa.
> I think, it would be fare to say that the whole compiler environment is broken.
> Having 'long double' with 15-bit exponent and 53-bit mantissa is, by itself, legal, if weird.
> But then LDBL_MANT_DIG in float.h should be set to 53. An in this case it is set to 64.

Just to affirm what should be already obvious to attentive readers:
If I am adding following lines at the beginning of the program then Linux under WSL
under WS2019 behaves identically to x86-64 Linux tested by Thomas Koenig.

unsigned short cw;
_FPU_GETCW(cw);
cw = cw | _FPU_EXTENDED;
_FPU_SETCW(cw);

Pages:12345678910111213
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor