public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] math: Add a no-mathvec flag for sin (-0.0)
@ 2023-08-16 12:36 Wilco Dijkstra
  2023-08-16 12:47 ` Paul Zimmermann
  0 siblings, 1 reply; 6+ messages in thread
From: Wilco Dijkstra @ 2023-08-16 12:36 UTC (permalink / raw)
  To: 'GNU C Library'; +Cc: Joseph Myers


Add support for a no-mathvec flag to gen-auto-libm-tests.c.  Update input test sin (-0.0)
to be skipped in vector math libraries and regenerate testcases.

OK for commit?

---

diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index c400cafb4bd4715ac74e418ca0b442815b909ca0..2672eb1f6a2af813a77808060cf8d4efa7c7ffee 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -7318,7 +7318,7 @@ pow 0x1.7ac7cp+5 23
 pow -0x1.7ac7cp+5 23
 
 sin 0
-sin -0
+sin -0 no-mathvec
 sin pi/6
 sin -pi/6
 sin pi/2
diff --git a/math/auto-libm-test-out-sin b/math/auto-libm-test-out-sin
index f1d21b179c955eb7761a8309241f57450237d981..e1f684528316dde592255e488e23382a6b8a019e 100644
--- a/math/auto-libm-test-out-sin
+++ b/math/auto-libm-test-out-sin
@@ -23,31 +23,31 @@ sin 0
 = sin tonearest ibm128 0x0p+0 : 0x0p+0 : inexact-ok
 = sin towardzero ibm128 0x0p+0 : 0x0p+0 : inexact-ok
 = sin upward ibm128 0x0p+0 : 0x0p+0 : inexact-ok
-sin -0
-= sin downward binary32 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin tonearest binary32 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin towardzero binary32 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin upward binary32 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin downward binary64 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin tonearest binary64 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin towardzero binary64 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin upward binary64 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin downward intel96 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin tonearest intel96 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin towardzero intel96 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin upward intel96 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin downward m68k96 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin tonearest m68k96 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin towardzero m68k96 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin upward m68k96 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin downward binary128 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin tonearest binary128 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin towardzero binary128 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin upward binary128 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin downward ibm128 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin tonearest ibm128 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin towardzero ibm128 -0x0p+0 : -0x0p+0 : inexact-ok
-= sin upward ibm128 -0x0p+0 : -0x0p+0 : inexact-ok
+sin -0 no-mathvec
+= sin downward binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin tonearest binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin towardzero binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin upward binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin downward binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin tonearest binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin towardzero binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin upward binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin downward intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin tonearest intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin towardzero intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin upward intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin downward m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin tonearest m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin towardzero m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin upward m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin downward binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin tonearest binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin towardzero binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin upward binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin downward ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin tonearest ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin towardzero ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
+= sin upward ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok
 sin pi/6
 = sin downward binary32 0x8.60a92p-4 : 0x8p-4 : inexact-ok
 = sin tonearest binary32 0x8.60a92p-4 : 0x8p-4 : inexact-ok
diff --git a/math/gen-auto-libm-tests.c b/math/gen-auto-libm-tests.c
index 12aba4c8ee62388d4df33becdacac548dbcee19c..f0ee6edba9fe0877b027cb43b61754b9dcb2b9f9 100644
--- a/math/gen-auto-libm-tests.c
+++ b/math/gen-auto-libm-tests.c
@@ -96,7 +96,8 @@
    zero and infinite results should be ignored; "xfail" indicates the
    test is disabled as expected to produce incorrect results,
    "xfail-rounding" indicates the test is disabled only in rounding
-   modes other than round-to-nearest.  Otherwise, test flags are of
+   modes other than round-to-nearest; "no-mathvec" indicates the test
+   is disabled in vector math libraries.  Otherwise, test flags are of
    the form "spurious-<exception>" and "missing-<exception>", for any
    exception ("overflow", "underflow", "inexact", "invalid",
    "divbyzero"), "spurious-errno" and "missing-errno", to indicate
@@ -352,6 +353,7 @@ typedef enum
     flag_missing_overflow,
     flag_missing_underflow,
     flag_missing_errno,
+    flag_no_mathvec,
     num_input_flag_types,
     flag_first_flag = 0,
     flag_spurious_first = flag_spurious_divbyzero,
@@ -377,6 +379,7 @@ static const char *const input_flags[num_input_flag_types] =
     "missing-overflow",
     "missing-underflow",
     "missing-errno",
+    "no-mathvec",
   };
 
 /* An input flag, possibly conditional.  */
@@ -2049,6 +2052,7 @@ output_for_one_input_case (FILE *fp, const char *filename, test_function *tf,
 		  {
 		  case flag_ignore_zero_inf_sign:
 		  case flag_xfail:
+		  case flag_no_mathvec:
 		    if (fprintf (fp, " %s%s",
 				 input_flags[it->flags[i].type],
 				 (it->flags[i].cond
diff --git a/math/gen-libm-test.py b/math/gen-libm-test.py
index 6ae78beb01ce27a4f03f2e4b5ab75083c1914a81..a573c3b8cbc85bdb70eb03ebc320948be6e4f674 100755
--- a/math/gen-libm-test.py
+++ b/math/gen-libm-test.py
@@ -93,7 +93,8 @@ BEAUTIFY_MAP = {'minus_zero': '-0',
 
 # Flags in auto-libm-test-out that map directly to C flags.
 FLAGS_SIMPLE = {'ignore-zero-inf-sign': 'IGNORE_ZERO_INF_SIGN',
-                'xfail': 'XFAIL_TEST'}
+                'xfail': 'XFAIL_TEST',
+                'no-mathvec': 'NO_TEST_MATHVEC'}
 
 # Exceptions in auto-libm-test-out, and their corresponding C flags
 # for being required, OK or required to be absent.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] math: Add a no-mathvec flag for sin (-0.0)
  2023-08-16 12:36 [PATCH] math: Add a no-mathvec flag for sin (-0.0) Wilco Dijkstra
@ 2023-08-16 12:47 ` Paul Zimmermann
  2023-08-16 12:58   ` Wilco Dijkstra
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Zimmermann @ 2023-08-16 12:47 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: libc-alpha, joseph

       Hi Wilco,

I don't understand the purpose of this new no-mathvec flag.
Are vector math libraries allowed to return anything else
than -0 for sin(-0)?

If so, why would it be different in scalar (non vector) mode?

Paul

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] math: Add a no-mathvec flag for sin (-0.0)
  2023-08-16 12:47 ` Paul Zimmermann
