From patchwork Fri Mar 14 00:26:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Pandey X-Patchwork-Id: 107866 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDEC33857C58 for ; Fri, 14 Mar 2025 00:27:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDEC33857C58 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by sourceware.org (Postfix) with ESMTPS id A45C23858D39 for ; Fri, 14 Mar 2025 00:26:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A45C23858D39 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A45C23858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741912010; cv=none; b=ihlELNW+iPRZ0IS+na3thn0Z428CDt6yYTIWO5E5H9BKv49oNbFQU3R+vx3r5e4AkuCzXqrxDYFw7De9zWE9GRRTGMWh8xxlJdrsAOvQ9nR/K/fjAX2hfB63HRDZif/4xcb71VaFxh3VoQjESyv9VydODyeKGgBM4lAKgMn7Zpc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741912010; c=relaxed/simple; bh=uYjK88uM9JQ5THyu8sH0h0HWhgISJd4CEjj+WgCKNKY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=hoOrUKxTWgmq8h0eJKPBvO9ZV2vU7tGyvx2i0d/476EMrA9w5Ph8TIboGFZkONhO5UyBAtg7oyVJ+ViYOdRV/7v8v1ytpH5RRGK1SYRGMDhsZf7D8QILI28JIEebWhKoulKltbxGEirMV5Hl5Y14IF/sL2ddE0ytxPm5HxML8qc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A45C23858D39 X-CSE-ConnectionGUID: yHDozxFMSI+41R9kUHCGYA== X-CSE-MsgGUID: oiZpuf5XSYa9JjXOCFZEvA== X-IronPort-AV: E=McAfee;i="6700,10204,11372"; a="42302417" X-IronPort-AV: E=Sophos;i="6.14,246,1736841600"; d="scan'208";a="42302417" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2025 17:26:49 -0700 X-CSE-ConnectionGUID: Mv9WwpMGSvO8aMnhF5jIhg== X-CSE-MsgGUID: Dkxuo6+9QamBY3skvL6GeQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,246,1736841600"; d="scan'208";a="121108471" Received: from scymds03.sc.intel.com ([10.148.94.166]) by orviesa006.jf.intel.com with ESMTP; 13 Mar 2025 17:26:48 -0700 Received: from gskx-1.sc.intel.com (gskx-1.sc.intel.com [172.25.149.211]) by scymds03.sc.intel.com (Postfix) with ESMTP id 8CC942F7 for ; Thu, 13 Mar 2025 17:26:48 -0700 (PDT) From: Sunil K Pandey To: libc-alpha@sourceware.org Subject: [PATCH] x86_64: Add asinh with FMA Date: Thu, 13 Mar 2025 17:26:48 -0700 Message-ID: <20250314002648.1013721-1-skpgkp2@gmail.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_SHORT, KAM_STOCKGEN, LOCAL_AUTHENTICATION_FAIL_DMARC, LOCAL_AUTHENTICATION_FAIL_SPF, NML_ADSP_CUSTOM_MED, SPF_HELO_NONE, SPF_SOFTFAIL, SPOOFED_FREEMAIL, SPOOF_GMAIL_MID, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org FMA and non-FMA performance are similar on SPR. Before After Improvement reciprocal-throughput 12.226 12.4064 -1% latency 49.4701 48.4424 2% --- benchtests/asinh-inputs | 1 + sysdeps/ieee754/dbl-64/s_asinh.c | 5 ++++ sysdeps/x86_64/fpu/multiarch/Makefile | 2 ++ sysdeps/x86_64/fpu/multiarch/s_asinh-fma.c | 7 +++++ sysdeps/x86_64/fpu/multiarch/s_asinh.c | 31 ++++++++++++++++++++++ 5 files changed, 46 insertions(+) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_asinh-fma.c create mode 100644 sysdeps/x86_64/fpu/multiarch/s_asinh.c diff --git a/benchtests/asinh-inputs b/benchtests/asinh-inputs index 8dfa37c49f..946e7b4d22 100644 --- a/benchtests/asinh-inputs +++ b/benchtests/asinh-inputs @@ -1,6 +1,7 @@ ## args: double ## ret: double ## includes: math.h +## name: workload-random 0x1.408fb643484cep-11 0x1.f0763423f1d52p-23 -0x1.681573418e494p4 diff --git a/sysdeps/ieee754/dbl-64/s_asinh.c b/sysdeps/ieee754/dbl-64/s_asinh.c index 7fd281d791..04b686a28e 100644 --- a/sysdeps/ieee754/dbl-64/s_asinh.c +++ b/sysdeps/ieee754/dbl-64/s_asinh.c @@ -32,6 +32,11 @@ static const double ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ huge = 1.00000000000000000000e+300; +#ifndef SECTION +# define SECTION +#endif + +SECTION double __asinh (double x) { diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index 3403422443..1ab46bb446 100644 --- a/sysdeps/x86_64/fpu/multiarch/Makefile +++ b/sysdeps/x86_64/fpu/multiarch/Makefile @@ -7,6 +7,7 @@ CFLAGS-e_log-fma.c = -mfma -mavx2 CFLAGS-e_log2-fma.c = -mfma -mavx2 CFLAGS-e_pow-fma.c = -mfma -mavx2 CFLAGS-e_sinh-fma.c = -mfma -mavx2 +CFLAGS-s_asinh-fma.c = -mfma -mavx2 CFLAGS-s_atan-fma.c = -mfma -mavx2 CFLAGS-s_expm1-fma.c = -mfma -mavx2 CFLAGS-s_log1p-fma.c = -mfma -mavx2 @@ -73,6 +74,7 @@ libm-sysdep_routines += \ e_pow-fma \ e_powf-fma \ e_sinh-fma \ + s_asinh-fma \ s_atan-avx \ s_atan-fma \ s_ceil-sse4_1 \ diff --git a/sysdeps/x86_64/fpu/multiarch/s_asinh-fma.c b/sysdeps/x86_64/fpu/multiarch/s_asinh-fma.c new file mode 100644 index 0000000000..293a255005 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_asinh-fma.c @@ -0,0 +1,7 @@ +#define __asinh __asinh_fma +#define __ieee754_log __ieee754_log_fma +#define __log1p __log1p_fma + +#define SECTION __attribute__ ((section (".text.fma"))) + +#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_asinh.c b/sysdeps/x86_64/fpu/multiarch/s_asinh.c new file mode 100644 index 0000000000..509d74c96b --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_asinh.c @@ -0,0 +1,31 @@ +/* Multiple versions of asinh. + Copyright (C) 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 + . */ + +#include +#if MINIMUM_X86_ISA_LEVEL < AVX2_X86_ISA_LEVEL + +extern double __redirect_asinh (double); + +# define SYMBOL_NAME asinh +# include "ifunc-fma.h" + +libc_ifunc_redirected (__redirect_asinh, __asinh, IFUNC_SELECTOR ()); + +# define __asinh __asinh_sse2 +#endif +#include