From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Cc: DJ Delorie <dj@redhat.com>, Joseph Myers <josmyers@redhat.com>,
Paul Zimmermann <Paul.Zimmermann@inria.fr>,
Alexei Sibidanov <sibid@uvic.ca>
Subject: [PATCH 15/15] x86_64: Add asinpif with FMA
Date: Fri, 31 Jan 2025 16:17:19 -0300 [thread overview]
Message-ID: <20250131191844.2582716-16-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20250131191844.2582716-1-adhemerval.zanella@linaro.org>
The CORE-MATH asinpif implementation showed slight worse performance
when using x86_64 baseline ABI due its usage of fma on fast path.
This patch adds a ifunc variant with similar performance for x86_64-v3.
---
sysdeps/ieee754/flt-32/s_asinpif.c | 2 ++
sysdeps/x86_64/fpu/multiarch/Makefile | 2 ++
sysdeps/x86_64/fpu/multiarch/s_asinpif-fma.c | 4 +++
sysdeps/x86_64/fpu/multiarch/s_asinpif.c | 33 ++++++++++++++++++++
4 files changed, 41 insertions(+)
create mode 100644 sysdeps/x86_64/fpu/multiarch/s_asinpif-fma.c
create mode 100644 sysdeps/x86_64/fpu/multiarch/s_asinpif.c
diff --git a/sysdeps/ieee754/flt-32/s_asinpif.c b/sysdeps/ieee754/flt-32/s_asinpif.c
index 585dc3f06e..42dbafdf97 100644
--- a/sysdeps/ieee754/flt-32/s_asinpif.c
+++ b/sysdeps/ieee754/flt-32/s_asinpif.c
@@ -133,4 +133,6 @@ __asinpif (float x)
return r;
}
}
+#ifndef __asinpif
libm_alias_float (__asinpi, asinpi)
+#endif
diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile
index e823d2fcc6..e00d76eb81 100644
--- a/sysdeps/x86_64/fpu/multiarch/Makefile
+++ b/sysdeps/x86_64/fpu/multiarch/Makefile
@@ -13,6 +13,7 @@ CFLAGS-s_tan-fma.c = -mfma -mavx2
CFLAGS-s_sincos-fma.c = -mfma -mavx2
CFLAGS-s_exp10m1f-fma.c = -mfma -mavx2
CFLAGS-s_exp2m1f-fma.c = -mfma -mavx2
+CFLAGS-s_asinpif-fma.c = -mfma -mavx2
CFLAGS-e_exp2f-fma.c = -mfma -mavx2
CFLAGS-e_expf-fma.c = -mfma -mavx2
@@ -68,6 +69,7 @@ libm-sysdep_routines += \
e_logf-fma \
e_pow-fma \
e_powf-fma \
+ s_asinpif-fma \
s_atan-avx \
s_atan-fma \
s_ceil-sse4_1 \
diff --git a/sysdeps/x86_64/fpu/multiarch/s_asinpif-fma.c b/sysdeps/x86_64/fpu/multiarch/s_asinpif-fma.c
new file mode 100644
index 0000000000..3c85bec1c9
--- /dev/null
+++ b/sysdeps/x86_64/fpu/multiarch/s_asinpif-fma.c
@@ -0,0 +1,4 @@
+#define __asinpif __asinpif_fma
+#define SECTION __attribute__ ((section (".text.fma")))
+
+#include <sysdeps/ieee754/flt-32/s_asinpif.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_asinpif.c b/sysdeps/x86_64/fpu/multiarch/s_asinpif.c
new file mode 100644
index 0000000000..98add04b7f
--- /dev/null
+++ b/sysdeps/x86_64/fpu/multiarch/s_asinpif.c
@@ -0,0 +1,33 @@
+/* Multiple versions of asinpif.
+ Copyright (C) 2024-2025 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <sysdeps/x86/isa-level.h>
+#if MINIMUM_X86_ISA_LEVEL < AVX2_X86_ISA_LEVEL
+# include <libm-alias-float.h>
+
+extern float __redirect_asinpif (float);
+
+# define SYMBOL_NAME asinpif
+# include "ifunc-fma.h"
+
+libc_ifunc_redirected (__redirect_asinpif, __asinpif, IFUNC_SELECTOR ());
+libm_alias_float (__asinpi, asinpi)
+
+# define __asinpif __asinpif_sse2
+#endif
+#include <sysdeps/ieee754/flt-32/s_asinpif.c>
--
2.43.0
next prev parent reply other threads:[~2025-01-31 19:19 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 19:17 [PATCH 00/15] Add c23 CORE-MATH binary32 implementations to libm Adhemerval Zanella
2025-01-31 19:17 ` [PATCH 01/15] benchtests: Add acospif Adhemerval Zanella
2025-02-07 22:00 ` DJ Delorie
2025-01-31 19:17 ` [PATCH 02/15] benchtests: Add asinpif Adhemerval Zanella
2025-02-07 22:06 ` DJ Delorie
2025-02-11 12:56 ` Adhemerval Zanella Netto
2025-01-31 19:17 ` [PATCH 03/15] benchtests: Add atan2pif Adhemerval Zanella
2025-02-07 22:19 ` DJ Delorie
2025-01-31 19:17 ` [PATCH 04/15] benchtests: Add atanpif Adhemerval Zanella
2025-02-07 22:36 ` DJ Delorie
2025-01-31 19:17 ` [PATCH 05/15] benchtests: Add cospif Adhemerval Zanella
2025-02-07 22:51 ` DJ Delorie
2025-02-11 13:13 ` Adhemerval Zanella Netto
2025-02-11 19:56 ` DJ Delorie
2025-01-31 19:17 ` [PATCH 06/15] benchtests: Add sinpif Adhemerval Zanella
2025-02-07 22:54 ` DJ Delorie
2025-02-11 13:13 ` Adhemerval Zanella Netto
2025-02-11 19:58 ` DJ Delorie
2025-01-31 19:17 ` [PATCH 07/15] benchtests: Add tanpif Adhemerval Zanella
2025-02-01 8:18 ` Paul Zimmermann
2025-02-07 22:55 ` DJ Delorie
2025-01-31 19:17 ` [PATCH 08/15] math: Use acospif from CORE-MATH Adhemerval Zanella
2025-02-01 8:22 ` Paul Zimmermann
2025-02-08 2:15 ` DJ Delorie
2025-02-11 13:16 ` Adhemerval Zanella Netto
2025-01-31 19:17 ` [PATCH 09/15] math: Use asinpif " Adhemerval Zanella
2025-02-01 8:28 ` Paul Zimmermann
2025-02-03 6:40 ` Paul Zimmermann
2025-02-03 12:27 ` Adhemerval Zanella Netto
2025-02-08 3:03 ` DJ Delorie
2025-01-31 19:17 ` [PATCH 10/15] math: Use atan2pif " Adhemerval Zanella
2025-02-08 4:20 ` DJ Delorie
2025-02-11 13:27 ` Adhemerval Zanella Netto
2025-01-31 19:17 ` [PATCH 11/15] math: Use atanpif " Adhemerval Zanella
2025-02-03 7:09 ` Paul Zimmermann
2025-02-10 22:29 ` DJ Delorie
2025-02-11 14:07 ` Adhemerval Zanella Netto
2025-02-11 14:22 ` Paul Zimmermann
2025-02-11 20:01 ` DJ Delorie
2025-02-11 20:10 ` Adhemerval Zanella Netto
2025-01-31 19:17 ` [PATCH 12/15] math: Use cospif " Adhemerval Zanella
2025-02-03 7:16 ` Paul Zimmermann
2025-02-10 23:07 ` DJ Delorie
2025-01-31 19:17 ` [PATCH 13/15] math: Use sinpif " Adhemerval Zanella
2025-02-03 10:39 ` Paul Zimmermann
2025-02-11 0:56 ` DJ Delorie
2025-01-31 19:17 ` [PATCH 14/15] math: Use tanpif " Adhemerval Zanella
2025-02-03 11:05 ` Paul Zimmermann
2025-02-11 1:15 ` DJ Delorie
2025-02-11 14:09 ` Adhemerval Zanella Netto
2025-01-31 19:17 ` Adhemerval Zanella [this message]
2025-01-31 22:59 ` [PATCH 15/15] x86_64: Add asinpif with FMA Noah Goldstein
2025-02-11 1:31 ` DJ Delorie
2025-02-11 14:12 ` Adhemerval Zanella Netto
2025-02-11 20:13 ` Adhemerval Zanella Netto
2025-02-12 11:00 ` Adhemerval Zanella Netto
2025-02-01 8:14 ` [PATCH 00/15] Add c23 CORE-MATH binary32 implementations to libm Paul Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250131191844.2582716-16-adhemerval.zanella@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=Paul.Zimmermann@inria.fr \
--cc=dj@redhat.com \
--cc=josmyers@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=sibid@uvic.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).