@ 2023-08-16 12:58   ` Wilco Dijkstra
  2023-08-16 13:04     ` Paul Zimmermann
  0 siblings, 1 reply; 6+ messages in thread
From: Wilco Dijkstra @ 2023-08-16 12:58 UTC (permalink / raw)
  To: Paul Zimmermann; +Cc: libc-alpha, joseph

Hi Paul,

> I don't understand the purpose of this new no-mathvec flag.
> Are vector math libraries allowed to return anything else
> than -0 for sin(-0)?
>
> If so, why would it be different in scalar (non vector) mode?

Vector math libraries are only used with -Ofast since they have
much higher ULP errors, create spurious exceptions etc. -Ofast
ignores sign of zero, and doesn't support NaNs. In this case the
vector sin (-0.0) returned +0.0 (no ULP error), so we skip this test.

Cheers,
Wilco


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] math: Add a no-mathvec flag for sin (-0.0)
  2023-08-16 12:58   ` Wilco Dijkstra
@ 2023-08-16 13:04     ` Paul Zimmermann
  2023-08-16 13:13       ` Wilco Dijkstra
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Zimmermann @ 2023-08-16 13:04 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: libc-alpha, joseph

       Hi Wilco,

> > I don't understand the purpose of this new no-mathvec flag.
> > Are vector math libraries allowed to return anything else
> > than -0 for sin(-0)?
> >
> > If so, why would it be different in scalar (non vector) mode?
> 
> Vector math libraries are only used with -Ofast since they have
> much higher ULP errors, create spurious exceptions etc. -Ofast
> ignores sign of zero, and doesn't support NaNs. In this case the
> vector sin (-0.0) returned +0.0 (no ULP error), so we skip this test.

since there is no ULP error, the test should pass, no?

Or did the vector sin return -0.0 before, and now it returns +0.0,
so the test fails now?

Sorry I'm trying to understand the reason of this patch
(and why it worked before without this patch).

Paul

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] math: Add a no-mathvec flag for sin (-0.0)
  2023-08-16 13:04     ` Paul Zimmermann
@ 2023-08-16 13:13       ` Wilco Dijkstra
  2023-08-16 13:39         ` Paul Zimmermann
  0 siblings, 1 reply; 6+ messages in thread
From: Wilco Dijkstra @ 2023-08-16 13:13 UTC (permalink / raw)
  To: Paul Zimmermann; +Cc: libc-alpha, joseph

Hi Paul,

> since there is no ULP error, the test should pass, no?

It doesn't pass because it checks the sign too.

> Or did the vector sin return -0.0 before, and now it returns +0.0,
> so the test fails now?

No, vector sin didn't exist until very recently.

> Sorry I'm trying to understand the reason of this patch
> (and why it worked before without this patch).

The current vector sin has a quick hack to handle zero as a special
case, but that affects performance, so the goal is to remove it.

Cheers,
Wilco

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] math: Add a no-mathvec flag for sin (-0.0)
  2023-08-16 13:13       ` Wilco Dijkstra
@ 2023-08-16 13:39         ` Paul Zimmermann
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Zimmermann @ 2023-08-16 13:39 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: libc-alpha, joseph

thank you Wilco for the explanation.

This clarifies things on my side, and I'm ok to merge this patch.

Paul

> From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
> CC: "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
> 	"joseph@codesourcery.com" <joseph@codesourcery.com>
> Thread-Topic: [PATCH] math: Add a no-mathvec flag for sin (-0.0)
> Thread-Index: AQHZ0D20SBSUPesvf0+Qd6YidtA8+6/s3zoHgAAANYeAAASI54AAAE1k
> Date: Wed, 16 Aug 2023 13:13:54 +0000
> nodisclaimer: true
> Original-Authentication-Results: dkim=none (message not signed)
>  header.d=none;dmarc=none action=none header.from=arm.com;
> 
> Hi Paul,
> 
> > since there is no ULP error, the test should pass, no?
> 
> It doesn't pass because it checks the sign too.
> 
> > Or did the vector sin return -0.0 before, and now it returns +0.0,
> > so the test fails now?
> 
> No, vector sin didn't exist until very recently.
> 
> > Sorry I'm trying to understand the reason of this patch
> > (and why it worked before without this patch).
> 
> The current vector sin has a quick hack to handle zero as a special
> case, but that affects performance, so the goal is to remove it.
> 
> Cheers,
> Wilco

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-16 13:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-16 12:36 [PATCH] math: Add a no-mathvec flag for sin (-0.0) Wilco Dijkstra
2023-08-16 12:47 ` Paul Zimmermann
2023-08-16 12:58   ` Wilco Dijkstra
2023-08-16 13:04     ` Paul Zimmermann
2023-08-16 13:13       ` Wilco Dijkstra
2023-08-16 13:39         ` Paul Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).