Message ID | 5640E24F.3030602@mentor.com |
---|---|
State | New |
Headers | show |
On Mon, 9 Nov 2015, Tom de Vries wrote: > On 09/11/15 16:35, Tom de Vries wrote: > > Hi, > > > > this patch series for stage1 trunk adds support to: > > - parallelize oacc kernels regions using parloops, and > > - map the loops onto the oacc gang dimension. > > > > The patch series contains these patches: > > > > 1 Insert new exit block only when needed in > > transform_to_exit_first_loop_alt > > 2 Make create_parallel_loop return void > > 3 Ignore reduction clause on kernels directive > > 4 Implement -foffload-alias > > 5 Add in_oacc_kernels_region in struct loop > > 6 Add pass_oacc_kernels > > 7 Add pass_dominator_oacc_kernels > > 8 Add pass_ch_oacc_kernels > > 9 Add pass_parallelize_loops_oacc_kernels > > 10 Add pass_oacc_kernels pass group in passes.def > > 11 Update testcases after adding kernels pass group > > 12 Handle acc loop directive > > 13 Add c-c++-common/goacc/kernels-*.c > > 14 Add gfortran.dg/goacc/kernels-*.f95 > > 15 Add libgomp.oacc-c-c++-common/kernels-*.c > > 16 Add libgomp.oacc-fortran/kernels-*.f95 > > > > The first 9 patches are more or less independent, but patches 10-16 are > > intended to be committed at the same time. > > > > Bootstrapped and reg-tested on x86_64. > > > > Build and reg-tested with nvidia accelerator, in combination with a > > patch that enables accelerator testing (which is submitted at > > https://gcc.gnu.org/ml/gcc-patches/2015-10/msg01771.html ). > > > > I'll post the individual patches in reply to this message. > > this patch adds pass_dominator_oacc_kernels (which we may as well call > pass_dominator_no_peel_loop_headers. It doesn't do anything > oacc-kernels-specific), to be used in the kernels pass group. > > The reason I'm adding a new pass instead of using pass_dominator is that > pass_dominator uses first_pass_instance. So adding a pass_dominator instance A > before a pass_dominator instance B has the unexpected consequence that it may > change the behaviour of instance B. I've filed PR68247 - "Remove > pass_first_instance" to note this issue. This looks ok (minus my comments to patch #10) Richard. > Thanks, > - Tom > >
On 11/11/15 12:05, Richard Biener wrote: > On Mon, 9 Nov 2015, Tom de Vries wrote: > >> On 09/11/15 16:35, Tom de Vries wrote: >>> Hi, >>> >>> this patch series for stage1 trunk adds support to: >>> - parallelize oacc kernels regions using parloops, and >>> - map the loops onto the oacc gang dimension. >>> >>> The patch series contains these patches: >>> >>> 1 Insert new exit block only when needed in >>> transform_to_exit_first_loop_alt >>> 2 Make create_parallel_loop return void >>> 3 Ignore reduction clause on kernels directive >>> 4 Implement -foffload-alias >>> 5 Add in_oacc_kernels_region in struct loop >>> 6 Add pass_oacc_kernels >>> 7 Add pass_dominator_oacc_kernels >>> 8 Add pass_ch_oacc_kernels >>> 9 Add pass_parallelize_loops_oacc_kernels >>> 10 Add pass_oacc_kernels pass group in passes.def >>> 11 Update testcases after adding kernels pass group >>> 12 Handle acc loop directive >>> 13 Add c-c++-common/goacc/kernels-*.c >>> 14 Add gfortran.dg/goacc/kernels-*.f95 >>> 15 Add libgomp.oacc-c-c++-common/kernels-*.c >>> 16 Add libgomp.oacc-fortran/kernels-*.f95 >>> >>> The first 9 patches are more or less independent, but patches 10-16 are >>> intended to be committed at the same time. >>> >>> Bootstrapped and reg-tested on x86_64. >>> >>> Build and reg-tested with nvidia accelerator, in combination with a >>> patch that enables accelerator testing (which is submitted at >>> https://gcc.gnu.org/ml/gcc-patches/2015-10/msg01771.html ). >>> >>> I'll post the individual patches in reply to this message. >> >> this patch adds pass_dominator_oacc_kernels (which we may as well call >> pass_dominator_no_peel_loop_headers. It doesn't do anything >> oacc-kernels-specific), to be used in the kernels pass group. >> >> The reason I'm adding a new pass instead of using pass_dominator is that >> pass_dominator uses first_pass_instance. So adding a pass_dominator instance A >> before a pass_dominator instance B has the unexpected consequence that it may >> change the behaviour of instance B. I've filed PR68247 - "Remove >> pass_first_instance" to note this issue. > > This looks ok (minus my comments to patch #10) > AFAIU, if "Remove first_pass_instance from pass_dominator" get approved and committed, we can drop this patch, and use this pass instantiation instead in the oacc_kernels pass group: ... NEXT_PASS (pass_dominator, false /* may_peel_loop_headers_p */); ... Thanks, - Tom
Add pass_dominator_oacc_kernels 2015-11-09 Tom de Vries <tom@codesourcery.com> * tree-pass.h (make_pass_dominator_oacc_kernels): Declare. * tree-ssa-dom.c (class dominator_base): New class. Factor out of ... (class pass_dominator): ... here. (dominator_base::may_peel_loop_headers_p) (pass_dominator::may_peel_loop_headers_p): New function. (pass_dominator_oacc_kernels): New pass. (make_pass_dominator_oacc_kernels): New function. (dominator_base::execute): Use may_peel_loop_headers_p. --- gcc/tree-pass.h | 1 + gcc/tree-ssa-dom.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 4ed8da6..2825aea 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -395,6 +395,7 @@ extern gimple_opt_pass *make_pass_build_ssa (gcc::context *ctxt); extern gimple_opt_pass *make_pass_build_alias (gcc::context *ctxt); extern gimple_opt_pass *make_pass_build_ealias (gcc::context *ctxt); extern gimple_opt_pass *make_pass_dominator (gcc::context *ctxt); +extern gimple_opt_pass *make_pass_dominator_oacc_kernels (gcc::context *ctxt); extern gimple_opt_pass *make_pass_dce (gcc::context *ctxt); extern gimple_opt_pass *make_pass_cd_dce (gcc::context *ctxt); extern gimple_opt_pass *make_pass_call_cdce (gcc::context *ctxt); diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 3887bbe1..e4ff63a 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -519,6 +519,19 @@ private: namespace { +class dominator_base : public gimple_opt_pass +{ + protected: + dominator_base (pass_data data, gcc::context *ctxt) + : gimple_opt_pass (data, ctxt) + {} + + unsigned int execute (function *); + + protected: + virtual bool may_peel_loop_headers_p (void) { return true; } +}; // class dominator_base + const pass_data pass_data_dominator = { GIMPLE_PASS, /* type */ @@ -532,22 +545,23 @@ const pass_data pass_data_dominator = ( TODO_cleanup_cfg | TODO_update_ssa ), /* todo_flags_finish */ }; -class pass_dominator : public gimple_opt_pass +class pass_dominator : public dominator_base { public: pass_dominator (gcc::context *ctxt) - : gimple_opt_pass (pass_data_dominator, ctxt) + : dominator_base (pass_data_dominator, ctxt) {} /* opt_pass methods: */ opt_pass * clone () { return new pass_dominator (m_ctxt); } virtual bool gate (function *) { return flag_tree_dom != 0; } - virtual unsigned int execute (function *); + protected: + virtual bool may_peel_loop_headers_p (void) { return first_pass_instance; } }; // class pass_dominator unsigned int -pass_dominator::execute (function *fun) +dominator_base::execute (function *fun) { memset (&opt_stats, 0, sizeof (opt_stats)); @@ -619,7 +633,7 @@ pass_dominator::execute (function *fun) free_all_edge_infos (); /* Thread jumps, creating duplicate blocks as needed. */ - cfg_altered |= thread_through_all_blocks (first_pass_instance); + cfg_altered |= thread_through_all_blocks (may_peel_loop_headers_p ()); if (cfg_altered) free_dominance_info (CDI_DOMINATORS); @@ -700,6 +714,34 @@ pass_dominator::execute (function *fun) return 0; } +const pass_data pass_data_dominator_oacc_kernels = +{ + GIMPLE_PASS, /* type */ + "dom_oacc_kernels", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_TREE_SSA_DOMINATOR_OPTS, /* tv_id */ + ( PROP_cfg | PROP_ssa ), /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + ( TODO_cleanup_cfg | TODO_update_ssa ), /* todo_flags_finish */ +}; + +class pass_dominator_oacc_kernels : public dominator_base +{ +public: + pass_dominator_oacc_kernels (gcc::context *ctxt) + : dominator_base (pass_data_dominator_oacc_kernels, ctxt) + {} + + /* opt_pass methods: */ + opt_pass * clone () { return new pass_dominator_oacc_kernels (m_ctxt); } + virtual bool gate (function *) { return true; } + + protected: + virtual bool may_peel_loop_headers_p (void) { return false; } +}; // class pass_dominator_oacc_kernels + } // anon namespace gimple_opt_pass * @@ -708,6 +750,11 @@ make_pass_dominator (gcc::context *ctxt) return new pass_dominator (ctxt); } +gimple_opt_pass * +make_pass_dominator_oacc_kernels (gcc::context *ctxt) +{ + return new pass_dominator_oacc_kernels (ctxt); +} /* Given a conditional statement CONDSTMT, convert the condition to a canonical form. */ -- 1.9.1