From patchwork Fri Sep 9 12:20:11 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Patchwork-Submitter: Tobias Burnus
X-Patchwork-Id: 1116
Return-Path:
Delivered-To: ouuuleilei@gmail.com
Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp687612wrt;
Fri, 9 Sep 2022 05:20:56 -0700 (PDT)
X-Google-Smtp-Source:
AA6agR6PykAyZE/12vImPH/FlKDS8m4a7RQDnf6ErGt+GHjicjT9YrJAV65u0/htdHoiVGgLs6+m
X-Received: by 2002:a17:907:1612:b0:770:86e3:2f1f with SMTP id
hb18-20020a170907161200b0077086e32f1fmr8665408ejc.403.1662726056511;
Fri, 09 Sep 2022 05:20:56 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1662726056; cv=none;
d=google.com; s=arc-20160816;
b=F2e6n2VDEFcjsu4+kcGmnyWOscRJM2slufaQ3t9QbhDDpZMsw7Czxp7RUm5gElpIYj
j8ooTxRizYgQScgDKIo2vkg3QkiDGjS9ynceR/+IOn9V9KEZp3tbSizunh9o+7fMP6Cl
+ZkeK7x1eEp+H+juIn3v3ZcNI2ID9n5MnDO3sf9uhN0yM8VnsrXuANLo8XJniINVYYqB
uSEpHWHklP1eUTnXwEICr++829EeeqGsTC14nHGJlR04lbbpDU/wU+3OuZgH3Pn4om94
dzL1brA8EuzQyaRsr4T7FJKv0BT5SBBlawGb//0lLEAD75df50XYPtHJaqTBkJnFAHh2
AIWg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20160816;
h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive
:list-unsubscribe:list-id:precedence:in-reply-to:from:references:to
:content-language:subject:user-agent:mime-version:date:message-id
:ironport-sdr:dmarc-filter:delivered-to;
bh=e3Z2IT4oKylLoh6vOaU5iZRKZv1cl/M+ybsAKHira6U=;
b=IvMu93qvNNEbcsfqLbLGVcLgoLVfO7i+vTGhuBtVbIhs/9jYo5giH47jiCT21T4ybB
rY9HZuEuwcTMrciWw5Ifl3EoqqyqVpiF2Aq9jTQG1246Xcii4kNMggK7mg0gQ4pmx/BB
uoXuL5IIRuNLerf998nYu+v+g7pRJQvV2bxzJVp6aEL0jX3f+AV02NhwxUyC0Rf38CAp
qrVFKUsy+HNKsCtCW9leFD6Zr7O/3VpbVS0TTO/Qt298Uec5oPLE4XR1sGNfEy0LFLQ6
kxvq+kMBCL/n2z32ljEKPf3rGD+3CyjkiqV4WOwvfkg7x83eb45TVQdItkIjAPvbyGKp
JHMQ==
ARC-Authentication-Results: i=1; mx.google.com;
spf=pass (google.com: domain of
gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates
2620:52:3:1:0:246e:9693:128c as permitted sender)
smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"
Received: from sourceware.org (server2.sourceware.org.
[2620:52:3:1:0:246e:9693:128c])
by mx.google.com with ESMTPS id
dd3-20020a1709069b8300b0073c14b6560bsi387139ejc.177.2022.09.09.05.20.56
for
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 09 Sep 2022 05:20:56 -0700 (PDT)
Received-SPF: pass (google.com: domain of
gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates
2620:52:3:1:0:246e:9693:128c as permitted sender)
client-ip=2620:52:3:1:0:246e:9693:128c;
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of
gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates
2620:52:3:1:0:246e:9693:128c as permitted sender)
smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"
Received: from server2.sourceware.org (localhost [IPv6:::1])
by sourceware.org (Postfix) with ESMTP id 06ED0385701B
for ; Fri, 9 Sep 2022 12:20:53 +0000 (GMT)
X-Original-To: gcc-patches@gcc.gnu.org
Delivered-To: gcc-patches@gcc.gnu.org
Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252])
by sourceware.org (Postfix) with ESMTPS id 08E2B38582BF
for ; Fri, 9 Sep 2022 12:20:26 +0000 (GMT)
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 08E2B38582BF
Authentication-Results: sourceware.org; dmarc=none (p=none dis=none)
header.from=codesourcery.com
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com
X-IronPort-AV: E=Sophos;i="5.93,303,1654588800";
d="diff'?scan'208";a="82715123"
Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167])
by esa4.mentor.iphmx.com with ESMTP; 09 Sep 2022 04:20:19 -0800
IronPort-SDR:
62tu7zWTgka5uvV4piMKs0Gk5fFK2fMgralgYWFxgpxUq+OWvHb3Dqnvd6t2mlk+5fyb5zk92k
SGsuCZw54CvENtihziDQh4UG7++QyA/VO4FgZSak+kqMJhjwysylAQeZWGlDgeuIOJzSkwLGpB
uShCAZOAEvPWus7hm0oGMLxXFHImp30ALrZrHorFqmHZEAIWdP/GO7NkFiz81/UfgzPvmf6R3q
qp44oS/uoEssr1MYptdTMaJ46DCo+NFoKr70PfQVC+YeusMER/oqQI+QqZyDNjkpye7047G95m
XWI=
Message-ID: <5d7ca95c-8a61-6d07-dd5b-e7c2d03072ff@codesourcery.com>
Date: Fri, 9 Sep 2022 14:20:11 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.2.1
Subject: GCN: Add -mlow-precision-sqrt for double-precision sqrt [PR105246]
(was: Re: [PATCH] amdgcn: Add support for additional natively supported
floating-point operations)
Content-Language: en-US
To: Andrew Stubbs
References:
<08966068-719a-30d1-5b71-7cf839e507e7@codesourcery.com>
From: Tobias Burnus
In-Reply-To:
X-Originating-IP: [137.202.0.90]
X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To
svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12)
X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0,
HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS,
SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: gcc-patches@gcc.gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Gcc-patches mailing list
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Cc: Richard Biener ,
Kwok Cheung Yeung ,
gcc-patches
Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org
Sender: "Gcc-patches"
X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?=
X-GMAIL-THRID: =?utf-8?q?1743494637439402197?=
X-GMAIL-MSGID: =?utf-8?q?1743494637439402197?=
On 09.09.22 12:16, Richard Biener wrote:
> On Fri, 9 Sep 2022, Tobias Burnus wrote:
>> -funsafe-math-optimizations implies -fno-signed-zeros, -fno-trapping-math,
>> -fassociative-math,
>> and -freciprocal-math. All of them reduce precision and my violate IEEE or
>> ISO/language standards.
>>
>> However, I think it is rather surprising to have all of the sudden only a
>> precision of the order of 100,000,000 ULP instead of ~4 ULP as to be expected.
>> That's a precision loss of the order of 10^8 or 2^29 which is huge!
>> ...
> I agree - for example powerpc has -mrecip= to control which instructions
> to use (float/double rsqrt or inverse) and -mrecip-precision to
> specify whether further iteration is done or not.
> [...]
> Your suggested huge reduction in precision isn't usually acceptable
> and should be always explicitely enabled.
First, I have to correct myself – Kwok's -munsafe-math-optimizations is
only about single-precision functions, which do not have this problem.
However, the pre-existing 'sqrt' problem still is real. It also applies
to reverse sqrt ("v_rsq"), but that's for whatever reason not used for GCN.
This patch now adds a commandline flag - off by default - to choose
whether this behavior is wanted. I did use the same name as aarch64,
https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-mlow-precision-sqrt
(the latter also has -mlow-precision-recip-sqrt, which is not (yet)
sensible for GCN.)
This patch was manually tested for all combinations and I also looked at
insn-recog.cc, given that it is my first .md patch – it it seems to work
fine.
OK for mainline – or are there comments or more suggestions? I also
included some word for the release notes.
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
gcc-13/changes.html - GCN: document -mlow-precision-sqrt
diff --git a/htdocs/gcc-13/changes.html b/htdocs/gcc-13/changes.html
index 390193ca..d335eab3 100644
--- a/htdocs/gcc-13/changes.html
+++ b/htdocs/gcc-13/changes.html
@@ -179,6 +179,12 @@ a work-in-progress.
Support for the Instinct MI200 series devices (
gfx90a
) has been added.
+ The -mlow-precision-sqrt
option (disabled by default)
+ has been added to use the hardware sqrt
also for
+ double-precision floating point arguments; note that the result
+ only has much a reduced accurary of 229 ULP. This
+ option requires -funsafe-math-optimizations
+ (implied by -ffast-math
) in addition.