From patchwork Fri Oct 25 18:21:54 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: 838388 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp444953wri; Fri, 25 Oct 2024 11:31:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDlRFf+tYX4MeUogl5RCbmv1HWChGEsE6b5zLiH3lhEBTt1bX3hlgpmcvQ5+H15z0OiNfLrg==@linaro.org X-Google-Smtp-Source: AGHT+IHpHNpg/tLe4GBmQD+8QXaRtgHof5FNZXGIvngrpICO3n18IOVZ+x+vZ8ENHmza66EjQ0Hq X-Received: by 2002:a05:6102:512c:b0:4a5:e2a8:ec8f with SMTP id ada2fe7eead31-4a8cfb5de31mr438004137.9.1729881089894; Fri, 25 Oct 2024 11:31:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1729881089; cv=pass; d=google.com; s=arc-20240605; b=Bh4lFaNlmmh5P1FyL9ecdwX+HnmwdA34sJ+WLhMWrFgA/EBQLRayypXJSJM9YuCFr3 8WG+cHEEhIY+ma024ux1cohyJ0KjsSxnFt21SzNyi40X6K7hxkbR/9Ly10aNUJXmh8om 4/k8Dxq7wWTypreoGelTljDHbRquh4tyvmeqwm93Ul9J2DtlmP10/CW/b9+CeqI+WK7m 7uol7CXFdfE5NEyT8MHUSJhGRlDu1HBzRtDZ9mGXVFfzzmmrXHD29Y3Z31lk0hgMNfAw yyrRY2t/LVoPTtKz39nc0MElOJWXIKpitC/mulEfWFDWIHFbX9oNzeT5Lky38hSeoLvb tBNQ== 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=xyGPGMlYmM4osUTc1NN7SiyHWdyIHL4A/JrR1aCnMF0=; fh=t7K9SrKfAVamsrcTQr7hpJTc6WX7Vbl5hwH62Vkp0W0=; b=D90MSmPCiyBw4QIrrmmnGzq9cbRppTEKz86ElM33N6HwmL6KKg27Bc//guwNr0vL1t TTlUiN/S+g9yddIRreszPRZibN4qSRdkvipSFGZmknBAeJ8pimBwi5OrpxjMzmzwareQ eLyx1SjUDpT3hYE3gT+htFSeSd2ghbPRE+0zccDJQHCudvSZLvV283sST0s5xj3CnaJ8 MEo1mPyukQo77iZ0OXAvpMal9WnEFkQNJscGmCcyFmLlXgMxwkuIxrR36Cy5PJPp3w9I TQy3ngTGTlXy10mqAMp5mXFLLDQ5pXToJaYOmD+HgcTO5JveogJxSInQnKth6WAuuDX7 2SaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="RJ/GcpsN"; 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 a1e0cc1a2514c-85580a833b8si539349241.66.2024.10.25.11.31.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 11:31:29 -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="RJ/GcpsN"; 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 7B2293858403 for ; Fri, 25 Oct 2024 18:31:29 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id EE3253858415 for ; Fri, 25 Oct 2024 18:27:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE3253858415 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 EE3253858415 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729880843; cv=none; b=FdsWXuLeBSx6dWpnSUxkma9UPj8zUN+K6MOa3ZKBFt0nyiYOUr58PqHullUR8AN6+WCISnfn/PvNEgxrIHGHZAfDa6X+yYzoL+URc7kawqBerpp+MUOkCdPtmmcPLpCr4OotPbd9otuPBJ6mb79X8mrO2LJCqfcau0Z266DARYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729880843; c=relaxed/simple; bh=3UGnSedWSu6ydS7c5jLCgKun80gK6rYWwh8+Y5GQZJk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Y/6NiOhhidHhrwSIUIxc9CU/ZWh7zprxu/CfNDTUr2ONIpcH8SApliJ5mWJ/Q44WjEAFtjjY/0YIWZCULJEmESYkLCz9ZTG1TlorDjXaphpx8qdVK3P4eVGCON1uzXfFYh/c7QFiCcCDHCYFwLryn3hcU3TJi2VdvChPTJybtg4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-20c767a9c50so20216275ad.1 for ; Fri, 25 Oct 2024 11:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729880840; x=1730485640; 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=xyGPGMlYmM4osUTc1NN7SiyHWdyIHL4A/JrR1aCnMF0=; b=RJ/GcpsNiokUgFW8zUZebvG0ShNfxuJRmAUWzyEWJRDlYI+WmW/6WmnRkf0sRcwCkO 3otL9CC21+8G9YwsXN7jwJpCNsB7S84bEqreuZTYatEkxqNj2xMSEAAny8La7kaHBg24 09etMQyI6nqCwpJWdmMDeHI1wnb6kkEw7DwI7deWZgY4cC/g6l1jWsK3O/BF2DBdsDyF SppuUDBjxoWjQRm6EKsUfSwK71NAHOFIH8LmvdD+sh2uJg6Bv3tlspQUVQVrsQtGk78P JPNE7LpqtC+q2BQ4lkr6n/NfMZLi6I7SPGFJsZBsWA0Cs51oXztd4WQ3M+SofPTmhbO4 +MYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729880840; x=1730485640; 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=xyGPGMlYmM4osUTc1NN7SiyHWdyIHL4A/JrR1aCnMF0=; b=kNHLsZUBIt4If3IChSTyCquqEoT0FGIVNpexeM9V7+6zhBq203uQsJZBR2GlysYvIJ G0cO858Jv+/YXVc7IAIBcI9R9uOnLnYk0UXTFYhdXLwW3tNLTAuyEujPFdAVGok3kzDQ qCxT9MjlaMHB5rnlzU+XAGosMqIesueH5zSlWedfM3LM/iv9W/zJIe5XYLQoc7HHImEZ cINzcIHDzixn9DB3XAZ98gKYN/BTe8pBDyiEjAFByljAQTqc6IoHOwZ3OMLikUsaCoTU Ki5WrCSnn+k4Oap4IF2QjQSxy7XCcZsbxDYOKbPyTGhzS06EsCLOGDderwD34tM4Qbkk syDA== X-Gm-Message-State: AOJu0Yw5WlMNAW6owwcjbmLMyY1qsoc2Y4rMCR7o8SPzu0UNUn6GGNNB clUGOWrmPONwhD7raSAAN13PG5SkSqhiJguw3mkCnQ0Mo3j47Dz7v1cJ0T1I/SVuGb9X3vk8g7d A X-Received: by 2002:a17:903:32c4:b0:20c:7796:5e76 with SMTP id d9443c01a7336-210c68d82f3mr967495ad.18.1729880839645; Fri, 25 Oct 2024 11:27:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 11:27:19 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann , Alexei Sibidanov Subject: [PATCH 16/17] x86_64: Add exp10m1f with FMA Date: Fri, 25 Oct 2024 15:21:54 -0300 Message-ID: <20241025182614.2022697-17-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_exp10m1f.c | 2 ++ sysdeps/x86_64/fpu/multiarch/Makefile | 2 ++ sysdeps/x86_64/fpu/multiarch/s_exp10m1f-fma.c | 4 +++ sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c | 33 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_exp10m1f-fma.c create mode 100644 sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c diff --git a/sysdeps/ieee754/flt-32/s_exp10m1f.c b/sysdeps/ieee754/flt-32/s_exp10m1f.c index 610f269b01..c918c905e8 100644 --- a/sysdeps/ieee754/flt-32/s_exp10m1f.c +++ b/sysdeps/ieee754/flt-32/s_exp10m1f.c @@ -222,4 +222,6 @@ __exp10m1f (float x) return (s - 1.0) + w * c0; } } +#ifndef __exp10m1f libm_alias_float (__exp10m1, exp10m1) +#endif diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index cbe09d49f4..dcff4df2f1 100644 --- a/sysdeps/x86_64/fpu/multiarch/Makefile +++ b/sysdeps/x86_64/fpu/multiarch/Makefile @@ -11,6 +11,7 @@ CFLAGS-s_log1p-fma.c = -mfma -mavx2 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-e_exp2f-fma.c = -mfma -mavx2 CFLAGS-e_expf-fma.c = -mfma -mavx2 @@ -72,6 +73,7 @@ libm-sysdep_routines += \ s_ceilf-sse4_1 \ s_cosf-fma \ s_cosf-sse2 \ + s_exp10m1f-fma \ s_expm1-fma \ s_floor-sse4_1 \ s_floorf-sse4_1 \ diff --git a/sysdeps/x86_64/fpu/multiarch/s_exp10m1f-fma.c b/sysdeps/x86_64/fpu/multiarch/s_exp10m1f-fma.c new file mode 100644 index 0000000000..3dda04e2dd --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_exp10m1f-fma.c @@ -0,0 +1,4 @@ +#define __exp10m1f __exp10m1f_fma +#define SECTION __attribute__ ((section (".text.fma"))) + +#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c b/sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c new file mode 100644 index 0000000000..8040b7ed79 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c @@ -0,0 +1,33 @@ +/* Multiple versions of exp10m1. + 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_exp10m1f (float); + +# define SYMBOL_NAME exp10m1f +# include "ifunc-fma.h" + +libc_ifunc_redirected (__redirect_exp10m1f, __exp10m1f, IFUNC_SELECTOR ()); +libm_alias_float (__exp10m1, exp10m1) + +# define __exp10m1f __exp10m1f_sse2 +#endif +#include