This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] use hw instructions for ieee754_sqrt on s390.


Hi,
I checked with the hardware designers and they confirmed
that the square root instructions sqdbr and sqebr are exact
to the last bit of precision following the rules and rounding
modes of ieee754.
The patch goes on top of Jakubs latest s390 math patch which
introduces the mathinline.h header.

blue skies,
  Martin.

2004-07-01  Martin Schwidefsky  <schwidefsky@de.ibm.com>

	* sysdeps/s390/fpu/bits/mathinline.h [__LIBC_INTERNAL_MATH_INLINES]
	(__ieee754_sqrt): Define as __MATH_INLINE using sqdbr instruction.
	(__ieee754_sqrtf): Define as __MATH_INLINE using sqebr instruction.
	* sysdeps/s390/fpu/e_sqrt.c: New file.
	* sysdeps/s390/fpu/e_sqrtf.c: New file.
	* sysdeps/s390/Implies: New file.
	* sysdeps/s390/s390-32/Implies: Remove ieee754, move 
	ieee754/dbl-64 and ieee754/flt-32 to s390/s390/Implies.
	* sysdeps/s390/s390-64/Implies: Likewise.


diff -urN libc/sysdeps/s390/fpu/bits/mathinline.h libc-s390/sysdeps/s390/fpu/bits/mathinline.h
--- libc/sysdeps/s390/fpu/bits/mathinline.h	2004-07-01 19:04:33.000000000 +0200
+++ libc-s390/sysdeps/s390/fpu/bits/mathinline.h	2004-07-01 19:05:10.000000000 +0200
@@ -47,4 +47,31 @@
 
 #endif /* C99 */
 
+/* This code is used internally in the GNU libc.  */
+#ifdef __LIBC_INTERNAL_MATH_INLINES
+
+#include <sysdep.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+
+__MATH_INLINE double
+__ieee754_sqrt (double x)
+{
+  double res;
+     
+  asm ( "sqdbr %0,%1" : "=f" (res) : "f" (x) );
+  return res;
+}
+
+__MATH_INLINE float
+__ieee754_sqrtf (float x)
+{
+  float res;
+  
+  asm ( "sqebr %0,%1" : "=f" (res) : "f" (x) );
+  return res;
+}
+
+#endif /* __LIBC_INTERNAL_MATH_INLINES */
+
 #endif /* __NO_MATH_INLINES */
diff -urN libc/sysdeps/s390/fpu/e_sqrt.c libc-s390/sysdeps/s390/fpu/e_sqrt.c
--- libc/sysdeps/s390/fpu/e_sqrt.c	1970-01-01 01:00:00.000000000 +0100
+++ libc-s390/sysdeps/s390/fpu/e_sqrt.c	2004-07-01 19:04:41.000000000 +0200
@@ -0,0 +1,29 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <math_private.h>
+
+double
+__ieee754_sqrt (double x)
+{
+  double res;
+
+  asm ( "sqdbr %0,%1" : "=f" (res) : "f" (x) );
+  return res;
+}
diff -urN libc/sysdeps/s390/fpu/e_sqrtf.c libc-s390/sysdeps/s390/fpu/e_sqrtf.c
--- libc/sysdeps/s390/fpu/e_sqrtf.c	1970-01-01 01:00:00.000000000 +0100
+++ libc-s390/sysdeps/s390/fpu/e_sqrtf.c	2004-07-01 19:04:41.000000000 +0200
@@ -0,0 +1,29 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <math_private.h>
+
+float
+__ieee754_sqrtf (float x)
+{
+  float res;
+
+  asm ( "sqebr %0,%1" : "=f" (res) : "f" (x) );
+  return res;
+}
diff -urN libc/sysdeps/s390/Implies libc-s390/sysdeps/s390/Implies
--- libc/sysdeps/s390/Implies	1970-01-01 01:00:00.000000000 +0100
+++ libc-s390/sysdeps/s390/Implies	2004-07-01 19:04:41.000000000 +0200
@@ -0,0 +1,2 @@
+ieee754/dbl-64
+ieee754/flt-32
diff -urN libc/sysdeps/s390/s390-32/Implies libc-s390/sysdeps/s390/s390-32/Implies
--- libc/sysdeps/s390/s390-32/Implies	2004-06-11 11:05:32.000000000 +0200
+++ libc-s390/sysdeps/s390/s390-32/Implies	2004-07-01 19:04:41.000000000 +0200
@@ -1,4 +1 @@
 wordsize-32
-ieee754
-ieee754/dbl-64
-ieee754/flt-32
diff -urN libc/sysdeps/s390/s390-64/Implies libc-s390/sysdeps/s390/s390-64/Implies
--- libc/sysdeps/s390/s390-64/Implies	2004-06-11 11:05:32.000000000 +0200
+++ libc-s390/sysdeps/s390/s390-64/Implies	2004-07-01 19:04:41.000000000 +0200
@@ -1,4 +1 @@
 wordsize-64
-ieee754
-ieee754/dbl-64
-ieee754/flt-32


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]