Message ID | VI1PR0802MB21768DDC39759A94BC4F2A54E7CD0@VI1PR0802MB2176.eurprd08.prod.outlook.com |
---|---|
State | New |
Headers | show |
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.
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.
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.
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.
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);
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. 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(-)