public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Bin.Cheng" <amker.cheng@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH GCC][06/13]Preserve loop nest in whole distribution life time
Date: Mon, 19 Jun 2017 13:32:00 -0000	[thread overview]
Message-ID: <CAHFci2_-vw_eojObJiinuk_UvTGAPN6q5cP1rjt7Si++=74Hmg@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc2d_Azow+f80_os+P3_DQ+g8jYbwa7mAyw_OfNhHDtw2g@mail.gmail.com>

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

On Tue, Jun 13, 2017 at 12:08 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Tue, Jun 13, 2017 at 1:06 PM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Mon, Jun 12, 2017 at 7:02 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
>>> Hi,
>>> This simple patch computes and preserves loop nest vector for whole distribution
>>> life time.  The loop nest will be used multiple times in on-demand data dependence
>>> computation.
>>>
>>> Bootstrap and test on x86_64 and AArch64.  Is it OK?
>>
>> Don't like it too much but I guess we can see if refactoring it back
>> to pass down
>> loop_nest can work.
>>
>> Ok.
>
> Oh.
>
> +/* The loop (nest) to be distributed.  */
> +static vec<loop_p> *loop_nest;
> +
>
> please make it
>
> static vec<loop_p> loop_nest;
>
> instead to avoid a pointless indirection (vec<> just contains a
> pointer to allocated storage).
Hi Richard,
This is the updated patch according to your comment, is it OK?

Thanks,
bin

2017-06-17  Bin Cheng  <bin.cheng@arm.com>

    * tree-loop-distribution.c (loop_nest): New global var.
    (build_rdg): Use loop directly, rather than loop nest.
    (pg_add_dependence_edges): Remove loop nest parameter.  Use global
    variable directly.
    (distribute_loop): Compute global variable loop nest.  Update use.

