* [PATCH GCC][06/13]Preserve loop nest in whole distribution life time
@ 2017-06-12 17:03 Bin Cheng
2017-06-13 11:06 ` Richard Biener
0 siblings, 1 reply; 7+ messages in thread
From: Bin Cheng @ 2017-06-12 17:03 UTC (permalink / raw)
To: gcc-patches; +Cc: nd
[-- Attachment #1: Type: text/plain, Size: 575 bytes --]
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?
Thanks,
bin
2017-06-07 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: 0006-loop-nest-20170607.txt --]
[-- Type: text/plain, Size: 4746 bytes --]
From ea3c198138036676334063226b6c1535e45dd4b2 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 06/14] loop-nest-20170607.txt
---
gcc/tree-loop-distribution.c | 45 +++++++++++++++++++++++++++-----------------
1 file changed, 28 insertions(+), 17 deletions(-)
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index ce6db66..e1f5bce 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 ();
@@ -1421,7 +1424,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)
{
@@ -1442,8 +1445,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)
@@ -1511,11 +1514,15 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
*destroy_p = false;
*nb_calls = 0;
- auto_vec<loop_p, 3> loop_nest;
- if (!find_loop_nest (loop, &loop_nest))
- return 0;
+ loop_nest = new vec<loop_p> ();
+ if (!find_loop_nest (loop, loop_nest))
+ {
+ loop_nest->release ();
+ delete loop_nest;
+ return 0;
+ }
- rdg = build_rdg (loop_nest, cd);
+ rdg = build_rdg (loop, cd);
if (!rdg)
{
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -1523,6 +1530,8 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
"Loop %d not distributed: failed to build the RDG.\n",
loop->num);
+ loop_nest->release ();
+ delete loop_nest;
return 0;
}
@@ -1646,15 +1655,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)
@@ -1730,6 +1739,8 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
}
ldist_done:
+ loop_nest->release ();
+ delete loop_nest;
FOR_EACH_VEC_ELT (partitions, i, partition)
partition_free (partition);
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH GCC][06/13]Preserve loop nest in whole distribution life time
2017-06-12 17:03 [PATCH GCC][06/13]Preserve loop nest in whole distribution life time Bin Cheng
@ 2017-06-13 11:06 ` Richard Biener
2017-06-13 11:08 ` Richard Biener
2017-06-13 11:16 ` Bin.Cheng
0 siblings, 2 replies; 7+ messages in thread
From: Richard Biener @ 2017-06-13 11:06 UTC (permalink / raw)
To: Bin Cheng; +Cc: gcc-patches, nd
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.
Thanks,
Richard.
> Thanks,
> bin
> 2017-06-07 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH GCC][06/13]Preserve loop nest in whole distribution life time
2017-06-13 11:06 ` Richard Biener
@ 2017-06-13 11:08 ` Richard Biener
2017-06-19 13:32 ` Bin.Cheng
2017-06-13 11:16 ` Bin.Cheng
1 sibling, 1 reply; 7+ messages in thread
From: Richard Biener @ 2017-06-13 11:08 UTC (permalink / raw)
To: Bin Cheng; +Cc: gcc-patches, nd
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).
Richard.
> Thanks,
> Richard.
>
>> Thanks,
>> bin
>> 2017-06-07 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH GCC][06/13]Preserve loop nest in whole distribution life time
2017-06-13 11:06 ` Richard Biener
2017-06-13 11:08 ` Richard Biener
@ 2017-06-13 11:16 ` Bin.Cheng
2017-06-13 11:20 ` Richard Biener
1 sibling, 1 reply; 7+ messages in thread
From: Bin.Cheng @ 2017-06-13 11:16 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
On Tue, Jun 13, 2017 at 12: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.
The global data is partly to avoid patch conflicts when separating
patches, otherwise several parameters are needed for quite number of
functions. We can introduce a global distribution data and only pass
it to various functions.
Thanks,
bin
>
> Ok.
>
> Thanks,
> Richard.
>
>> Thanks,
>> bin
>> 2017-06-07 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH GCC][06/13]Preserve loop nest in whole distribution life time
2017-06-13 11:16 ` Bin.Cheng
@ 2017-06-13 11:20 ` Richard Biener
0 siblings, 0 replies; 7+ messages in thread
From: Richard Biener @ 2017-06-13 11:20 UTC (permalink / raw)
To: Bin.Cheng; +Cc: gcc-patches
On Tue, Jun 13, 2017 at 1:15 PM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> On Tue, Jun 13, 2017 at 12: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.
> The global data is partly to avoid patch conflicts when separating
> patches, otherwise several parameters are needed for quite number of
> functions. We can introduce a global distribution data and only pass
> it to various functions.
Or make a class covering distribution of one loop (nest) and make all
functions members ...
struct one_loop_distribution
{
one_loop_distribution (loop *);
...
};
Richard.
> Thanks,
> bin
>>
>> Ok.
>>
>> Thanks,
>> Richard.
>>
>>> Thanks,
>>> bin
>>> 2017-06-07 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH GCC][06/13]Preserve loop nest in whole distribution life time
2017-06-13 11:08 ` Richard Biener
@ 2017-06-19 13:32 ` Bin.Cheng
2017-06-19 15:16 ` Richard Biener
0 siblings, 1 reply; 7+ messages in thread
From: Bin.Cheng @ 2017-06-19 13:32 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
[-- 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH GCC][06/13]Preserve loop nest in whole distribution life time
2017-06-19 13:32 ` Bin.Cheng
@ 2017-06-19 15:16 ` Richard Biener
0 siblings, 0 replies; 7+ messages in thread
From: Richard Biener @ 2017-06-19 15:16 UTC (permalink / raw)
To: Bin.Cheng; +Cc: gcc-patches
On Mon, Jun 19, 2017 at 3:32 PM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> 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?
Ok.
Richard.
> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-06-19 15:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-12 17:03 [PATCH GCC][06/13]Preserve loop nest in whole distribution life time Bin Cheng
2017-06-13 11:06 ` Richard Biener
2017-06-13 11:08 ` Richard Biener
2017-06-19 13:32 ` Bin.Cheng
2017-06-19 15:16 ` Richard Biener
2017-06-13 11:16 ` Bin.Cheng
2017-06-13 11:20 ` Richard Biener
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).