[PATCH v4 2/2] x86_64: roundeven with sse4.1 support

H.J. Lu hjl.tools@gmail.com
Thu May 28 12:05:32 GMT 2020


On Sat, May 2, 2020 at 8:06 AM Shen-Ta Hsieh via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> This patch adds support for the sse4.1 hardware floating point
> roundeven.

Do you have FSF paper on file?

> Here is a benchmark result on my AMD Ryzen 9 3900X system:

Since we don't know or may not care SSE4 machines without AVX,
should we make it to AVX only?

> * benchmark result before this commit
> |            |     roundeven |   roundevenf |
> |------------|---------------|--------------|
> | duration   |   3.77783e+09 |  3.77792e+09 |
> | iterations |   3.75706e+08 |  3.80448e+08 |
> | max        | 158.498       | 88.539       |
> | min        |   6.802       |  7.676       |
> | mean       |  10.0553      |  9.93018     |
>
> * benchmark result after this commit
> |            |     roundeven |    roundevenf |
> |------------|---------------|---------------|
> | duration   |   3.77242e+09 |   3.77238e+09 |
> | iterations |   5.18681e+08 |   5.2425e+08  |
> | max        | 127.338       | 172.102       |
> | min        |   7.03        |   7.03        |
> | mean       |   7.27311     |   7.19577     |
> ---
>  sysdeps/x86_64/fpu/multiarch/Makefile         |  5 +--
>  sysdeps/x86_64/fpu/multiarch/s_roundeven-c.c  |  2 ++
>  .../x86_64/fpu/multiarch/s_roundeven-sse4_1.S | 26 ++++++++++++++++
>  sysdeps/x86_64/fpu/multiarch/s_roundeven.c    | 31 +++++++++++++++++++
>  sysdeps/x86_64/fpu/multiarch/s_roundevenf-c.c |  3 ++
>  .../fpu/multiarch/s_roundevenf-sse4_1.S       | 26 ++++++++++++++++
>  sysdeps/x86_64/fpu/multiarch/s_roundevenf.c   | 31 +++++++++++++++++++
>  7 files changed, 122 insertions(+), 2 deletions(-)
>  create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundeven-c.c
>  create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundeven-sse4_1.S
>  create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundeven.c
>  create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundevenf-c.c
>  create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundevenf-sse4_1.S
>  create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundevenf.c
>
> diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile
> index 3836574f48..7e3a3f78cb 100644
> --- a/sysdeps/x86_64/fpu/multiarch/Makefile
> +++ b/sysdeps/x86_64/fpu/multiarch/Makefile
> @@ -1,11 +1,12 @@
>  ifeq ($(subdir),math)
>  libm-sysdep_routines += s_floor-c s_ceil-c s_floorf-c s_ceilf-c \
>                         s_rint-c s_rintf-c s_nearbyint-c s_nearbyintf-c \
> -                       s_trunc-c s_truncf-c
> +                       s_roundeven-c s_roundevenf-c s_trunc-c s_truncf-c
>
>  libm-sysdep_routines += s_ceil-sse4_1 s_ceilf-sse4_1 s_floor-sse4_1 \
>                         s_floorf-sse4_1 s_nearbyint-sse4_1 \
> -                       s_nearbyintf-sse4_1 s_rint-sse4_1 s_rintf-sse4_1 \
> +                       s_nearbyintf-sse4_1 s_roundeven-sse4_1 \
> +                       s_roundevenf-sse4_1 s_rint-sse4_1 s_rintf-sse4_1 \
>                         s_trunc-sse4_1 s_truncf-sse4_1
>
>  libm-sysdep_routines += e_exp-fma e_log-fma e_pow-fma s_atan-fma \
> diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundeven-c.c b/sysdeps/x86_64/fpu/multiarch/s_roundeven-c.c
> new file mode 100644
> index 0000000000..c7be43cb22
> --- /dev/null
> +++ b/sysdeps/x86_64/fpu/multiarch/s_roundeven-c.c
> @@ -0,0 +1,2 @@
> +#define __roundeven __roundeven_c
> +#include <sysdeps/ieee754/dbl-64/s_roundeven.c>
> diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundeven-sse4_1.S b/sysdeps/x86_64/fpu/multiarch/s_roundeven-sse4_1.S
> new file mode 100644
> index 0000000000..6db88a1649
> --- /dev/null
> +++ b/sysdeps/x86_64/fpu/multiarch/s_roundeven-sse4_1.S
> @@ -0,0 +1,26 @@
> +/* Round to nearest integer value, rounding halfway cases to even.
> +   double version.
> +   Copyright (C) 2019 Free Software Foundation, Inc.

Please replace all 2019 with 2020.


-- 
H.J.


More information about the Libc-alpha mailing list