[-- Attachment #2: 0005-loop-nest-20170609.txt.patch --]
[-- Type: text/x-patch, Size: 4611 bytes --]

From 6acd21a433606955b756ada75a33f3f61e2e0b6c Mon Sep 17 00:00:00 2001
From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com>
Date: Fri, 9 Jun 2017 11:56:28 +0100
Subject: [PATCH 05/13] loop-nest-20170609.txt

---
 gcc/tree-loop-distribution.c | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index f409e94..8183090 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -66,6 +66,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-vectorizer.h"
 
 
+/* The loop (nest) to be distributed.  */
+static vec<loop_p> loop_nest;
+
 /* A Reduced Dependence Graph (RDG) vertex representing a statement.  */
 struct rdg_vertex
 {
@@ -454,22 +457,22 @@ free_rdg (struct graph *rdg)
   free_graph (rdg);
 }
 
-/* Build the Reduced Dependence Graph (RDG) with one vertex per
-   statement of the loop nest LOOP_NEST, and one edge per data dependence or
-   scalar dependence.  */
+/* Build the Reduced Dependence Graph (RDG) with one vertex per statement of
+   LOOP, and one edge per flow dependence or control dependence from control
+   dependence CD.  */
 
 static struct graph *
-build_rdg (vec<loop_p> loop_nest, control_dependences *cd)
+build_rdg (struct loop *loop, control_dependences *cd)
 {
   struct graph *rdg;
   vec<data_reference_p> datarefs;
 
   /* Create the RDG vertices from the stmts of the loop nest.  */
   auto_vec<gimple *, 10> stmts;
-  stmts_from_loop (loop_nest[0], &stmts);
+  stmts_from_loop (loop, &stmts);
   rdg = new_graph (stmts.length ());
   datarefs.create (10);
-  if (!create_rdg_vertices (rdg, stmts, loop_nest[0], &datarefs))
+  if (!create_rdg_vertices (rdg, stmts, loop, &datarefs))
     {
       datarefs.release ();
       free_rdg (rdg);
@@ -479,7 +482,7 @@ build_rdg (vec<loop_p> loop_nest, control_dependences *cd)
 
   create_rdg_flow_edges (rdg);
   if (cd)
-    create_rdg_cd_edges (rdg, cd, loop_nest[0]);
+    create_rdg_cd_edges (rdg, cd, loop);
 
   datarefs.release ();
 
@@ -1418,7 +1421,7 @@ partition_contains_all_rw (struct graph *rdg,
    and DRS2 and modify and return DIR according to that.  */
 
 static int
-pg_add_dependence_edges (struct graph *rdg, vec<loop_p> loops, int dir,
+pg_add_dependence_edges (struct graph *rdg, int dir,
 			 vec<data_reference_p> drs1,
 			 vec<data_reference_p> drs2)
 {
@@ -1439,8 +1442,8 @@ pg_add_dependence_edges (struct graph *rdg, vec<loop_p> loops, int dir,
 	    std::swap (dr1, dr2);
 	    this_dir = -this_dir;
 	  }
-	ddr = initialize_data_dependence_relation (dr1, dr2, loops);
-	compute_affine_dependence (ddr, loops[0]);
+	ddr = initialize_data_dependence_relation (dr1, dr2, loop_nest);
+	compute_affine_dependence (ddr, loop_nest[0]);
 	if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
 	  this_dir = 2;
 	else if (DDR_ARE_DEPENDENT (ddr) == NULL_TREE)
@@ -1508,11 +1511,14 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
 
   *destroy_p = false;
   *nb_calls = 0;
-  auto_vec<loop_p, 3> loop_nest;
+  loop_nest.create (0);
   if (!find_loop_nest (loop, &loop_nest))
-    return 0;
+    {
+      loop_nest.release ();
+      return 0;
+    }
 
-  rdg = build_rdg (loop_nest, cd);
+  rdg = build_rdg (loop, cd);
   if (!rdg)
     {
       if (dump_file && (dump_flags & TDF_DETAILS))
@@ -1520,6 +1526,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
 		 "Loop %d not distributed: failed to build the RDG.\n",
 		 loop->num);
 
+      loop_nest.release ();
       return 0;
     }
 
@@ -1643,15 +1650,15 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
 	    /* dependence direction - 0 is no dependence, -1 is back,
 	       1 is forth, 2 is both (we can stop then, merging will occur).  */
 	    int dir = 0;
-	    dir = pg_add_dependence_edges (rdg, loop_nest, dir,
+	    dir = pg_add_dependence_edges (rdg, dir,
 					   PGDATA(i)->writes,
 					   PGDATA(j)->reads);
 	    if (dir != 2)
-	      dir = pg_add_dependence_edges (rdg, loop_nest, dir,
+	      dir = pg_add_dependence_edges (rdg, dir,
 					     PGDATA(i)->reads,
 					     PGDATA(j)->writes);
 	    if (dir != 2)
-	      dir = pg_add_dependence_edges (rdg, loop_nest, dir,
+	      dir = pg_add_dependence_edges (rdg, dir,
 					     PGDATA(i)->writes,
 					     PGDATA(j)->writes);
 	    if (dir == 1 || dir == 2)
@@ -1727,6 +1734,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
     }
 
  ldist_done:
+  loop_nest.release ();
 
   FOR_EACH_VEC_ELT (partitions, i, partition)
     partition_free (partition);
-- 
1.9.1


  reply	other threads:[~2017-06-19 13:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-12 17:03 Bin Cheng
2017-06-13 11:06 ` Richard Biener
2017-06-13 11:08   ` Richard Biener
2017-06-19 13:32     ` Bin.Cheng [this message]
2017-06-19 15:16       ` Richard Biener
2017-06-13 11:16   ` Bin.Cheng
2017-06-13 11:20     ` Richard Biener

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='CAHFci2_-vw_eojObJiinuk_UvTGAPN6q5cP1rjt7Si++=74Hmg@mail.gmail.com' \
    --to=amker.cheng@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.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).