public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: DJ Delorie <dj@redhat.com>
Cc: libc-alpha@sourceware.org, josmyers@redhat.com,
	Paul.Zimmermann@inria.fr, sibid@uvic.ca
Subject: Re: [PATCH 15/15] x86_64: Add asinpif with FMA
Date: Tue, 11 Feb 2025 11:12:27 -0300	[thread overview]
Message-ID: <decba9a2-c6eb-4f6d-bac8-567d53c00177@linaro.org> (raw)
In-Reply-To: <xnjz9xmfmh.fsf@greed.delorie.com>



On 10/02/25 22:31, DJ Delorie wrote:
> 
> LGTM
> 
> Reviewed-by: DJ Delorie <dj@redhat.com>
> 
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>> The CORE-MATH asinpif implementation showed slight worse performance
>> when using x86_64 baseline ABI due its usage of fma on fast path.
>> This patch adds a ifunc variant with similar performance for x86_64-v3.
> 
> Do you have the performance numbers to report?

It turns out that Paul has suggested to just remove the fma operation [1]
on the fast-path; which makes the code faster on x86_64 and x86_64-v2
and the iFUNC variant not required anymore.  I will update the asinpif
with the new performance numbers. 

[1] https://gitlab.inria.fr/core-math/core-math/-/commit/ccdd955b6fa614c8d88bd1d6fd323abaf43cfb3f

