This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch hjl/x86/math created. glibc-2.26.9000-996-g4e06619
- From: hjl at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 16 Dec 2017 14:31:05 -0000
- Subject: GNU C Library master sources branch hjl/x86/math created. glibc-2.26.9000-996-g4e06619
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/x86/math has been created
at 4e066198b0da3fac8330bafe4f729eccab58cdf6 (commit)
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=4e066198b0da3fac8330bafe4f729eccab58cdf6
commit 4e066198b0da3fac8330bafe4f729eccab58cdf6
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sat Dec 16 06:16:01 2017 -0800
x86-64: Add sincosf with FMA
diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile
index 0825340..9a89bfc 100644
--- a/sysdeps/x86_64/fpu/multiarch/Makefile
+++ b/sysdeps/x86_64/fpu/multiarch/Makefile
@@ -37,10 +37,10 @@ CFLAGS-slowpow-fma.c = -mfma -mavx2
CFLAGS-s_sin-fma.c = -mfma -mavx2
CFLAGS-s_tan-fma.c = -mfma -mavx2
-libm-sysdep_routines += s_sinf-sse2 s_cosf-sse2
+libm-sysdep_routines += s_sinf-sse2 s_cosf-sse2 s_sincosf-sse2
libm-sysdep_routines += e_exp2f-fma e_expf-fma e_log2f-fma e_logf-fma \
- e_powf-fma s_sinf-fma s_cosf-fma
+ e_powf-fma s_sinf-fma s_cosf-fma s_sincosf-fma
CFLAGS-e_exp2f-fma.c = -mfma -mavx2
CFLAGS-e_expf-fma.c = -mfma -mavx2
@@ -49,6 +49,7 @@ CFLAGS-e_logf-fma.c = -mfma -mavx2
CFLAGS-e_powf-fma.c = -mfma -mavx2
CFLAGS-s_sinf-fma.c = -mfma -mavx2
CFLAGS-s_cosf-fma.c = -mfma -mavx2
+CFLAGS-s_sincosf-fma.c = -mfma -mavx2
libm-sysdep_routines += e_exp-fma4 e_log-fma4 e_pow-fma4 s_atan-fma4 \
e_asin-fma4 e_atan2-fma4 s_sin-fma4 s_tan-fma4 \
diff --git a/sysdeps/x86_64/fpu/multiarch/s_sincosf-fma.c b/sysdeps/x86_64/fpu/multiarch/s_sincosf-fma.c
new file mode 100644
index 0000000..253dab1
--- /dev/null
+++ b/sysdeps/x86_64/fpu/multiarch/s_sincosf-fma.c
@@ -0,0 +1,2 @@
+#define SINCOSF __sincosf_fma
+#include <sysdeps/ieee754/flt-32/s_sincosf.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_sincosf-sse2.c b/sysdeps/x86_64/fpu/multiarch/s_sincosf-sse2.c
new file mode 100644
index 0000000..3c6d293
--- /dev/null
+++ b/sysdeps/x86_64/fpu/multiarch/s_sincosf-sse2.c
@@ -0,0 +1,2 @@
+#define SINCOSF __sincosf_sse2
+#include <sysdeps/ieee754/flt-32/s_sincosf.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_sincosf.c b/sysdeps/x86_64/fpu/multiarch/s_sincosf.c
new file mode 100644
index 0000000..6cb4295
--- /dev/null
+++ b/sysdeps/x86_64/fpu/multiarch/s_sincosf.c
@@ -0,0 +1,28 @@
+/* Multiple versions of sincosf.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <libm-alias-float.h>
+
+extern void __redirect_sincosf (float, float *, float *);
+
+#define SYMBOL_NAME sincosf
+#include "ifunc-fma.h"
+
+libc_ifunc_redirected (__redirect_sincosf, __sincosf, IFUNC_SELECTOR ());
+
+libm_alias_float (__sincos, sincos)
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=6bc50c672ac0ac50287e16942d8d03689f4fc87b
commit 6bc50c672ac0ac50287e16942d8d03689f4fc87b
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Dec 15 12:08:22 2017 -0800
Add s_sincosf_data.c
Add s_sincosf_data.c to data between sinf, cosf and sincosf.
Tested on x86-64. It reduced the read-only data size by 352 bytes.
On Skylake, bench-sincosf reports performance change:
Before After Change
max 148.062 144.118 3%
min 9.408 9.418 -0.1%
mean 21.5507 21.8225 -1%
* math/Makefile (type-float-routines): Add s_sincosf_data.
* sysdeps/ieee754/flt-32/math_config.h (SINCOSF_PIO2_TABLE):
New.
(SINCOSF_INVPIO4_TABLE): Likewise.
(SINCOSF_DOUBLE_ONES): Likewise.
(__sincosf_data): Likewise.
* sysdeps/ieee754/flt-32/s_sincosf.h: Include "math_config.h".
(pio2_table): Replaced with __sincosf_data.
(invpio4_table): Likewise.
(ones): Likewise.
* sysdeps/ieee754/flt-32/s_sincosf_data.c: New file.
diff --git a/math/Makefile b/math/Makefile
index cba9ce9..8762f20 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -120,7 +120,7 @@ type-double-routines := branred doasin dosincos halfulp mpa mpatan2 \
# float support
type-float-suffix := f
type-float-routines := k_rem_pio2f math_errf e_exp2f_data e_logf_data \
- e_log2f_data e_powf_log2_data
+ e_log2f_data e_powf_log2_data s_sincosf_data
# _Float128 support
type-float128-suffix := f128
diff --git a/sysdeps/ieee754/flt-32/math_config.h b/sysdeps/ieee754/flt-32/math_config.h
index e5a830b..c2bc728 100644
--- a/sysdeps/ieee754/flt-32/math_config.h
+++ b/sysdeps/ieee754/flt-32/math_config.h
@@ -161,4 +161,15 @@ extern const struct powf_log2_data
double poly[POWF_LOG2_POLY_ORDER];
} __powf_log2_data attribute_hidden;
+/* Shared between sinf, cosf and sincosf. */
+#define SINCOSF_PIO2_TABLE 6
+#define SINCOSF_INVPIO4_TABLE 8
+#define SINCOSF_DOUBLE_ONES 2
+extern const struct sincosf_data
+{
+ double pio2_table[SINCOSF_PIO2_TABLE];
+ double invpio4_table[SINCOSF_INVPIO4_TABLE];
+ double ones[SINCOSF_DOUBLE_ONES];
+} __sincosf_data attribute_hidden;
+
#endif
diff --git a/sysdeps/ieee754/flt-32/s_sincosf.h b/sysdeps/ieee754/flt-32/s_sincosf.h
index b0110fc..89855c7 100644
--- a/sysdeps/ieee754/flt-32/s_sincosf.h
+++ b/sysdeps/ieee754/flt-32/s_sincosf.h
@@ -16,6 +16,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include "math_config.h"
+
/* Chebyshev constants for cos, range -PI/4 - PI/4. */
static const double C0 = -0x1.ffffffffe98aep-2;
static const double C1 = 0x1.55555545c50c7p-5;
@@ -48,27 +50,9 @@ static const double inv_PI_4 = 0x1.45f306dc9c883p+0; /* 4/PI. */
#define FLOAT_EXPONENT_SHIFT 23
#define FLOAT_EXPONENT_BIAS 127
-static const double pio2_table[] = {
- 0 * M_PI_2,
- 1 * M_PI_2,
- 2 * M_PI_2,
- 3 * M_PI_2,
- 4 * M_PI_2,
- 5 * M_PI_2
-};
-
-static const double invpio4_table[] = {
- 0x0p+0,
- 0x1.45f306cp+0,
- 0x1.c9c882ap-28,
- 0x1.4fe13a8p-58,
- 0x1.f47d4dp-85,
- 0x1.bb81b6cp-112,
- 0x1.4acc9ep-142,
- 0x1.0e4107cp-169
-};
-
-static const double ones[] = { 1.0, -1.0 };
+#define pio2_table __sincosf_data.pio2_table
+#define invpio4_table __sincosf_data.invpio4_table
+#define ones __sincosf_data.ones
/* Compute the sine value using Chebyshev polynomials where
THETA is the range reduced absolute value of the input
diff --git a/sysdeps/ieee754/flt-32/s_sincosf_data.c b/sysdeps/ieee754/flt-32/s_sincosf_data.c
new file mode 100644
index 0000000..d999ac5
--- /dev/null
+++ b/sysdeps/ieee754/flt-32/s_sincosf_data.c
@@ -0,0 +1,41 @@
+/* Shared data between sinf, cosf and sincosf.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "math_config.h"
+
+const struct sincosf_data __sincosf_data = {
+ .pio2_table = {
+ 0 * M_PI_2,
+ 1 * M_PI_2,
+ 2 * M_PI_2,
+ 3 * M_PI_2,
+ 4 * M_PI_2,
+ 5 * M_PI_2
+ },
+ .invpio4_table = {
+ 0x0p+0,
+ 0x1.45f306cp+0,
+ 0x1.c9c882ap-28,
+ 0x1.4fe13a8p-58,
+ 0x1.f47d4dp-85,
+ 0x1.bb81b6cp-112,
+ 0x1.4acc9ep-142,
+ 0x1.0e4107cp-169
+ },
+ .ones = { 1.0, -1.0 }
+};
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources