From patchwork Fri Oct 25 18:21:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 838387 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp444928wri; Fri, 25 Oct 2024 11:31:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUURdHxAhgfYrDaiHjQ50ApoQKLQBZbutZJqyUGzDX8Wizc0azOo2AFfEEOKxs4DCA8346eNw==@linaro.org X-Google-Smtp-Source: AGHT+IFt7CPIwkc88r72jgzzWF1cLaOeFeSQbwlNBvT0/cFe8hSgokT3uykPr5K4zCal/YFNArxp X-Received: by 2002:ac8:59c6:0:b0:458:1651:b235 with SMTP id d75a77b69052e-4613c01539dmr3052101cf.20.1729881087187; Fri, 25 Oct 2024 11:31:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1729881087; cv=pass; d=google.com; s=arc-20240605; b=fNtB4rGjxw77d/Ukq7sb13Rkgl07xZKRDBRdrnSZ3Hun44fjUZo+WtY7gww2QhZt6w ppo2DAlacJ2t9LZr+I761bU4/0g6MFw1R+S4JTS6mfA6zK2Ec0fTTKVRa+Tr61oQbeKn grSO+fk863qmzT0NgQM8MidY5kakK+4FIP35np/DAkmtRRHYZ9YV89jJOqee5EdyW/24 iQYZjq2MCTYSW7Re3uLb6UJz5lHI9vjw1nI5ejl1hDo19xbqO1StTirCj0dcqrrgnw/q ceym0vYVSTgLDurNPkPR/eudVDluv1aOwxv/DYgztJHF9Qa1g6XFrFJJMyUWgR5YKLxo w8NA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=5OAc+/NGN0baJk6SiaAr/65j5nqTCd3UWGHwvoTfYZU=; fh=t7K9SrKfAVamsrcTQr7hpJTc6WX7Vbl5hwH62Vkp0W0=; b=dzMKLibKDP83nMxg9DBpPy2cgBvD0hnSduvTY1OZ1ziqLDkoETEYuF1M7YbXR5wdw+ OthBjhEasQEJsBp7GKiVZQYBmXQHsSz9JtwbGMTCzQ3oE8wgfV/z7xFhR4U3nCqNODAB lpAmecZapHnJ70o9o6Q83+nSxawBgCtRezt5At7JxalZ4Cu4hKSmUvmfZ3MLl5GZdOAq HMjrIGVKmVaFNA3EiMwmynAvX25udRsXD5nyaD74p9YcL6E+I46nJqwt1KFX2SemzXOR ylNT/a1VtW4O4Mqm5XkJ58PKyU+LYWQ/Vmopar3+swSdy55UUJpza/HmyQRJ26RODiMJ vuHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cmot7N0l; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d75a77b69052e-46132110220si22233381cf.137.2024.10.25.11.31.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 11:31:27 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cmot7N0l; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA46A3858416 for ; Fri, 25 Oct 2024 18:31:26 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 1DFAE3858C56 for ; Fri, 25 Oct 2024 18:27:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1DFAE3858C56 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1DFAE3858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729880847; cv=none; b=A8ELzN0krIfBU1I5LhrMrx9zIqjaUuJfRXvmYjvfTY1vB8SSYVeD5W6Xy9/Fsm5vOAYZg5oiBBVM8J38SJbKh6NmGKbl2wJLUASaakscMX6NDVap8nUPqTYA086kQVjQDhu6GAo8PM9DxgfVhEbsi7Ykuo3vZP5epRF4Co+RZ50= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729880847; c=relaxed/simple; bh=SnNogSj2Px/uEoz5EQt5UVCBDPyz+Eptj6gWSqvDOs4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cDzWgwtT2tq8Nb3M/GVU16x8qE5SYIPOQpPke5RtF0qddygTdi5KmnCdy6zXjwK4hOzvQmt0qKjVL4laEtaMsbbDGPv4bRsyU8VY5D/KUsT7t59b1oCzfinwCkKfA7qFASPV/lGfylyYKPttfUnyZs+HyRJD/6UgG103cSjcEX0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-20caccadbeeso23983585ad.2 for ; Fri, 25 Oct 2024 11:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729880841; x=1730485641; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5OAc+/NGN0baJk6SiaAr/65j5nqTCd3UWGHwvoTfYZU=; b=Cmot7N0lRrIHzTSIAxyr+HD7AIJgEmJ0gdV/M3QzuruqW8f9YF+9XkpWom506abC9e hOipCajNFqxbZLIKwbP7JeVPyN6S+Op7gDONStmLETgAmrU2T2qRD/jHIc3AsxqET7jA mWIIBlBy9M4bmpwBG+ymuaU7C0X/wEVu9KCCYOyOorRIBplUz74HT+G4Ggf0f+Z1/qKH fk87QNQbvMgCgetUdzG+cmQVjS0mHP3DL392rKGfTu8NWvANiKwrqzKFiFicsGqktDug CscqIz2JAsy1Kl3q87LQj6cILgbuqIYCVIM/tuqQBR32+dduVR6XInOjD0cPZ1Wz6a9x mwxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729880841; x=1730485641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5OAc+/NGN0baJk6SiaAr/65j5nqTCd3UWGHwvoTfYZU=; b=FtodIF3qtGJ+0mC3CIO5TmPDU8Sz1wSYp9UCnYBdKUs+1GRunJTus6K+em/D4bBB8o rNyDiRe9/UkoLx5n7kUN6H1VX5sWSdtxwQ5+i3JH9SqzUowexwARoD/TDG8TbEQH67IU dbyAfwdOIyZXkdPNfq6Ubj41qoT5iGbkJ5B1/7xu+uaH2DMz656xUBHF7telZd2Q5Vo6 DTXvXw2KQ4+9NBVUpmTbQ55OKH3USAAmKMimYFEHxF7hoQlCvktOAL2OJTDaBUOfACqw jVIwVItbRirHxXE3yliWMD6lrydQaVhsaCoecnR6zu/khkj1gkUZfA2EXQuRwK6zBq7V J6Iw== X-Gm-Message-State: AOJu0YwiD61aF/2iAuK5w6w3Z7qrr8U7VqNuWfQTnAjN9qZdxVnnKpzQ T8BasHRIaFRAr/rHBJBfU0H/pzAxd4Ldvg2+pK7/fP02ypj9uKSyD5r2eTxCgaRv1T0wg0Hro6I G X-Received: by 2002:a17:903:1cf:b0:20b:7ed8:3978 with SMTP id d9443c01a7336-210c6c3ac64mr515215ad.26.1729880841561; Fri, 25 Oct 2024 11:27:21 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:a8a8:cb9e:64f4:66fb:5ca2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-210bbf44550sm12314075ad.14.2024.10.25.11.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 11:27:21 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann , Alexei Sibidanov Subject: [PATCH 17/17] x86_64: Add exp2m1f with FMA Date: Fri, 25 Oct 2024 15:21:55 -0300 Message-ID: <20241025182614.2022697-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025182614.2022697-1-adhemerval.zanella@linaro.org> References: <20241025182614.2022697-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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~patch=linaro.org@sourceware.org The CORE-MATH exp10m1f implementation showed slight worse latency when using x86_64 baseline ABI. This patch adds a ifunc variant with similar performance for x86_64-v3. Reviewed-by: Noah Goldstein --- sysdeps/ieee754/flt-32/s_exp2m1f.c | 2 ++ sysdeps/x86_64/fpu/multiarch/Makefile | 2 ++ sysdeps/x86_64/fpu/multiarch/s_exp2m1f-fma.c | 4 +++ sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c | 33 ++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_exp2m1f-fma.c create mode 100644 sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c diff --git a/sysdeps/ieee754/flt-32/s_exp2m1f.c b/sysdeps/ieee754/flt-32/s_exp2m1f.c index f899152d2a..3e79030888 100644 --- a/sysdeps/ieee754/flt-32/s_exp2m1f.c +++ b/sysdeps/ieee754/flt-32/s_exp2m1f.c @@ -189,4 +189,6 @@ __exp2m1f (float x) return (s - 1.0) + w * c0; } } +#ifndef __exp2m1f libm_alias_float (__exp2m1, exp2m1) +#endif diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index dcff4df2f1..e823d2fcc6 100644 --- a/sysdeps/x86_64/fpu/multiarch/Makefile +++ b/sysdeps/x86_64/fpu/multiarch/Makefile @@ -12,6 +12,7 @@ CFLAGS-s_sin-fma.c = -mfma -mavx2 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-e_exp2f-fma.c = -mfma -mavx2 CFLAGS-e_expf-fma.c = -mfma -mavx2 @@ -74,6 +75,7 @@ libm-sysdep_routines += \ s_cosf-fma \ s_cosf-sse2 \ s_exp10m1f-fma \ + s_exp2m1f-fma \ s_expm1-fma \ s_floor-sse4_1 \ s_floorf-sse4_1 \ diff --git a/sysdeps/x86_64/fpu/multiarch/s_exp2m1f-fma.c b/sysdeps/x86_64/fpu/multiarch/s_exp2m1f-fma.c new file mode 100644 index 0000000000..bfa00eae4e --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_exp2m1f-fma.c @@ -0,0 +1,4 @@ +#define __exp2m1f __exp2m1f_fma +#define SECTION __attribute__ ((section (".text.fma"))) + +#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c b/sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c new file mode 100644 index 0000000000..8e2d7ec384 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c @@ -0,0 +1,33 @@ +/* Multiple versions of exp2m1. + Copyright (C) 2024 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 +# include + +extern float __redirect_exp2m1f (float); + +# define SYMBOL_NAME exp2m1f +# include "ifunc-fma.h" + +libc_ifunc_redirected (__redirect_exp2m1f, __exp2m1f, IFUNC_SELECTOR ()); +libm_alias_float (__exp2m1, exp2m1) + +# define __exp2m1f __exp2m1f_sse2 +#endif +#include