Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/833408/?format=api
{ "id": 833408, "url": "http://patchwork.ozlabs.org/api/1.2/patches/833408/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/1509637838-21839-1-git-send-email-raji@linux.vnet.ibm.com/", "project": { "id": 41, "url": "http://patchwork.ozlabs.org/api/1.2/projects/41/?format=api", "name": "GNU C Library", "link_name": "glibc", "list_id": "libc-alpha.sourceware.org", "list_email": "libc-alpha@sourceware.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1509637838-21839-1-git-send-email-raji@linux.vnet.ibm.com>", "list_archive_url": null, "date": "2017-11-02T15:50:38", "name": "[PATCHv3] New generic sinf", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "3306b3f12c6654158f01cdde3e9408db596e24d9", "submitter": { "id": 64254, "url": "http://patchwork.ozlabs.org/api/1.2/people/64254/?format=api", "name": "Rajalakshmi Srinivasaraghavan", "email": "raji@linux.vnet.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/1509637838-21839-1-git-send-email-raji@linux.vnet.ibm.com/mbox/", "series": [ { "id": 11535, "url": "http://patchwork.ozlabs.org/api/1.2/series/11535/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=11535", "date": "2017-11-02T15:50:38", "name": "[PATCHv3] New generic sinf", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/11535/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/833408/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/833408/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<libc-alpha-return-86679-incoming=patchwork.ozlabs.org@sourceware.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "mailing list libc-alpha@sourceware.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-86679-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"yJ5zNvjE\"; dkim-atps=neutral", "sourceware.org; auth=none" ], "Received": [ "from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3ySV1c6Hm0z9sRW\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 3 Nov 2017 02:51:16 +1100 (AEDT)", "(qmail 46882 invoked by alias); 2 Nov 2017 15:51:10 -0000", "(qmail 46872 invoked by uid 89); 2 Nov 2017 15:51:10 -0000" ], "DomainKey-Signature": "a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id; q=dns; s=\n\tdefault; b=wi2IYV66H1FxEUEPprESw2o82O1GeEoBrTaZrOqBM4WHRGPlzNr8/\n\tHlM1SrshRr59xk+HDtscLmuoH7We/RXAluocw2jgoW6kDzd6ViGo28+0jYxityuD\n\tiwxA2s3bZYYLBVYh+o2GGtAekYO/tDotU41gY//wnu8Vb3vorOytlI=", "DKIM-Signature": "v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id; s=default;\n\tbh=BRGIM8NKyGzLgDqI5/kck6p4Zek=; b=yJ5zNvjEIDFZ9YpcwLMhF/S0tT8j\n\t4CywWhB3PH/9IffcJXEy9zfegJ62juzAl50nAAlgIFiXlLubrzKyVrEAb9+8dsSF\n\tFH1bzQWBV0erg6IpsD7oUMU8Vf8etJmGJew/Ip0Fdx/u94jQvEcbC5UQzb1WFPSj\n\to5gKOB3wuNDeklY=", "Mailing-List": "contact libc-alpha-help@sourceware.org; run by ezmlm", "Precedence": "bulk", "List-Id": "<libc-alpha.sourceware.org>", "List-Unsubscribe": "<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>", "List-Subscribe": "<mailto:libc-alpha-subscribe@sourceware.org>", "List-Archive": "<http://sourceware.org/ml/libc-alpha/>", "List-Post": "<mailto:libc-alpha@sourceware.org>", "List-Help": "<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>", "Sender": "libc-alpha-owner@sourceware.org", "X-Virus-Found": "No", "X-Spam-SWARE-Status": "No, score=-23.4 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tKAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY,\n\tRCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Ian, ian,\n\tSMALL, taylor", "X-HELO": "mx0a-001b2d01.pphosted.com", "From": "Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>", "To": "libc-alpha@sourceware.org", "Cc": "Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>", "Subject": "[PATCHv3] New generic sinf", "Date": "Thu, 2 Nov 2017 21:20:38 +0530", "X-TM-AS-GCONF": "00", "x-cbid": "17110215-0040-0000-0000-000003E9D1B3", "X-IBM-AV-DETECTION": "SAVI=unused REMOTE=unused XFE=unused", "x-cbparentid": "17110215-0041-0000-0000-000025EC5DB4", "Message-Id": "<1509637838-21839-1-git-send-email-raji@linux.vnet.ibm.com>", "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-11-02_05:, , signatures=0", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n\tpriorityscore=1501\n\tmalwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0\n\tclxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0\n\tclassifier=spam adjust=0 reason=mlx scancount=1\n\tengine=8.0.1-1707230000\n\tdefinitions=main-1711020197" }, "content": "Changes since version 2:\n\n - Added code comments.\n - Added BZ in Changelog.\n - Spacing correction.\n - Added const to theta2 variable.\n - Change in some constant representation.\n\n---\nChanges since version 1:\n\n - Removed sccs id.\n\n---\nThe same logic used in s_sinf.S version of x86 and powerpc\nis moved as generic s_sinf.c, so there is no performance\nimprovement in x86_64 and powerpc64.\nFor s390, this is the improvement noted.\n\nWith patch:\nbenchtests/bench-sinf\n \"\": {\n \"duration\": 9.91026e+09,\n \"iterations\": 4.6512e+08,\n \"max\": 130.26,\n \"min\": 7.027,\n \"mean\": 21.3069\n }\nWithout patch:\n \"\": {\n \"duration\": 1.00656e+10,\n \"iterations\": 1.65699e+08,\n \"max\": 1740.57,\n \"min\": 4.729,\n \"mean\": 60.7461\n }\n\nAlso addressed comments from Joseph on generic sincosf version\nRef:https://sourceware.org/ml/libc-alpha/2017-10/msg00367.html\n\n---\n\nThis implementation is based on optimized sinf assembly versions\nof x86_64 and powerpc.\n\nTested on s390, x86_64 and powerpc64le.\n\n2017-11-02 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>\n\n \t[BZ #5997]\n\t* sysdeps/ieee754/flt-32/s_sinf.c: New implementation.\n---\n sysdeps/ieee754/flt-32/s_sinf.c | 262 +++++++++++++++++++++++++++++++++-------\n 1 file changed, 221 insertions(+), 41 deletions(-)", "diff": "diff --git a/sysdeps/ieee754/flt-32/s_sinf.c b/sysdeps/ieee754/flt-32/s_sinf.c\nindex 3ec98f811d..f611d45c9d 100644\n--- a/sysdeps/ieee754/flt-32/s_sinf.c\n+++ b/sysdeps/ieee754/flt-32/s_sinf.c\n@@ -1,21 +1,20 @@\n-/* s_sinf.c -- float version of s_sin.c.\n- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.\n- */\n-\n-/*\n- * ====================================================\n- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n- *\n- * Developed at SunPro, a Sun Microsystems, Inc. business.\n- * Permission to use, copy, modify, and distribute this\n- * software is freely granted, provided that this notice\n- * is preserved.\n- * ====================================================\n- */\n-\n-#if defined(LIBM_SCCS) && !defined(lint)\n-static char rcsid[] = \"$NetBSD: s_sinf.c,v 1.4 1995/05/10 20:48:16 jtc Exp $\";\n-#endif\n+/* Compute sine of argument.\n+ Copyright (C) 2017 Free Software Foundation, Inc.\n+ This file is part of the GNU C Library.\n+\n+ The GNU C Library is free software; you can redistribute it and/or\n+ modify it under the terms of the GNU Lesser General Public\n+ License as published by the Free Software Foundation; either\n+ version 2.1 of the License, or (at your option) any later version.\n+\n+ The GNU C Library is distributed in the hope that it will be useful,\n+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ Lesser General Public License for more details.\n+\n+ You should have received a copy of the GNU Lesser General Public\n+ License along with the GNU C Library; if not, see\n+ <http://www.gnu.org/licenses/>. */\n \n #include <errno.h>\n #include <math.h>\n@@ -28,35 +27,216 @@ static char rcsid[] = \"$NetBSD: s_sinf.c,v 1.4 1995/05/10 20:48:16 jtc Exp $\";\n # define SINF_FUNC SINF\n #endif\n \n-float SINF_FUNC(float x)\n-{\n-\tfloat y[2],z=0.0;\n-\tint32_t n, ix;\n+/* Chebyshev constants for cos, range -PI/4 - PI/4. */\n+static const double C0 = -0x1.ffffffffe98aep-2;\n+static const double C1 = 0x1.55555545c50c7p-5;\n+static const double C2 = -0x1.6c16b348b6874p-10;\n+static const double C3 = 0x1.a00eb9ac43ccp-16;\n+static const double C4 = -0x1.23c97dd8844d7p-22;\n \n-\tGET_FLOAT_WORD(ix,x);\n+/* Chebyshev constants for sin, range -PI/4 - PI/4. */\n+static const double S0 = -0x1.5555555551cd9p-3;\n+static const double S1 = 0x1.1111110c2688bp-7;\n+static const double S2 = -0x1.a019f8b4bd1f9p-13;\n+static const double S3 = 0x1.71d7264e6b5b4p-19;\n+static const double S4 = -0x1.a947e1674b58ap-26;\n \n- /* |x| ~< pi/4 */\n-\tix &= 0x7fffffff;\n-\tif(ix <= 0x3f490fd8) return __kernel_sinf(x,z,0);\n+/* Chebyshev constants for sin, range 2^-27 - 2^-5. */\n+static const double SS0 = -0x1.555555543d49dp-3;\n+static const double SS1 = 0x1.110f475cec8c5p-7;\n \n- /* sin(Inf or NaN) is NaN */\n-\telse if (ix>=0x7f800000) {\n-\t if (ix == 0x7f800000)\n-\t __set_errno (EDOM);\n-\t return x-x;\n-\t}\n+/* PI/2 with 98 bits of accuracy. */\n+static const double PI_2_hi = -0x1.921fb544p+0;\n+static const double PI_2_lo = -0x1.0b4611a626332p-34;\n+\n+static const double SMALL = 0x1p-50; /* 2^-50. */\n+static const double inv_PI_4 = 0x1.45f306dc9c883p+0; /* 4/PI. */\n+\n+#define FLOAT_EXPONENT_SHIFT 23\n+#define FLOAT_EXPONENT_BIAS 127\n+\n+static const double pio2_table[] = {\n+ 0 * M_PI_2,\n+ 1 * M_PI_2,\n+ 2 * M_PI_2,\n+ 3 * M_PI_2,\n+ 4 * M_PI_2\n+};\n+\n+static const double invpio4_table[] = {\n+ 0x0p+0,\n+ 0x1.45f306cp+0,\n+ 0x1.c9c882ap-28,\n+ 0x1.4fe13a8p-58,\n+ 0x1.f47d4dp-85,\n+ 0x1.bb81b6cp-112,\n+ 0x1.4acc9ep-142,\n+ 0x1.0e4107cp-169\n+};\n+\n+static const int ones[] = { +1, -1 };\n+\n+/* reduced (theta, n, signbit):\n+ * Compute sine (n * theta) using Chebyshev polynomials, where\n+ * - -Pi/4 <= theta < Pi/4\n+ * - n thus indicates the actual quadrant in which n*theta resides.\n+ * n is used to decide whether a sine or cosine approximation is\n+ * more accurate and the sign of the result. */\n \n- /* argument reduction needed */\n-\telse {\n-\t n = __ieee754_rem_pio2f(x,y);\n-\t switch(n&3) {\n-\t\tcase 0: return __kernel_sinf(y[0],y[1],1);\n-\t\tcase 1: return __kernel_cosf(y[0],y[1]);\n-\t\tcase 2: return -__kernel_sinf(y[0],y[1],1);\n-\t\tdefault:\n-\t\t\treturn -__kernel_cosf(y[0],y[1]);\n+static inline float\n+reduced (const double theta, const unsigned long n,\n+\t const unsigned long signbit)\n+{\n+ double sx;\n+ const double theta2 = theta * theta;\n+ /* We are operating on |x|, so we need to add back the original\n+ * signbit for sinf. */\n+ int sign;\n+ sign = ones[((n >> 2) & 1) ^ signbit];\n+ theta2 = theta * theta;\n+ /* Chebyshev polynomial of the form for sin:\n+ * x+x^3*(S0+x^2*(S1+x^2*(S2+x^2*(S3+x^2*S4)))).\n+ * 1.0+x^2*(C0+x^2*(C1+x^2*(C2+x^2*(C3+x^2*C4)))). */\n+ if ((n & 2) == 0)\n+ {\n+ sx = S3 + theta2 * S4; /* S3+x^2*S4. */\n+ sx = S2 + theta2 * sx; /* S2+x^2*(S3+x^2*S4). */\n+ sx = S1 + theta2 * sx; /* S1+x^2*(S2+x^2*(S3+x^2*S4)). */\n+ sx = S0 + theta2 * sx; /* S0+x^2*(S1+x^2*(S2+x^2*(S3+x^2*S4))). */\n+ /* x+x^3*(S0+x^2*(S1+x^2*(S2+x^2*(S3+x^2*S4)))). */\n+ sx = theta + theta * theta2 * sx;\n+ }\n+ else\n+ {\n+ sx = C3 + theta2 * C4; /* C3+x^2*C4. */\n+ sx = C2 + theta2 * sx; /* C2+x^2*(C3+x^2*C4). */\n+ sx = C1 + theta2 * sx; /* C1+x^2*(C2+x^2*(C3+x^2*C4)). */\n+ sx = C0 + theta2 * sx; /* C0+x^2*(C1+x^2*(C2+x^2*(C3+x^2*C4))). */\n+ /* 1.0 + x^2*(C0+x^2*(C1+x^2*(C2+x^2*(C3+x^2*C4)))). */\n+ sx = 1.0 + theta2 * sx;\n+ }\n+\n+ /* Add in the signbit and assign the result. */\n+ return sign * sx;\n+}\n+\n+float\n+SINF_FUNC (float x)\n+{\n+ double cx;\n+ double theta = x;\n+ double abstheta = fabs (theta);\n+ /* if |x|< Pi/4. */\n+ if (abstheta < M_PI_4)\n+ {\n+ if (abstheta >= 0x1p-5) /* |x| >= 2^-5. */\n+\t{\n+\t const double theta2 = theta * theta;\n+\t /* Chebyshev polynomial of the form for sin\n+\t * x+x^3*(S0+x^2*(S1+x^2*(S2+x^2*(S3+x^2*S4)))). */\n+\t cx = S3 + theta2 * S4;\n+\t cx = S2 + theta2 * cx;\n+\t cx = S1 + theta2 * cx;\n+\t cx = S0 + theta2 * cx;\n+\t cx = theta + theta * theta2 * cx;\n+\t return cx;\n+\t}\n+ else if (abstheta >= 0x1p-27) /* |x| >= 2^-27. */\n+\t{\n+\t /* A simpler Chebyshev approximation is close enough for this range:\n+\t * for sin: x+x^3*(SS0+x^2*SS1). */\n+\t const double theta2 = theta * theta;\n+\t cx = SS0 + theta2 * SS1;\n+\t cx = theta + theta * theta2 * cx;\n+\t return cx;\n+\t}\n+ else\n+\t{\n+\t /* Handle some special cases. */\n+\t if (theta)\n+\t return theta - (theta * SMALL);\n+\t else\n+\t return theta;\n+\t}\n+ }\n+ else /* |x| >= Pi/4. */\n+ {\n+ unsigned long signbit = (x < 0);\n+ if (abstheta < 9 * M_PI_4) /* |x| < 9*Pi/4. */\n+\t{\n+\t unsigned long n = (abstheta * inv_PI_4) + 1;\n+\t theta = abstheta - pio2_table[n / 2];\n+\t return reduced (theta, n, signbit);\n+\t}\n+ else if (abstheta < INFINITY)\n+\t{\n+\t if (abstheta < 0x1p+23) /* |x| < 2^23. */\n+\t {\n+\t unsigned long n = floor (abstheta * inv_PI_4) + 1.0;\n+\t double x = floor (n / 2.0);\n+\t theta = x * PI_2_lo + (x * PI_2_hi + abstheta);\n+\t /* Argument reduction needed. */\n+\t return reduced (theta, n, signbit);\n+\t }\n+\t else /* |x| >= 2^23. */\n+\t {\n+\t x = fabs (x);\n+\t int exponent;\n+\t GET_FLOAT_WORD (exponent, x);\n+\t exponent =\n+\t (exponent >> FLOAT_EXPONENT_SHIFT) - FLOAT_EXPONENT_BIAS;\n+\t exponent += 3;\n+\t exponent = (exponent * (0x100000000 / 28 + 1)) >> 32;\n+\t double a = invpio4_table[exponent] * x;\n+\t double b = invpio4_table[exponent + 1] * x;\n+\t double c = invpio4_table[exponent + 2] * x;\n+\t double d = invpio4_table[exponent + 3] * x;\n+\t unsigned long l = a;\n+\t l &= ~0x7;\n+\t a -= l;\n+\t double e = a + b;\n+\t l = e;\n+\t e = a - l;\n+\t if (l & 1)\n+\t {\n+\t e -= 1.0;\n+\t e += b;\n+\t e += c;\n+\t e += d;\n+\t e *= M_PI_4;\n+\t return reduced (e, l + 1, signbit);\n+\t }\n+\t else\n+\t {\n+\t e += b;\n+\t e += c;\n+\t e += d;\n+\t if (e <= 1.0)\n+\t {\n+\t e *= M_PI_4;\n+\t return reduced (e, l + 1, signbit);\n+\t }\n+\t else\n+\t {\n+\t l++;\n+\t e -= 2.0;\n+\t e *= M_PI_4;\n+\t return reduced (e, l + 1, signbit);\n+\t }\n+\t }\n \t }\n \t}\n+ else\n+\t{\n+\t int32_t ix;\n+\t /* High word of x. */\n+\t GET_FLOAT_WORD (ix, abstheta);\n+\t /* sin(Inf or NaN) is NaN. */\n+\t if (ix == 0x7f800000)\n+\t __set_errno (EDOM);\n+\t return x - x;\n+\t}\n+ }\n }\n \n #ifndef SINF\n", "prefixes": [ "PATCHv3" ] }