> 
>> ---
>>  sysdeps/ieee754/flt-32/s_asinpif.c           |  2 ++
>>  sysdeps/x86_64/fpu/multiarch/Makefile        |  2 ++
>>  sysdeps/x86_64/fpu/multiarch/s_asinpif-fma.c |  4 +++
>>  sysdeps/x86_64/fpu/multiarch/s_asinpif.c     | 33 ++++++++++++++++++++
> 
> So this is an ifunc of asinpf() itself, not fma...
> 
>> diff --git a/sysdeps/ieee754/flt-32/s_asinpif.c b/sysdeps/ieee754/flt-32/s_asinpif.c
>>        return r;
>>      }
>>  }
>> +#ifndef __asinpif
>>  libm_alias_float (__asinpi, asinpi)
>> +#endif
> 
> Ok.
> 
>> diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile
>>  CFLAGS-s_sincos-fma.c = -mfma -mavx2
>>  CFLAGS-s_exp10m1f-fma.c = -mfma -mavx2
>>  CFLAGS-s_exp2m1f-fma.c = -mfma -mavx2
>> +CFLAGS-s_asinpif-fma.c = -mfma -mavx2
>>  
>>  CFLAGS-e_exp2f-fma.c = -mfma -mavx2
>>  CFLAGS-e_expf-fma.c = -mfma -mavx2
>> @@ -68,6 +69,7 @@ libm-sysdep_routines += \
>>    e_logf-fma \
>>    e_pow-fma \
>>    e_powf-fma \
>> +  s_asinpif-fma \
>>    s_atan-avx \
>>    s_atan-fma \
>>    s_ceil-sse4_1 \
> 
> Ok.
> 
>> diff --git a/sysdeps/x86_64/fpu/multiarch/s_asinpif-fma.c b/sysdeps/x86_64/fpu/multiarch/s_asinpif-fma.c
>> +#define __asinpif __asinpif_fma
>> +#define SECTION __attribute__ ((section (".text.fma")))
>> +
>> +#include <sysdeps/ieee754/flt-32/s_asinpif.c>
> 
> So same code, but without the alias and built with different options, to
> make a variant.  Ok.
> 
>> diff --git a/sysdeps/x86_64/fpu/multiarch/s_asinpif.c b/sysdeps/x86_64/fpu/multiarch/s_asinpif.c
>> +/* Multiple versions of asinpif.
>> +   Copyright (C) 2024-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
>> +   <https://www.gnu.org/licenses/>.  */
> 
> Ok.
> 
>> +#include <sysdeps/x86/isa-level.h>
>> +#if MINIMUM_X86_ISA_LEVEL < AVX2_X86_ISA_LEVEL
>> +# include <libm-alias-float.h>
>> +
>> +extern float __redirect_asinpif (float);
>> +
>> +# define SYMBOL_NAME asinpif
>> +# include "ifunc-fma.h"
>> +
>> +libc_ifunc_redirected (__redirect_asinpif, __asinpif, IFUNC_SELECTOR ());
>> +libm_alias_float (__asinpi, asinpi)
>> +
>> +# define __asinpif __asinpif_sse2
>> +#endif
>> +#include <sysdeps/ieee754/flt-32/s_asinpif.c>
> 
> So if the build picks this *.c file, it adds the ifunc code but also
> includes the default asinpf() as __asinpif_sse2().  Ok.
> 


  reply	other threads:[~2025-02-11 14:12 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-31 19:17 [PATCH 00/15] Add c23 CORE-MATH binary32 implementations to libm Adhemerval Zanella
2025-01-31 19:17 ` [PATCH 01/15] benchtests: Add acospif Adhemerval Zanella
2025-02-07 22:00   ` DJ Delorie
2025-01-31 19:17 ` [PATCH 02/15] benchtests: Add asinpif Adhemerval Zanella
2025-02-07 22:06   ` DJ Delorie
2025-02-11 12:56     ` Adhemerval Zanella Netto
2025-01-31 19:17 ` [PATCH 03/15] benchtests: Add atan2pif Adhemerval Zanella
2025-02-07 22:19   ` DJ Delorie
2025-01-31 19:17 ` [PATCH 04/15] benchtests: Add atanpif Adhemerval Zanella
2025-02-07 22:36   ` DJ Delorie
2025-01-31 19:17 ` [PATCH 05/15] benchtests: Add cospif Adhemerval Zanella
2025-02-07 22:51   ` DJ Delorie
2025-02-11 13:13     ` Adhemerval Zanella Netto
2025-02-11 19:56       ` DJ Delorie
2025-01-31 19:17 ` [PATCH 06/15] benchtests: Add sinpif Adhemerval Zanella
2025-02-07 22:54   ` DJ Delorie
2025-02-11 13:13     ` Adhemerval Zanella Netto
2025-02-11 19:58       ` DJ Delorie
2025-01-31 19:17 ` [PATCH 07/15] benchtests: Add tanpif Adhemerval Zanella
2025-02-01  8:18   ` Paul Zimmermann
2025-02-07 22:55   ` DJ Delorie
2025-01-31 19:17 ` [PATCH 08/15] math: Use acospif from CORE-MATH Adhemerval Zanella
2025-02-01  8:22   ` Paul Zimmermann
2025-02-08  2:15   ` DJ Delorie
2025-02-11 13:16     ` Adhemerval Zanella Netto
2025-01-31 19:17 ` [PATCH 09/15] math: Use asinpif " Adhemerval Zanella
2025-02-01  8:28   ` Paul Zimmermann
2025-02-03  6:40   ` Paul Zimmermann
2025-02-03 12:27     ` Adhemerval Zanella Netto
2025-02-08  3:03   ` DJ Delorie
2025-01-31 19:17 ` [PATCH 10/15] math: Use atan2pif " Adhemerval Zanella
2025-02-08  4:20   ` DJ Delorie
2025-02-11 13:27     ` Adhemerval Zanella Netto
2025-01-31 19:17 ` [PATCH 11/15] math: Use atanpif " Adhemerval Zanella
2025-02-03  7:09   ` Paul Zimmermann
2025-02-10 22:29   ` DJ Delorie
2025-02-11 14:07     ` Adhemerval Zanella Netto
2025-02-11 14:22       ` Paul Zimmermann
2025-02-11 20:01         ` DJ Delorie
2025-02-11 20:10           ` Adhemerval Zanella Netto
2025-01-31 19:17 ` [PATCH 12/15] math: Use cospif " Adhemerval Zanella
2025-02-03  7:16   ` Paul Zimmermann
2025-02-10 23:07   ` DJ Delorie
2025-01-31 19:17 ` [PATCH 13/15] math: Use sinpif " Adhemerval Zanella
2025-02-03 10:39   ` Paul Zimmermann
2025-02-11  0:56   ` DJ Delorie
2025-01-31 19:17 ` [PATCH 14/15] math: Use tanpif " Adhemerval Zanella
2025-02-03 11:05   ` Paul Zimmermann
2025-02-11  1:15   ` DJ Delorie
2025-02-11 14:09     ` Adhemerval Zanella Netto
2025-01-31 19:17 ` [PATCH 15/15] x86_64: Add asinpif with FMA Adhemerval Zanella
2025-01-31 22:59   ` Noah Goldstein
2025-02-11  1:31   ` DJ Delorie
2025-02-11 14:12     ` Adhemerval Zanella Netto [this message]
2025-02-11 20:13       ` Adhemerval Zanella Netto
2025-02-12 11:00         ` Adhemerval Zanella Netto
2025-02-01  8:14 ` [PATCH 00/15] Add c23 CORE-MATH binary32 implementations to libm Paul Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=decba9a2-c6eb-4f6d-bac8-567d53c00177@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=Paul.Zimmermann@inria.fr \
    --cc=dj@redhat.com \
    --cc=josmyers@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=sibid@uvic.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).