public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: bule <bule1@huawei.com>
To: Richard Sandiford <richard.sandiford@arm.com>
Cc: "Yangfei (Felix)" <felix.yang@huawei.com>,
	Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	gcc-help <gcc-help@gcc.gnu.org>
Subject: re: re: [AArch64][Spec2017]Question about mlow-precision-div optimization.
Date: Thu, 12 Mar 2020 12:22:49 +0000	[thread overview]
Message-ID: <8FB10B4CA53A144E918874949D50CEB10228DBF6@dggeml528-mbx.china.huawei.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1393 bytes --]

Hi,

> Could you try doing a bootstrap with that change and seeing if it still works for your use case?  If so, could you post the final patch?

The bootstrap test and regression dejagnu test has been done on an aarch64 Linux platform for the patch attached.
The regression test for gcc will have 4 extra expected passes automatically due to the newly added 2 parameters. No new regression witnessed.
Newly added test cases are: 
	PASS: gcc.dg/params/blocksort-part.c -O3 --param aarch64-double-recp-precision=1 (test for excess errors)
	PASS: gcc.dg/params/blocksort-part.c -O3 --param aarch64-double-recp-precision=5 (test for excess errors)
	PASS: gcc.dg/params/blocksort-part.c -O3 --param aarch64-float-recp-precision=1 (test for excess errors)
	PASS: gcc.dg/params/blocksort-part.c -O3 --param aarch64-float-recp-precision=5 (test for excess errors)

gcc/config/aarch64/:
+2020-03-12  Bu Le  <bule1@huawei.com>
+
+       PR target/94154
+       * aarch64.c (aarch64_emit_approx_div): Add new parameters
+         Add two parameters to control the precision of the reciprocal division.
+
+       * aarch64.opt : Declare new parameters.     

gcc/doc:
+2020-03-12  Bu Le  <bule1@huawei.com>
+
+       PR target/94154
+       * invoke.texi: New parameters added for reciprocal division precision.
+

please help commit this if it's OK to go

Thanks,
Bu Le


[-- Attachment #2: div-param2.patch --]
[-- Type: application/octet-stream, Size: 3167 bytes --]

diff -Nurp a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
--- a/gcc/config/aarch64/aarch64.c	2020-03-08 18:00:34.581798076 +0800
+++ b/gcc/config/aarch64/aarch64.c	2020-03-10 11:06:58.946181675 +0800
@@ -12854,10 +12854,12 @@ aarch64_emit_approx_div (rtx quo, rtx nu
   /* Iterate over the series twice for SF and thrice for DF.  */
   int iterations = (GET_MODE_INNER (mode) == DFmode) ? 3 : 2;
 
-  /* Optionally iterate over the series once less for faster performance,
-     while sacrificing the accuracy.  */
+  /* Optionally iterate over the series less for faster performance,
+     while sacrificing the accuracy.  The default is 2 for DF and 1 for SF.  */
   if (flag_mlow_precision_div)
-    iterations--;
+    iterations = (GET_MODE_INNER (mode) == DFmode)
+				   ? aarch64_double_recp_precision
+				   : aarch64_float_recp_precision;
 
   /* Iterate over the series to calculate the approximate reciprocal.  */
   rtx xtmp = gen_reg_rtx (mode);
diff -Nurp a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
--- a/gcc/config/aarch64/aarch64.opt	2020-03-08 18:00:34.589802076 +0800
+++ b/gcc/config/aarch64/aarch64.opt	2020-03-08 17:52:37.556515481 +0800
@@ -262,3 +262,12 @@ Generate local calls to out-of-line atom
 -param=aarch64-sve-compare-costs=
 Target Joined UInteger Var(aarch64_sve_compare_costs) Init(1) IntegerRange(0, 1) Param
 When vectorizing for SVE, consider using unpacked vectors for smaller elements and use the cost model to pick the cheapest approach.  Also use the cost model to choose between SVE and Advanced SIMD vectorization.
+
+-param=aarch64-float-recp-precision=
+Target Joined UInteger Var(aarch64_float_recp_precision) Init(1) IntegerRange(1, 5) Param
+The number of Newton iterations for calculating the reciprocal for float type.  The precision of division is propotional to this param when division approximation is enabled.  The default value is 1.
+
+-param=aarch64-double-recp-precision=
+Target Joined UInteger Var(aarch64_double_recp_precision) Init(2) IntegerRange(1, 5) Param
+The number of Newton iterations for calculating the reciprocal for double type.  The precision of division is proportional to this param when division approximation is enabled.  The default value is 2.
+
diff -Nurp a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
--- a/gcc/doc/invoke.texi	2020-03-08 18:00:32.216616076 +0800
+++ b/gcc/doc/invoke.texi	2020-03-10 11:49:55.366032646 +0800
@@ -13095,6 +13095,19 @@ Also use the cost model to choose betwee
 Using unpacked vectors includes storing smaller elements in larger
 containers and accessing elements with extending loads and truncating
 stores.
+
+@item aarch64-float-recp-precision
+The number of Newton iterations for calculating the reciprocal for float type.
+The precision of division is propotional to this param
+when divisionapproximation is enabled.
+The default value is 1.
+
+@item aarch64-float-recp-precision
+The number of Newton iterations for calculating the reciprocal for double type.
+The precision of division is propotional to this param
+when divisionapproximation is enabled.
+The default value is 2.
+
 @end table
 
 @end table

             reply	other threads:[~2020-03-12 12:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 12:22 bule [this message]
2020-03-13  9:30 ` Richard Sandiford
  -- strict thread matches above, loose matches on Subject: below --
2020-03-13 10:06 bule
2020-03-09  1:48 bule
2020-03-09 12:28 ` Richard Sandiford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8FB10B4CA53A144E918874949D50CEB10228DBF6@dggeml528-mbx.china.huawei.com \
    --to=bule1@huawei.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=felix.yang@huawei.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=richard.sandiford@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).