| Message ID | 20260924180008.3049459-1-adhemerval.zanella@linaro.org (mailing list archive) |
|---|---|
| Headers |
Return-Path: <libc-alpha-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E5D814BB24D1 for <patchwork@sourceware.org>; Thu, 24 Sep 2026 18:01:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5D814BB24D1 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=vDhIxURz X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-vs2-x0f.google.com (mail-vs2-x0f.google.com [IPv6:2a00:1450:4864:3a::f]) by sourceware.org (Postfix) with ESMTPS id D6B794BAE7ED for <libc-alpha@sourceware.org>; Thu, 24 Sep 2026 18:00:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D6B794BAE7ED 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 D6B794BAE7ED Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:3a::f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790272815; cv=none; b=P6PLOve1uu9Y1HsRVYANVtP/Jl5tpKHOtJkEnHu7PejBg1QONBr/DNQq3CG+Xi/FuvibbDr2O9DRGJek3tTVyRV7Bw5BJNm+FHHtA1XSZtPq4PcSTsodyTev0R4EFIWy2pLeAOBYu7JF8djKNWGE7R+GwXKxkB8ZJk0duMaXJYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790272815; c=relaxed/simple; bh=owoUGscvq1hIW7ScyJjpNAXC90a0nd057rVYzdvIXqI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=DRNNbDNqLRHljlOlcloUCicWf9rY6Lv7KWd8ZtXGsK/W+Q0CxwnvLga2sNFR35nsEsI6B0/USz1yhqnQU0PfAXiZFGWb1T4LpRg8tc3scc/mKeNDkxl+eDdHM7mayfHc71kxcZJqw85qWOfhS8X15YSTBGqDYJdr9HFz2JxZ2lw= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=vDhIxURz DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D6B794BAE7ED Received: by mail-vs2-x0f.google.com with SMTP id ada2fe7eead31-79229116537so35415137.0 for <libc-alpha@sourceware.org>; Thu, 24 Sep 2026 11:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790272814; x=1790877614; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=xRhElGcDU4XwJ5ZE6j1iqu2ZzEwmt3PxoInt0INgNzU=; b=vDhIxURzR+JA5jcwuBwpBFN/PbRvNPZkKoZLU+gaT3ARxouuf9NEmekZ0rUEUfygJC RhiE8EXOpYS46J/QlSXr6G7wh2Nzipak+yXLeot5aSUpwVA8VpVmd7ZYPX4Wx0ovtPvr jovYwPPZoRbdtVoq3PresVJyw2E0bHVKX//lpdTRnm8vHvOa2rcpdx4t/dSZSzX6V/qq FJsgjOaaUFgGjuiba1JwK3IjuQssW7/l8Vr+MPKkjSpvantqSdoMZ/5RN2N5ppW8qHhh I8HYMXdJ6Iuf7fVyfH8XERNMtBG81lZ51jaoa5Hz4o6FSPIWLUGX9ZnDdrQreW0sR6BN Z8iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790272814; x=1790877614; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xRhElGcDU4XwJ5ZE6j1iqu2ZzEwmt3PxoInt0INgNzU=; b=HJYzyaPdWsp/MAQv1sRNyHaC6yaABLqLdo4HLTh39QfKOMjucAdtSmL9uLaR6BXzby bIT1RaDpwJB3zXXVFp/Onl7ifjH2ahMHhyMFu8dw6qr1JcoPjYVbNGPudAeTl4IG8dJT aJof7amg9DQn1i7t64f7LTyHjSywjhID1EMIWw+tGzxHiSWH33C9WQZjgroA6/Hs1z2Y TZ/ot6+iV00Ax4FxEmdGbAy3dG3SpwhLECHXgAZpVlql6wQvscaqO6vOsoGS9DTQbbnl Z9o8gkK6kCnRYHY7BzL6LLP41vWhuFtLdZmrdx/taXo7OOoX70REyGxy+vhxdUVnKSci C2mg== X-Gm-Message-State: AFuF++l+0hT2Ad4VQkIwqWVuhObpaX7qmZgL+onUFVDBx5UNO0J2W4Mg Na/DJcsdOdcHs+vihQe6YGCyABY8QXUXvDoSYqzBEYYODtqZrfHWbehn1PLWlljfx1fL48bwLan MSGM6 X-Gm-Gg: AYBFou0w31cabv6G8WwhmfnwVWK06lwys6XzJhNNinjokYRJeTrxTwG6CRpeoC1zFFy r7GhBcS15QxCT9psQnJuGNTiqL4+q9oJQ23WfBxYU7+zXsvU/vbeAXHd+EVT7005qf8/+FrbpIj mflR3SrAjfKMHhPJMqPsEWJwCjfuD/4lXhMqBJK2LvCT/Pkq3K3YPuEaIVFXwr6RsT/eZlssBJ7 Ke2Qfdg5YUAx2bLml0OiMM32o1cW3VwrkK+7pJbV0PcxIY0SXyJ+s/vS7Km/kxOL/NTS+Yhx012 cwrRHlRY2fiVtuGTW/y589KQIKorBQiqiHqVxanNLpLjt2gR5801Z9jgXotQbzmjs7LvO0ZnrxA NlBCgKHa3BicXbwdiUNNYRNH03N6+n7EHcoZkXiYkHn03xSzS8nbvYgFFMSZ6lZC39LF5EYLc8a zb5iJS7SfBnLAOaTcjlmntXkw34O/SCEW/omgbM/S8jzksRcJwrUbua4FFPrtcZfxwt/VoPBLYK ilCH7e2g8ti63ZFxs3z5enWIoCegHwh/9lhmcAbgxN5z8GTdA== X-Received: by 2002:a05:6102:160f:b0:7a7:196a:84ec with SMTP id ada2fe7eead31-7af1f1fe5b5mr1606992137.36.1790272813910; Thu, 24 Sep 2026 11:00:13 -0700 (PDT) Received: from mandiga ([2804:1b3:a7c1:43a:951c:af5f:fe02:64d6]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-7b0db7eba3fsm314825137.9.2026.09.24.11.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 11:00:12 -0700 (PDT) From: Adhemerval Zanella <adhemerval.zanella@linaro.org> To: libc-alpha@sourceware.org Cc: Paul Zimmermann <Paul.Zimmermann@inria.fr> Subject: [PATCH v2 0/4] math: Make rsqrt and rsqrtf correctly rounded Date: Thu, 24 Sep 2026 14:59:22 -0300 Message-ID: <20260924180008.3049459-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
math: Make rsqrt and rsqrtf correctly rounded
|
|
Message
Adhemerval Zanella
Sept. 24, 2026, 5:59 p.m. UTC
The generic rsqrt and rsqrtf compute 1/sqrt(x) in the same precision, which rounds twice and shows up to 1 ulp for rounding to nearest (for about 26% of the inputs) and up to 2 ulp for the directed roundings. This series makes both correctly rounded in all rounding modes. The first two patches add named workloads to the rsqrt and rsqrtf benchtests, since the current inputs only cover [0.5,2) and report a single mean. For rsqrtf, evaluating 1.0 / sqrt ((double) x) is a straightforward way to get the correctly rounded result, and it was checked exhaustively for all binary32 inputs in all rounding modes. I did not use the CORE-MATH rsqrtf, since it trades some latency for larger code (three magic constants for the hard cases, plus a FENV_ACCESS dependency). For rsqrt, I used the CORE-MATH implementation and adapt to glibc. On aarch64 (Neoverse-N1), rsqrtf keeps the same throughput with about 50% higher latency. rsqrt is 51-63% slower in throughput and 33-53% slower in latency. This is the cost of correct rounding over a plain square root and division. Checked on aarch64-linux-gnu, x86_64-linux-gnu, powerpc64-linux-gnu, and loongarch64-linux-gnuf64. Changes from v1: * Fixed on i686 check-localplt regression. Adhemerval Zanella (4): benchtests: Add workloads to rsqrtf benchtests: Add workloads to rsqrt math: Make rsqrtf correctly rounded math: Use rsqrt from CORE-MATH NEWS | 3 +- SHARED-FILES | 2 + benchtests/rsqrt-inputs | 2008 ++++++++++++++++++++- benchtests/rsqrtf-inputs | 2008 ++++++++++++++++++++- sysdeps/i386/Makefile | 2 + sysdeps/i386/fpu/math-use-builtins-sqrt.h | 12 +- sysdeps/ieee754/dbl-64/libm-test-ulps | 12 + sysdeps/ieee754/dbl-64/s_rsqrt.c | 144 ++ sysdeps/ieee754/flt-32/libm-test-ulps | 12 + sysdeps/ieee754/flt-32/s_rsqrtf.c | 30 + 10 files changed, 4228 insertions(+), 5 deletions(-) create mode 100644 sysdeps/ieee754/dbl-64/s_rsqrt.c create mode 100644 sysdeps/ieee754/flt-32/s_rsqrtf.c