From: Tom de Vries Date: Wed, 25 Nov 2015 21:26:24 +0000 (+0000) Subject: Add pass_oacc_kernels X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=896522eec5e80bb93108053d95096de46fb21939;p=gcc.git Add pass_oacc_kernels 2015-11-25 Tom de Vries * tree-pass.h (make_pass_oacc_kernels, make_pass_oacc_kernels2): Declare. * tree-ssa-loop.c (gate_oacc_kernels): New static function. (pass_data_oacc_kernels, pass_data_oacc_kernels2): New pass_data. (class pass_oacc_kernels, class pass_oacc_kernels2): New pass. (make_pass_oacc_kernels, make_pass_oacc_kernels2): New function. From-SVN: r230906 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2950141066c..8ba6d08f89c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2015-11-25 Tom de Vries + + * tree-pass.h (make_pass_oacc_kernels, make_pass_oacc_kernels2): + Declare. + * tree-ssa-loop.c (gate_oacc_kernels): New static function. + (pass_data_oacc_kernels, pass_data_oacc_kernels2): New pass_data. + (class pass_oacc_kernels, class pass_oacc_kernels2): New pass. + (make_pass_oacc_kernels, make_pass_oacc_kernels2): New function. + 2015-11-25 Jan Hubicka * timevar.def (TV_IPA_LTO_DECOMPRESS, TV_IPA_LTO_COMPRESS, diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index dcd2d5e3a46..97049183451 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -465,6 +465,8 @@ extern gimple_opt_pass *make_pass_strength_reduction (gcc::context *ctxt); extern gimple_opt_pass *make_pass_vtable_verify (gcc::context *ctxt); extern gimple_opt_pass *make_pass_ubsan (gcc::context *ctxt); extern gimple_opt_pass *make_pass_sanopt (gcc::context *ctxt); +extern gimple_opt_pass *make_pass_oacc_kernels (gcc::context *ctxt); +extern gimple_opt_pass *make_pass_oacc_kernels2 (gcc::context *ctxt); /* IPA Passes */ extern simple_ipa_opt_pass *make_pass_ipa_lower_emutls (gcc::context *ctxt); diff --git a/gcc/tree-ssa-loop.c b/gcc/tree-ssa-loop.c index afdef121788..cf7d94ef1cd 100644 --- a/gcc/tree-ssa-loop.c +++ b/gcc/tree-ssa-loop.c @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-inline.h" #include "tree-scalar-evolution.h" #include "tree-vectorizer.h" +#include "omp-low.h" /* A pass making sure loops are fixed up. */ @@ -141,6 +142,115 @@ make_pass_tree_loop (gcc::context *ctxt) return new pass_tree_loop (ctxt); } +/* Gate for oacc kernels pass group. */ + +static bool +gate_oacc_kernels (function *fn) +{ + if (flag_tree_parallelize_loops <= 1) + return false; + + tree oacc_function_attr = get_oacc_fn_attrib (fn->decl); + if (oacc_function_attr == NULL_TREE) + return false; + + tree val = TREE_VALUE (oacc_function_attr); + while (val != NULL_TREE && TREE_VALUE (val) == NULL_TREE) + val = TREE_CHAIN (val); + + if (val != NULL_TREE) + return false; + + struct loop *loop; + FOR_EACH_LOOP (loop, 0) + if (loop->in_oacc_kernels_region) + return true; + + return false; +} + +/* The oacc kernels superpass. */ + +namespace { + +const pass_data pass_data_oacc_kernels = +{ + GIMPLE_PASS, /* type */ + "oacc_kernels", /* name */ + OPTGROUP_LOOP, /* optinfo_flags */ + TV_TREE_LOOP, /* tv_id */ + PROP_cfg, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_oacc_kernels : public gimple_opt_pass +{ +public: + pass_oacc_kernels (gcc::context *ctxt) + : gimple_opt_pass (pass_data_oacc_kernels, ctxt) + {} + + /* opt_pass methods: */ + virtual bool gate (function *fn) { return gate_oacc_kernels (fn); } + +}; // class pass_oacc_kernels + +} // anon namespace + +gimple_opt_pass * +make_pass_oacc_kernels (gcc::context *ctxt) +{ + return new pass_oacc_kernels (ctxt); +} + +namespace { + +const pass_data pass_data_oacc_kernels2 = +{ + GIMPLE_PASS, /* type */ + "oacc_kernels2", /* name */ + OPTGROUP_LOOP, /* optinfo_flags */ + TV_TREE_LOOP, /* tv_id */ + PROP_cfg, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_oacc_kernels2 : public gimple_opt_pass +{ +public: + pass_oacc_kernels2 (gcc::context *ctxt) + : gimple_opt_pass (pass_data_oacc_kernels2, ctxt) + {} + + /* opt_pass methods: */ + virtual bool gate (function *fn) { return gate_oacc_kernels (fn); } + virtual unsigned int execute (function *fn) + { + /* Rather than having a copy of the previous dump, get some use out of + this dump, and try to minimize differences with the following pass + (pass_lim), which will initizalize the loop optimizer with + LOOPS_NORMAL. */ + loop_optimizer_init (LOOPS_NORMAL); + loop_optimizer_finalize (fn); + return 0; + } + +}; // class pass_oacc_kernels2 + +} // anon namespace + +gimple_opt_pass * +make_pass_oacc_kernels2 (gcc::context *ctxt) +{ + return new pass_oacc_kernels2 (ctxt); +} + /* The no-loop superpass. */ namespace {