From patchwork Sat May 22 00:22:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6Kyd5piH6YGUKFNoZW4tVGEgSHNpZWgp?= X-Patchwork-Id: 43536 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53B223AA9412; Sat, 22 May 2021 00:23:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53B223AA9412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621643025; bh=umFtr/i4aJGcfNvku+ERvpAYvAFeSsZ+u2aXSWdLzFc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Yq5U9/L8sO+CcQhR4IhxIKmNi2Oa0ugbjAlQpDXbI61336bNFXobe+xG7I9WEfNPc RaRK9agIeU1Thrrf15Abm6CAgdV5LWnhWQueCWnli+FkyWws5lJniucvOE7j1XSHe2 LScZe5Abr/UeEu9Nu3jq0+z3RuOPfmHQ/Bk/tFyY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 7B6E8383F41A for ; Sat, 22 May 2021 00:23:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7B6E8383F41A Received: by mail-pf1-x42d.google.com with SMTP id y15so4710789pfn.13 for ; Fri, 21 May 2021 17:23:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=umFtr/i4aJGcfNvku+ERvpAYvAFeSsZ+u2aXSWdLzFc=; b=cYiAFNeJVOiiHFKeZFRJKXegx3Tuv6WfP9/aIPCGQdiVAZgOIYOJCR3XoTiRgIoswl LrgqYJlop6IdkALmKOP2Khr3RY1vl4I3rkVT5hQBItJAvbQWwjCXi8QO0YGAwfqq0yR/ 4LJmJpUyQ1Klx85rPyZa8fTAJ45ACqI/hkQR9DRRf4dmzntkzdK9+5VaOfVDB6WLdXDy nnTPGxjuYyrW4MXCW+b/M0foVHfUL/Z9O/vgeW+uZuPBD5Iesm9EqhyebhaIr/ClHIP4 D0UgcsIruX1qVztesGcQuGBxiY6yHYFjHK532bt96FBEnhn3DRoxXlkkNkrdUAI0iRu/ /keA== X-Gm-Message-State: AOAM532UiMDg5TWfwmmTknfZ+Ix3K7rdCYZXFLROgXwoN2K7znw2qFnz wRbDQOmF9uWS3wUMSG4sibhAbPl1CjY9cg== X-Google-Smtp-Source: ABdhPJzWi6SkRtteSP6lrRRnIYV3eHSmKgj7Q+lRvdTd45GkMwiBQuaKik9uPuSmR9LSPq2BYtXXSg== X-Received: by 2002:a62:d447:0:b029:291:19f7:ddcd with SMTP id u7-20020a62d4470000b029029119f7ddcdmr12794785pfl.54.1621643020237; Fri, 21 May 2021 17:23:40 -0700 (PDT) Received: from fragrant.. (220-135-3-239.HINET-IP.hinet.net. [220.135.3.239]) by smtp.gmail.com with ESMTPSA id d3sm9256156pjw.35.2021.05.21.17.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 17:23:39 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v6 2/3] x86_64: roundeven with sse4.1 support Date: Sat, 22 May 2021 08:22:26 +0800 Message-Id: <20210522002227.2234377-2-ibmibmibm.tw@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210522002227.2234377-1-ibmibmibm.tw@gmail.com> References: <20210522002227.2234377-1-ibmibmibm.tw@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Shen-Ta Hsieh via Libc-alpha From: =?utf-8?b?6Kyd5piH6YGUKFNoZW4tVGEgSHNpZWgp?= Reply-To: Shen-Ta Hsieh Cc: Shen-Ta Hsieh Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This patch adds support for the sse4.1 hardware floating point roundeven. Here is a benchmark result on my AMD Ryzen 9 3900X system: * benchmark result before this commit | | roundeven | roundevenf | |------------|--------------|--------------| | duration | 3.77659e+09 | 3.77504e+09 | | iterations | 3.97043e+08 | 4.36752e+08 | | max | 83.714 | 58.861 | | min | 7.144 | 6.27 | | mean | 9.51179 | 8.64345 | * benchmark result after this commit | | roundeven | roundevenf | |------------|--------------|--------------| | duration | 3.76913e+09 | 3.76923e+09 | | iterations | 5.55921e+08 | 5.64822e+08 | | max | 211.698 | 439.09 | | min | 6.498 | 6.422 | | mean | 6.77998 | 6.6733 | Signed-off-by: Shen-Ta Hsieh Reviewed-by: H.J. Lu --- 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 | 24 ++++++++++++++ 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 | 24 ++++++++++++++ sysdeps/x86_64/fpu/multiarch/s_roundevenf.c | 31 +++++++++++++++++++ 7 files changed, 118 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 57892c56bb..d425ffd6d3 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 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..6ae8f6b1d3 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundeven-sse4_1.S @@ -0,0 +1,24 @@ +/* Copyright (C) 2021 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 + + .section .text.sse4.1,"ax",@progbits +ENTRY(__roundeven_sse41) + roundsd $8, %xmm0, %xmm0 + ret +END(__roundeven_sse41) diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundeven.c b/sysdeps/x86_64/fpu/multiarch/s_roundeven.c new file mode 100644 index 0000000000..d92eda652a --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundeven.c @@ -0,0 +1,31 @@ +/* Multiple versions of __roundeven. + Copyright (C) 2021 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 + +#define roundeven __redirect_roundeven +#define __roundeven __redirect___roundeven +#include +#undef roundeven +#undef __roundeven + +#define SYMBOL_NAME roundeven +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_roundeven, __roundeven, IFUNC_SELECTOR ()); +libm_alias_double (__roundeven, roundeven) diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundevenf-c.c b/sysdeps/x86_64/fpu/multiarch/s_roundevenf-c.c new file mode 100644 index 0000000000..72a6e7d1fb --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundevenf-c.c @@ -0,0 +1,3 @@ +#undef __roundevenf +#define __roundevenf __roundevenf_c +#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundevenf-sse4_1.S b/sysdeps/x86_64/fpu/multiarch/s_roundevenf-sse4_1.S new file mode 100644 index 0000000000..a76e10807e --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundevenf-sse4_1.S @@ -0,0 +1,24 @@ +/* Copyright (C) 2021 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 + + .section .text.sse4.1,"ax",@progbits +ENTRY(__roundevenf_sse41) + roundss $8, %xmm0, %xmm0 + ret +END(__roundevenf_sse41) diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundevenf.c b/sysdeps/x86_64/fpu/multiarch/s_roundevenf.c new file mode 100644 index 0000000000..2ee196e68f --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundevenf.c @@ -0,0 +1,31 @@ +/* Multiple versions of __roundevenf. + Copyright (C) 2021 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 + +#define roundevenf __redirect_roundevenf +#define __roundevenf __redirect___roundevenf +#include +#undef roundevenf +#undef __roundevenf + +#define SYMBOL_NAME roundevenf +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_roundevenf, __roundevenf, IFUNC_SELECTOR ()); +libm_alias_float (__roundeven, roundeven)