2015-08-06 Nathan Sidwell * doc/tm.texi.in (TARGET_GOACC_FORK_JOIN): New. * doc/tm.texi: Regenerate. * omp-low.c (execute_oacc_transform): Forward fork and join to target hook. (default_goacc_fork_join): New. * target.def (fork_join): New OpenACC hook. * targhooks.h (default_goacc_fork_join): Declare. Index: doc/tm.texi =================================================================== --- doc/tm.texi (revision 226665) +++ doc/tm.texi (working copy) @@ -5741,11 +5741,18 @@ to use it. @end deftypefn @deftypefn {Target Hook} tree TARGET_GOACC_VALIDATE_DIMS (tree, @var{tree}) -This hook should check the launch dimensions provided/ It should fill +This hook should check the launch dimensions provided. It should fill in default values and verify non-defaults. The TREE_LIST is unshared and may be overwritten. Diagnostics should be issued as appropriate. @end deftypefn +@deftypefn {Target Hook} bool TARGET_GOACC_FORK_JOIN (bool, gimple_stmt_iterator *@var{}, @var{gimple}) +This hook should convert IFN_GOACC_FORK and IFN_GOACC_JOIN function +calls to target-specific gimple. It is executed during the oacc_xform +pass. It should return true, if the functions should be deleted. The +default hook returns true, if there is no RTL expanders for them. +@end deftypefn + @node Anchored Addresses @section Anchored Addresses @cindex anchored addresses Index: doc/tm.texi.in =================================================================== --- doc/tm.texi.in (revision 226665) +++ doc/tm.texi.in (working copy) @@ -4247,6 +4247,8 @@ address; but often a machine-dependent @hook TARGET_GOACC_VALIDATE_DIMS +@hook TARGET_GOACC_FORK_JOIN + @node Anchored Addresses @section Anchored Addresses @cindex anchored addresses Index: omp-low.c =================================================================== --- omp-low.c (revision 226665) +++ omp-low.c (working copy) @@ -14638,30 +14638,35 @@ execute_oacc_transform () oacc_xform_on_device (&gsi, stmt); if (gimple_call_internal_p (stmt)) - switch (gimple_call_internal_fn (stmt)) - { - default: break; - - case IFN_GOACC_DIM_SIZE: - if (dims) - oacc_xform_dim (&gsi, stmt, dims, false); - break; - - case IFN_GOACC_DIM_POS: - if (dims) - oacc_xform_dim (&gsi, stmt, dims, true); - break; - -#ifndef ACCEL_COMPILER - case IFN_GOACC_FORK: - case IFN_GOACC_JOIN: - /* These are irrelevant on the host. */ - replace_uses_by (gimple_vdef (stmt), gimple_vuse (stmt)); - gsi_remove (&gsi, true); - /* Removal will have advanced the iterator. */ - continue; -#endif - } + { + unsigned ifn_code = gimple_call_internal_fn (stmt); + switch (ifn_code) + { + default: break; + + case IFN_GOACC_DIM_SIZE: + if (dims) + oacc_xform_dim (&gsi, stmt, dims, false); + break; + + case IFN_GOACC_DIM_POS: + if (dims) + oacc_xform_dim (&gsi, stmt, dims, true); + break; + + case IFN_GOACC_FORK: + case IFN_GOACC_JOIN: + if (targetm.goacc.fork_join + (ifn_code == IFN_GOACC_FORK, &gsi, stmt)) + { + replace_uses_by (gimple_vdef (stmt), + gimple_vuse (stmt)); + gsi_remove (&gsi, true); + /* Removal will have advanced the iterator. */ + continue; + } + } + } } gsi_next (&gsi); } @@ -14670,7 +14675,8 @@ execute_oacc_transform () return 0; } -/* Default launch dimension validator. */ +/* Default launch dimension validator. Force everything to 1 on the + host and default to 1 otherwise. */ tree default_goacc_validate_dims (tree ARG_UNUSED (decl), tree dims) @@ -14693,6 +14699,30 @@ default_goacc_validate_dims (tree ARG_UN return dims; } +/* Default fork/join early expander. Delete the function calls if + there is no RTL expander. */ + +bool +default_goacc_fork_join (bool is_fork, gimple_stmt_iterator *ARG_UNUSED (gsi), + gimple ARG_UNUSED (stmt)) +{ + if (is_fork) + { +#ifdef HAVE_oacc_fork + return false; +#endif + } + else + { +#ifdef HAVE_oacc_join + return false; +#endif + } + + /* We have no expander, so delete the functions now. */ + return true; +} + namespace { const pass_data pass_data_oacc_transform = Index: target.def =================================================================== --- target.def (revision 226665) +++ target.def (working copy) @@ -1646,12 +1646,21 @@ HOOK_VECTOR (TARGET_GOACC, goacc) DEFHOOK (validate_dims, -"This hook should check the launch dimensions provided/ It should fill\n\ +"This hook should check the launch dimensions provided. It should fill\n\ in default values and verify non-defaults. The TREE_LIST is unshared\n\ and may be overwritten. Diagnostics should be issued as appropriate.", tree, (tree, tree), default_goacc_validate_dims) +DEFHOOK +(fork_join, +"This hook should convert IFN_GOACC_FORK and IFN_GOACC_JOIN function\n\ +calls to target-specific gimple. It is executed during the oacc_xform\n\ +pass. It should return true, if the functions should be deleted. The\n\ +default hook returns true, if there is no RTL expanders for them.", +bool, (bool, gimple_stmt_iterator *, gimple), +default_goacc_fork_join) + HOOK_VECTOR_END (goacc) /* Functions relating to vectorization. */ Index: targhooks.h =================================================================== --- targhooks.h (revision 226665) +++ targhooks.h (working copy) @@ -108,6 +108,7 @@ extern void default_finish_cost (void *, extern void default_destroy_cost_data (void *); extern tree default_goacc_validate_dims (tree, tree); +extern bool default_goacc_fork_join (bool, gimple_stmt_iterator *, gimple); /* These are here, and not in hooks.[ch], because not all users of hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS. */