public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Fix reduc_strict_run-1 test case.
@ 2023-08-15 15:49 Robin Dapp
  2023-08-16  1:13 ` Jeff Law
  2023-08-16  6:29 ` juzhe.zhong
  0 siblings, 2 replies; 9+ messages in thread
From: Robin Dapp @ 2023-08-15 15:49 UTC (permalink / raw)
  To: gcc-patches, palmer, Kito Cheng, jeffreyalaw, juzhe.zhong; +Cc: rdapp.gcc

Hi,

this patch changes the equality check for the reduc_strict_run-1
testcase from == to fabs () < EPS.  The FAIL only occurs with
_Float16 but I'd argue approximate equality is preferable for all
float modes.

Regards
 Robin

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c:
	Check float equality with fabs < EPS.
---
 .../riscv/rvv/autovec/reduc/reduc_strict_run-1.c         | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c
index 516be97e9eb..93efe2c4333 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c
@@ -2,6 +2,9 @@
 /* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model" } */
 
 #include "reduc_strict-1.c"
+#include <math.h>
+
+#define EPS 1e-2
 
 #define TEST_REDUC_PLUS(TYPE)			\
   {						\
@@ -10,14 +13,14 @@
     TYPE r = 0, q = 3;				\
     for (int i = 0; i < NUM_ELEMS (TYPE); i++)	\
       {						\
-	a[i] = (i * 0.1) * (i & 1 ? 1 : -1);	\
-	b[i] = (i * 0.3) * (i & 1 ? 1 : -1);	\
+	a[i] = (i * 0.01) * (i & 1 ? 1 : -1);	\
+	b[i] = (i * 0.03) * (i & 1 ? 1 : -1);	\
 	r += a[i];				\
 	q -= b[i];				\
 	asm volatile ("" ::: "memory");		\
       }						\
     TYPE res = reduc_plus_##TYPE (a, b);	\
-    if (res != r * q)				\
+    if (fabs (res - r * q) > EPS)		\
       __builtin_abort ();			\
   }
 
-- 
2.41.0

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

end of thread, other threads:[~2023-08-17  8:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 15:49 [PATCH] RISC-V: Fix reduc_strict_run-1 test case Robin Dapp
2023-08-16  1:13 ` Jeff Law
2023-08-16  1:21   ` juzhe.zhong
2023-08-16  2:41     ` Jeff Law
2023-08-16 13:50       ` Robin Dapp
2023-08-16 22:59         ` Jeff Law
2023-08-16 23:21           ` Palmer Dabbelt
2023-08-17  8:26             ` Robin Dapp
2023-08-16  6:29 ` juzhe.zhong

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).