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: 2002476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=RJ/GcpsN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XZrwB4FYwz1xtp for ; Sat, 26 Oct 2024 05:31:38 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92D833858415 for ; Fri, 25 Oct 2024 18:31:36 +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-Google-Smtp-Source: AGHT+IGsCuKxYgvY6cU8VgNniDQ8Lm7tQRIB5+XyiQ829v2crq4dMrMJyOB1BZGhurn0rlflNDC4DA== 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~incoming=patchwork.ozlabs.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