From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2087.outbound.protection.outlook.com [40.107.6.87]) by sourceware.org (Postfix) with ESMTPS id 8DE263858D35 for ; Thu, 3 Aug 2023 15:22:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8DE263858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TnzNbwoK/pBVEdKXscMUTQ7/pwpTBd/5aQksTSVYMp0=; b=JY590Ws6rBhR5skyn8TIgAVQfDEbPRmWORXXk3KaBccPnhCC6TvkrD7CUcvp/FJ/QIaz+m1Z1I5ceAZcduHpKyN1j270XB2L4RyaGs8c1f3TIB8Tf/oxmeK4DbrNMBd61qQYCcyBYLL26AXyKX68uF53ye1vLWWZPKj9GSMtkR8= Received: from AS9PR06CA0254.eurprd06.prod.outlook.com (2603:10a6:20b:45f::29) by AS8PR08MB6647.eurprd08.prod.outlook.com (2603:10a6:20b:38e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Thu, 3 Aug 2023 15:22:41 +0000 Received: from AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45f:cafe::ea) by AS9PR06CA0254.outlook.office365.com (2603:10a6:20b:45f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.20 via Frontend Transport; Thu, 3 Aug 2023 15:22:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT036.mail.protection.outlook.com (100.127.140.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.48 via Frontend Transport; Thu, 3 Aug 2023 15:22:41 +0000 Received: ("Tessian outbound 997ae1cc9f47:v145"); Thu, 03 Aug 2023 15:22:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 644153cd82177e1a X-CR-MTA-TID: 64aa7808 Received: from ce566b2a6fae.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D0F8995D-A2BA-4F46-8FE4-6CA9650BBC47.1; Thu, 03 Aug 2023 15:22:34 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ce566b2a6fae.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Aug 2023 15:22:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X4a84a0JlJlvuuBnt/gUX8doiqp2486vh70gi4SFVKaUZspfliptMCukAsKWLSdHFXUWE1qVoFl5AHyteThe51qU+nm3utE1NWxn4EbJaETr0lnRhqHx40uSQBGkhAO9AMqpYFSVkdn6+ss1QHAhh4PFF56XOHsKM1NFPNziofTB4gXhppvE7WYUN5RdmvS28MzRhBA1FVqI1wG2SU/OivfvBHRvyYCoFsUWbDr4aSU2p/X3Z1gPRJIPfmAnvfqSEif2867vkEWJJJYJQhiJfMSjZSNiiwrkTILOyJS+TYsGgP7RiRCxN4FAN7up4jQkvKkeyoFKXdWWVLygTyPaOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TnzNbwoK/pBVEdKXscMUTQ7/pwpTBd/5aQksTSVYMp0=; b=Y6Fhw/Ooj7yj5ubc+C2npUVuXDv6bdfDMgIiUbzHxCrvIz9m6XliS50DZfcXyuIAarqx8zyqLXD6SlbnwX2JtfxYKU7kfUGkPjCliWKPCYFYRwLSzB+tbaDvwMy2cS4pZh+Pj7+rgx8jrVRiBCkbcEE8Ok2gZqDO9tRQaANOlbIaxuqn/0oKcDF/0bowj49YF7zCJyuD8ZF4rLzbaba0hTjRrHt9Xh1nvrqcAqTIk98eH/JVcOTv4b1NK6w5bdxEHFpMKNdDKisfD75ZeKtlqgGnnH0LuKoCzY/1zPtIdNY1I48qQV8l8bVuKKxzMWEagYVsFYWFECr3ubpd6Yk02Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TnzNbwoK/pBVEdKXscMUTQ7/pwpTBd/5aQksTSVYMp0=; b=JY590Ws6rBhR5skyn8TIgAVQfDEbPRmWORXXk3KaBccPnhCC6TvkrD7CUcvp/FJ/QIaz+m1Z1I5ceAZcduHpKyN1j270XB2L4RyaGs8c1f3TIB8Tf/oxmeK4DbrNMBd61qQYCcyBYLL26AXyKX68uF53ye1vLWWZPKj9GSMtkR8= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by AM9PR08MB6066.eurprd08.prod.outlook.com (2603:10a6:20b:2d8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Thu, 3 Aug 2023 15:22:32 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::adb0:61cb:8733:6db2]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::adb0:61cb:8733:6db2%7]) with mapi id 15.20.6631.046; Thu, 3 Aug 2023 15:22:32 +0000 Date: Thu, 3 Aug 2023 16:22:18 +0100 From: Szabolcs Nagy To: Wilco Dijkstra , paul zimmermann Cc: 'GNU C Library' , Joe Ramsay Subject: Re: [PATCH] aarch64: Improve SVE sin polynomial Message-ID: References: Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: LO4P123CA0461.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1aa::16) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB7179:EE_|AM9PR08MB6066:EE_|AM7EUR03FT036:EE_|AS8PR08MB6647:EE_ X-MS-Office365-Filtering-Correlation-Id: d749e01d-0f8a-4ad0-0965-08db94357aad x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: UdTzFhRe20acyHoDzB/RIem40ZIHNgFArd4oxQ55xYdg0goNcBWiPay/JSTFgw6k0R5t5enaQj+3xp+5GMPtC1mzMGQQjxgy+ZuWspGAngS/K813lJVv42tlnjr7WG2dgLPvQFIpnlCj9c7mjc2kuU2Q0UWaDwLo1TofixTxO0q2RgErNWZS8MIdSjN6kNFtEzUjlLMkodCTV88jDZgcRBparOKnst/YOlis72kWvy10SNTqobxKk4lOk8ulyGwU219JKn1NFfxvlpinVa/MUAlamWaMKIIWGd6xlx6H0/kLtNfCgmvfo5X4sgMdE4ABTfMSaJTgjLENs6x4Wk7eYtaV4FqbYxVvop/pzz3ku+KY76GMOh5SJ+Ejd95PTcEriBeNT3gStLVDngusvjvD/eoF1UhrmtCPyFV5TmHE+58+nz9hLym64gL0ernpQ+0vxKtEKwU1JW82No81NzM6HadCGkFQGpPJMSQiAcUt7OArJXtHapGDqMCYblRqoDLUHlesJ+iTnycmXFQkbZHsX7vVnGKJrIbvw7LtCtbdldk= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB7179.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(376002)(136003)(396003)(346002)(39860400002)(451199021)(2616005)(83380400001)(6506007)(41300700001)(26005)(186003)(8676002)(8936002)(66556008)(2906002)(4326008)(66946007)(5660300002)(316002)(66476007)(6666004)(6486002)(6512007)(478600001)(54906003)(110136005)(38100700002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6066 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: bb0a2f37-2e24-47c4-14df-08db943574e4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Byl5AYfAKKjBPsBHCG0kCM6seQjIlU7j/qHvmWQlEifmeYfm8LGQA21e3G+JEqJJvhqjJZFyNU1Q/QUCpKX+UZQCudy0H94GlCfa3KJ4UX88R86HjqjSneM8uPDnUeB9NzXXsDJdVKnDfOlhq4W527P5yu2hZUQwb1WFTJn/+UuNyvmiDJvduHpxK+whANLwcTW+juUAxHmcx3N1ar5J2MMqXi3W8elirdpCoXCWCxXvX4MzHSHTI/DIYRuroI63V4wf8yeSaV6Vwmo6XJtpxAvCRcstAa5nqxuTbKwrkhLLO7MuF9CAhSVvhWl+eJDQhDR3tFhcXW0V0UuZAzTWMCrYRucqF1yB6jmIsNc3kgFjfIrUmiwaBigK6thcJ5yD4vHyTkiNkgq6lk4dwRRbHx2WwG33dBJ49WINtzOc1j8PX2LWyL1EbiYM0RliwNIBMjbxfOVv4RDvBhXPljO7mUyNgv00pu/c5fX7vHxA/vJaAUL3+gBsASjl8R2KMJS0rzJ/9Jbhopz5DaoSWydpAwb7vGaN2NgyJraJd0crxwIt6WFZfb4/0DUmoBcdfsnnLN6HJe07IOPj6bjLgNCS+ZQOYuFIUuWP5L/J86wwd+uv9fO+V7dDr8UY5dsNxpE0a4LZCh8MpzCgz6JKBhsqRysBzHPZiftAxY1rLYC9yJaqK1ZXBqlsWuAox+A3YOkp5UIX4NGAokEPtax6vmu41UeNQ6wQ+i+SB0PotzPkqx4= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(136003)(376002)(396003)(451199021)(82310400008)(40470700004)(46966006)(36840700001)(40460700003)(2616005)(336012)(83380400001)(6506007)(26005)(186003)(47076005)(41300700001)(8936002)(2906002)(4326008)(70206006)(70586007)(5660300002)(316002)(8676002)(6666004)(6486002)(6512007)(36860700001)(478600001)(54906003)(110136005)(40480700001)(356005)(81166007)(86362001)(36756003)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2023 15:22:41.4926 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d749e01d-0f8a-4ad0-0965-08db94357aad X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6647 X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The 08/03/2023 15:21, Wilco Dijkstra wrote: > Hi Paul, > > > you can still improve the polynomial with the following one generated by > > Sollya (https://www.sollya.org/) with relative error < 2^-52.454 on > > [-pi/2, pi/2], instead of 2^-51.765 for the one you propose: > > So the goal is to reduce the ULP error. Due to the way floating point works, > errors are at their worst when the result is just above a power of 2. For the > wide sin(x) polynomial it happens when sin(x) is close to but larger than 0.5. > The poly is extremely accurate for small x. It's only problematic when x is large > and we cross an exponent boundary. > > Szabolcs can explain it better but what we ended up doing is to scale the > sollya function so that errors at the end of the range are and reduced more. i'd say we want to minimize the maximum of (poly(x) - sin(x))/ulp(sin(x)) instead of (poly(x) - sin(x))/sin(x) since ulp(x) is flat between 0.5 and 1 this can make a big difference when designing a sin poly for -pi/2,pi/2. e.g. you want to look at the abs error on [pi/6,pi/2], not relative error when comparing the polynomials. this is if you only consider approximation errors, but there is an independent effect of large rounding errors where operations in x + c*x*x*x cross powof2 boundaries which is also near x = pi/2. so for weighting func i used a polynomial that roughly approximates ulp(sin(x)) but forces smaller approx error where i expect big rounding error (this part was a bit of black magic but i think the approx error part is sound and covers most of the quality gain). > > Note also this is not the final polynomial. The ULP is a bit high at 3.3. I had a > more accurate one close to 2ULP but it could give results >1.0. So we need to > teach sollya to estimate the end from below, and not allow it to overshoot. we originally planned to use a poly with one more term, but that made errors go in the wrong direction at x=pi/2, and it could return 1.0 + 0x1p-52 which is not good for sin(x). i could not fix this with weighting, but reducing the degree the error goes into the other direction so even though the error is bigger then it's probably better in practice. hope this helps.