Hi! On Wed, 10 May 2017 18:28:38 +0200, Jakub Jelinek <ja...@redhat.com> wrote: > On Mon, May 08, 2017 at 09:29:28PM +0200, Thomas Schwinge wrote: > > Use "oacc kernels" attribute for OpenACC kernels
> > * omp-expand.c (expand_omp_target) > > <GF_OMP_TARGET_KIND_OACC_KERNELS>: Set "oacc kernels" attribute. > > I think > * omp-expand.c (expand_omp_target) <GF_OMP_TARGET_KIND_OACC_KERNELS>: > Set "oacc kernels" attribute. > fits better. So you overrule how Emacs Change Log mode's fill-paragraph things this should be formatted. ;-) > > @@ -7451,7 +7457,7 @@ expand_omp_target (struct omp_region *region) > > break; > > case BUILT_IN_GOACC_PARALLEL: > > { > > - oacc_set_fn_attrib (child_fn, clauses, oacc_kernels_p, &args); > > + oacc_set_fn_attrib (child_fn, clauses, &args); > > tagging = true; > > } > > /* FALLTHRU */ > > The {}s aren't needed around this, could you drop them? Done, but aren't such cleanups usually requested to be done separately of actual code changes? > > + pos = tree_cons (purpose[ix], > > + build_int_cst (integer_type_node, dims[ix]), > > + pos); > > pos); would fit on the earlier line. As already split over more than one line, I thought it was clearer if the "chain" parameter was on its own line -- but you get to overrule me there, too. ;-) > Ok with those changes. Thanks; committed to trunk in r247955: commit 1d3ea8fcacec29c9a89d9d0a505ed5fbdd5ad73e Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Fri May 12 09:02:55 2017 +0000 Use "oacc kernels" attribute for OpenACC kernels gcc/ * omp-expand.c (expand_omp_target) <GF_OMP_TARGET_KIND_OACC_KERNELS>: Set "oacc kernels" attribute. * omp-general.c (oacc_set_fn_attrib): Remove is_kernel formal parameter. Adjust all users. (oacc_fn_attrib_kernels_p): Remove function. * omp-offload.c (execute_oacc_device_lower): Look for "oacc kernels" attribute instead of calling oacc_fn_attrib_kernels_p. * tree-ssa-loop.c (gate_oacc_kernels): Likewise. * tree-parloops.c (create_parallel_loop): If oacc_kernels_p, assert "oacc kernels" attribute is set. gcc/testsuite/ * c-c++-common/goacc/classify-kernels-unparallelized.c: Adjust. * c-c++-common/goacc/classify-kernels.c: Likewise. * c-c++-common/goacc/classify-parallel.c: Likewise. * c-c++-common/goacc/classify-routine.c: Likewise. * gfortran.dg/goacc/classify-kernels-unparallelized.f95: Likewise. * gfortran.dg/goacc/classify-kernels.f95: Likewise. * gfortran.dg/goacc/classify-parallel.f95: Likewise. * gfortran.dg/goacc/classify-routine.f95: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@247955 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 13 ++++++++++++ gcc/omp-expand.c | 20 ++++++++++-------- gcc/omp-general.c | 18 ++-------------- gcc/omp-general.h | 4 +--- gcc/omp-offload.c | 24 +++++++++++----------- gcc/testsuite/ChangeLog | 9 ++++++++ .../goacc/classify-kernels-unparallelized.c | 8 ++++---- .../c-c++-common/goacc/classify-kernels.c | 8 ++++---- .../c-c++-common/goacc/classify-parallel.c | 2 +- .../c-c++-common/goacc/classify-routine.c | 2 +- .../goacc/classify-kernels-unparallelized.f95 | 8 ++++---- .../gfortran.dg/goacc/classify-kernels.f95 | 8 ++++---- .../gfortran.dg/goacc/classify-parallel.f95 | 2 +- .../gfortran.dg/goacc/classify-routine.f95 | 2 +- gcc/tree-parloops.c | 5 ++++- gcc/tree-ssa-loop.c | 5 +---- 16 files changed, 74 insertions(+), 64 deletions(-) diff --git gcc/ChangeLog gcc/ChangeLog index e1f8cf5..aeb22df 100644 --- gcc/ChangeLog +++ gcc/ChangeLog @@ -1,3 +1,16 @@ +2017-05-12 Thomas Schwinge <tho...@codesourcery.com> + + * omp-expand.c (expand_omp_target) <GF_OMP_TARGET_KIND_OACC_KERNELS>: + Set "oacc kernels" attribute. + * omp-general.c (oacc_set_fn_attrib): Remove is_kernel formal + parameter. Adjust all users. + (oacc_fn_attrib_kernels_p): Remove function. + * omp-offload.c (execute_oacc_device_lower): Look for "oacc + kernels" attribute instead of calling oacc_fn_attrib_kernels_p. + * tree-ssa-loop.c (gate_oacc_kernels): Likewise. + * tree-parloops.c (create_parallel_loop): If oacc_kernels_p, + assert "oacc kernels" attribute is set. + 2017-05-11 Carl Love <c...@us.ibm.com> * config/rs6000/rs6000-c: Add support for built-in functions diff --git gcc/omp-expand.c gcc/omp-expand.c index 5c48b78..7a7c747 100644 --- gcc/omp-expand.c +++ gcc/omp-expand.c @@ -7083,7 +7083,16 @@ expand_omp_target (struct omp_region *region) exit_bb = region->exit; if (gimple_omp_target_kind (entry_stmt) == GF_OMP_TARGET_KIND_OACC_KERNELS) - mark_loops_in_oacc_kernels_region (region->entry, region->exit); + { + mark_loops_in_oacc_kernels_region (region->entry, region->exit); + + /* Further down, both OpenACC kernels and OpenACC parallel constructs + will be mappted to BUILT_IN_GOACC_PARALLEL, and to distinguish the + two, there is an "oacc kernels" attribute set for OpenACC kernels. */ + DECL_ATTRIBUTES (child_fn) + = tree_cons (get_identifier ("oacc kernels"), + NULL_TREE, DECL_ATTRIBUTES (child_fn)); + } if (offloaded) { @@ -7266,7 +7275,6 @@ expand_omp_target (struct omp_region *region) enum built_in_function start_ix; location_t clause_loc; unsigned int flags_i = 0; - bool oacc_kernels_p = false; switch (gimple_omp_target_kind (entry_stmt)) { @@ -7287,8 +7295,6 @@ expand_omp_target (struct omp_region *region) flags_i |= GOMP_TARGET_FLAG_EXIT_DATA; break; case GF_OMP_TARGET_KIND_OACC_KERNELS: - oacc_kernels_p = true; - /* FALLTHROUGH */ case GF_OMP_TARGET_KIND_OACC_PARALLEL: start_ix = BUILT_IN_GOACC_PARALLEL; break; @@ -7450,10 +7456,8 @@ expand_omp_target (struct omp_region *region) args.quick_push (get_target_arguments (&gsi, entry_stmt)); break; case BUILT_IN_GOACC_PARALLEL: - { - oacc_set_fn_attrib (child_fn, clauses, oacc_kernels_p, &args); - tagging = true; - } + oacc_set_fn_attrib (child_fn, clauses, &args); + tagging = true; /* FALLTHRU */ case BUILT_IN_GOACC_ENTER_EXIT_DATA: case BUILT_IN_GOACC_UPDATE: diff --git gcc/omp-general.c gcc/omp-general.c index 3f9aec8..9a5ed88 100644 --- gcc/omp-general.c +++ gcc/omp-general.c @@ -515,11 +515,10 @@ oacc_replace_fn_attrib (tree fn, tree dims) /* Scan CLAUSES for launch dimensions and attach them to the oacc function attribute. Push any that are non-constant onto the ARGS - list, along with an appropriate GOMP_LAUNCH_DIM tag. IS_KERNEL is - true, if these are for a kernels region offload function. */ + list, along with an appropriate GOMP_LAUNCH_DIM tag. */ void -oacc_set_fn_attrib (tree fn, tree clauses, bool is_kernel, vec<tree> *args) +oacc_set_fn_attrib (tree fn, tree clauses, vec<tree> *args) { /* Must match GOMP_DIM ordering. */ static const omp_clause_code ids[] @@ -545,9 +544,6 @@ oacc_set_fn_attrib (tree fn, tree clauses, bool is_kernel, vec<tree> *args) non_const |= GOMP_DIM_MASK (ix); } attr = tree_cons (NULL_TREE, dim, attr); - /* Note kernelness with TREE_PUBLIC. */ - if (is_kernel) - TREE_PUBLIC (attr) = 1; } oacc_replace_fn_attrib (fn, attr); @@ -616,16 +612,6 @@ oacc_get_fn_attrib (tree fn) return lookup_attribute (OACC_FN_ATTRIB, DECL_ATTRIBUTES (fn)); } -/* Return true if this oacc fn attrib is for a kernels offload - region. We use the TREE_PUBLIC flag of each dimension -- only - need to check the first one. */ - -bool -oacc_fn_attrib_kernels_p (tree attr) -{ - return TREE_PUBLIC (TREE_VALUE (attr)); -} - /* Extract an oacc execution dimension from FN. FN must be an offloaded function or routine that has already had its execution dimensions lowered to the target-specific values. */ diff --git gcc/omp-general.h gcc/omp-general.h index 3cf7fce..d28eb4b 100644 --- gcc/omp-general.h +++ gcc/omp-general.h @@ -82,11 +82,9 @@ extern int omp_max_vf (void); extern int omp_max_simt_vf (void); extern tree oacc_launch_pack (unsigned code, tree device, unsigned op); extern void oacc_replace_fn_attrib (tree fn, tree dims); -extern void oacc_set_fn_attrib (tree fn, tree clauses, bool is_kernel, - vec<tree> *args); +extern void oacc_set_fn_attrib (tree fn, tree clauses, vec<tree> *args); extern tree oacc_build_routine_dims (tree clauses); extern tree oacc_get_fn_attrib (tree fn); -extern bool oacc_fn_attrib_kernels_p (tree attr); extern int oacc_get_fn_dim_size (tree fn, int axis); extern int oacc_get_ifn_dim_arg (const gimple *stmt); diff --git gcc/omp-offload.c gcc/omp-offload.c index beeeb71..d24f131 100644 --- gcc/omp-offload.c +++ gcc/omp-offload.c @@ -619,7 +619,6 @@ oacc_validate_dims (tree fn, tree attrs, int *dims, int level, unsigned used) tree purpose[GOMP_DIM_MAX]; unsigned ix; tree pos = TREE_VALUE (attrs); - bool is_kernel = oacc_fn_attrib_kernels_p (attrs); /* Make sure the attribute creator attached the dimension information. */ @@ -666,13 +665,8 @@ oacc_validate_dims (tree fn, tree attrs, int *dims, int level, unsigned used) /* Replace the attribute with new values. */ pos = NULL_TREE; for (ix = GOMP_DIM_MAX; ix--;) - { - pos = tree_cons (purpose[ix], - build_int_cst (integer_type_node, dims[ix]), - pos); - if (is_kernel) - TREE_PUBLIC (pos) = 1; - } + pos = tree_cons (purpose[ix], + build_int_cst (integer_type_node, dims[ix]), pos); oacc_replace_fn_attrib (fn, pos); } } @@ -1455,10 +1449,16 @@ execute_oacc_device_lower () int fn_level = oacc_fn_attrib_level (attrs); if (dump_file) - fprintf (dump_file, oacc_fn_attrib_kernels_p (attrs) - ? "Function is kernels offload\n" - : fn_level < 0 ? "Function is parallel offload\n" - : "Function is routine level %d\n", fn_level); + { + if (fn_level >= 0) + fprintf (dump_file, "Function is OpenACC routine level %d\n", + fn_level); + else if (lookup_attribute ("oacc kernels", + DECL_ATTRIBUTES (current_function_decl))) + fprintf (dump_file, "Function is OpenACC kernels offload\n"); + else + fprintf (dump_file, "Function is OpenACC parallel offload\n"); + } unsigned outer_mask = fn_level >= 0 ? GOMP_DIM_MASK (fn_level) - 1 : 0; unsigned used_mask = oacc_loop_partition (loops, outer_mask); diff --git gcc/testsuite/ChangeLog gcc/testsuite/ChangeLog index 5ed40a5..52865d3 100644 --- gcc/testsuite/ChangeLog +++ gcc/testsuite/ChangeLog @@ -1,5 +1,14 @@ 2017-05-12 Thomas Schwinge <tho...@codesourcery.com> + * c-c++-common/goacc/classify-kernels-unparallelized.c: Adjust. + * c-c++-common/goacc/classify-kernels.c: Likewise. + * c-c++-common/goacc/classify-parallel.c: Likewise. + * c-c++-common/goacc/classify-routine.c: Likewise. + * gfortran.dg/goacc/classify-kernels-unparallelized.f95: Likewise. + * gfortran.dg/goacc/classify-kernels.f95: Likewise. + * gfortran.dg/goacc/classify-parallel.f95: Likewise. + * gfortran.dg/goacc/classify-routine.f95: Likewise. + * c-c++-common/goacc/classify-kernels-unparallelized.c: New file. * c-c++-common/goacc/classify-kernels.c: Likewise. * c-c++-common/goacc/classify-parallel.c: Likewise. diff --git gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c index a76351c..70ff428 100644 --- gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c +++ gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c @@ -24,16 +24,16 @@ void KERNELS () } /* Check the offloaded function's attributes. - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp target entrypoint\\)\\)" 1 "ompexp" } } */ + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels, omp target entrypoint\\)\\)" 1 "ompexp" } } */ /* Check that exactly one OpenACC kernels construct is analyzed, and that it can't be parallelized. { dg-final { scan-tree-dump-times "FAILED:" 1 "parloops1" } } - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(, , \\), omp target entrypoint\\)\\)" 1 "parloops1" } } + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } { dg-final { scan-tree-dump-not "SUCCESS: may be parallelized" "parloops1" } } */ /* Check the offloaded function's classification and compute dimensions (will always be 1 x 1 x 1 for non-offloading compilation). - { dg-final { scan-tree-dump-times "(?n)Function is kernels offload" 1 "oaccdevlow" } } + { dg-final { scan-tree-dump-times "(?n)Function is OpenACC kernels offload" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } */ + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), oacc kernels, omp target entrypoint\\)\\)" 1 "oaccdevlow" } } */ diff --git gcc/testsuite/c-c++-common/goacc/classify-kernels.c gcc/testsuite/c-c++-common/goacc/classify-kernels.c index 199a73e..c8b0fda 100644 --- gcc/testsuite/c-c++-common/goacc/classify-kernels.c +++ gcc/testsuite/c-c++-common/goacc/classify-kernels.c @@ -20,16 +20,16 @@ void KERNELS () } /* Check the offloaded function's attributes. - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp target entrypoint\\)\\)" 1 "ompexp" } } */ + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels, omp target entrypoint\\)\\)" 1 "ompexp" } } */ /* Check that exactly one OpenACC kernels construct is analyzed, and that it can be parallelized. { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0, , \\), omp target entrypoint\\)\\)" 1 "parloops1" } } + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */ /* Check the offloaded function's classification and compute dimensions (will always be 1 x 1 x 1 for non-offloading compilation). - { dg-final { scan-tree-dump-times "(?n)Function is kernels offload" 1 "oaccdevlow" } } + { dg-final { scan-tree-dump-times "(?n)Function is OpenACC kernels offload" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } */ + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), oacc kernels, omp target entrypoint\\)\\)" 1 "oaccdevlow" } } */ diff --git gcc/testsuite/c-c++-common/goacc/classify-parallel.c gcc/testsuite/c-c++-common/goacc/classify-parallel.c index 9d48c1b..4f97301 100644 --- gcc/testsuite/c-c++-common/goacc/classify-parallel.c +++ gcc/testsuite/c-c++-common/goacc/classify-parallel.c @@ -23,6 +23,6 @@ void PARALLEL () /* Check the offloaded function's classification and compute dimensions (will always be 1 x 1 x 1 for non-offloading compilation). - { dg-final { scan-tree-dump-times "(?n)Function is parallel offload" 1 "oaccdevlow" } } + { dg-final { scan-tree-dump-times "(?n)Function is OpenACC parallel offload" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } */ diff --git gcc/testsuite/c-c++-common/goacc/classify-routine.c gcc/testsuite/c-c++-common/goacc/classify-routine.c index 72b02c2..fd89fc1 100644 --- gcc/testsuite/c-c++-common/goacc/classify-routine.c +++ gcc/testsuite/c-c++-common/goacc/classify-routine.c @@ -25,6 +25,6 @@ void ROUTINE () /* Check the offloaded function's classification and compute dimensions (will always be 1 x 1 x 1 for non-offloading compilation). - { dg-final { scan-tree-dump-times "(?n)Function is routine level 1" 1 "oaccdevlow" } } + { dg-final { scan-tree-dump-times "(?n)Function is OpenACC routine level 1" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0 1, 1 1, 1 1\\), omp declare target, oacc function \\(0 1, 1 0, 1 0\\)\\)\\)" 1 "oaccdevlow" } } */ diff --git gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95 gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95 index fd46d0d..9887d35 100644 --- gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95 +++ gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95 @@ -26,16 +26,16 @@ program main end program main ! Check the offloaded function's attributes. -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp target entrypoint\\)\\)" 1 "ompexp" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels, omp target entrypoint\\)\\)" 1 "ompexp" } } ! Check that exactly one OpenACC kernels construct is analyzed, and that it ! can't be parallelized. ! { dg-final { scan-tree-dump-times "FAILED:" 1 "parloops1" } } -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(, , \\), omp target entrypoint\\)\\)" 1 "parloops1" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } ! { dg-final { scan-tree-dump-not "SUCCESS: may be parallelized" "parloops1" } } ! Check the offloaded function's classification and compute dimensions (will ! always be 1 x 1 x 1 for non-offloading compilation). -! { dg-final { scan-tree-dump-times "(?n)Function is kernels offload" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)Function is OpenACC kernels offload" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), oacc kernels, omp target entrypoint\\)\\)" 1 "oaccdevlow" } } diff --git gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95 gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95 index 053d27c..69c89a9 100644 --- gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95 +++ gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95 @@ -22,16 +22,16 @@ program main end program main ! Check the offloaded function's attributes. -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp target entrypoint\\)\\)" 1 "ompexp" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels, omp target entrypoint\\)\\)" 1 "ompexp" } } ! Check that exactly one OpenACC kernels construct is analyzed, and that it ! can be parallelized. ! { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0, , \\), omp target entrypoint\\)\\)" 1 "parloops1" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } ! { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } ! Check the offloaded function's classification and compute dimensions (will ! always be 1 x 1 x 1 for non-offloading compilation). -! { dg-final { scan-tree-dump-times "(?n)Function is kernels offload" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)Function is OpenACC kernels offload" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), oacc kernels, omp target entrypoint\\)\\)" 1 "oaccdevlow" } } diff --git gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95 gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95 index 087ff48..e215c79 100644 --- gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95 +++ gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95 @@ -25,6 +25,6 @@ end program main ! Check the offloaded function's classification and compute dimensions (will ! always be 1 x 1 x 1 for non-offloading compilation). -! { dg-final { scan-tree-dump-times "(?n)Function is parallel offload" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)Function is OpenACC parallel offload" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } diff --git gcc/testsuite/gfortran.dg/goacc/classify-routine.f95 gcc/testsuite/gfortran.dg/goacc/classify-routine.f95 index 319d767..4ca4067 100644 --- gcc/testsuite/gfortran.dg/goacc/classify-routine.f95 +++ gcc/testsuite/gfortran.dg/goacc/classify-routine.f95 @@ -24,6 +24,6 @@ end subroutine ROUTINE ! Check the offloaded function's classification and compute dimensions (will ! always be 1 x 1 x 1 for non-offloading compilation). -! { dg-final { scan-tree-dump-times "(?n)Function is routine level 1" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)Function is OpenACC routine level 1" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0 1, 1 1, 1 1\\), omp declare target, oacc function \\(0 0, 1 0, 1 0\\)\\)\\)" 1 "oaccdevlow" } } diff --git gcc/tree-parloops.c gcc/tree-parloops.c index 7393011..6ce9d84 100644 --- gcc/tree-parloops.c +++ gcc/tree-parloops.c @@ -2043,10 +2043,13 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data, /* Prepare the GIMPLE_OMP_PARALLEL statement. */ if (oacc_kernels_p) { + gcc_checking_assert (lookup_attribute ("oacc kernels", + DECL_ATTRIBUTES (cfun->decl))); + tree clause = build_omp_clause (loc, OMP_CLAUSE_NUM_GANGS); OMP_CLAUSE_NUM_GANGS_EXPR (clause) = build_int_cst (integer_type_node, n_threads); - oacc_set_fn_attrib (cfun->decl, clause, true, NULL); + oacc_set_fn_attrib (cfun->decl, clause, NULL); } else { diff --git gcc/tree-ssa-loop.c gcc/tree-ssa-loop.c index 8b25b41..10c43f3 100644 --- gcc/tree-ssa-loop.c +++ gcc/tree-ssa-loop.c @@ -152,10 +152,7 @@ gate_oacc_kernels (function *fn) if (!flag_openacc) return false; - tree oacc_function_attr = oacc_get_fn_attrib (fn->decl); - if (oacc_function_attr == NULL_TREE) - return false; - if (!oacc_fn_attrib_kernels_p (oacc_function_attr)) + if (!lookup_attribute ("oacc kernels", DECL_ATTRIBUTES (fn->decl))) return false; struct loop *loop; Committed to gomp-4_0-branch in r247956: commit 01a98ef0ceb7afc15b7a97054bbff1db0ccf9fb4 Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Fri May 12 09:03:37 2017 +0000 Use "oacc kernels" attribute for OpenACC kernels gcc/ * omp-low.c (expand_omp_target) <GF_OMP_TARGET_KIND_OACC_KERNELS>: Set "oacc kernels" attribute. (set_oacc_fn_attrib): Remove is_kernel formal parameter. Adjust all users. (oacc_fn_attrib_kernels_p): Remove function. (oacc_validate_dims, execute_oacc_device_lower): Look for "oacc kernels" attribute instead of calling oacc_fn_attrib_kernels_p. * tree-ssa-loop.c (gate_oacc_kernels): Likewise. * config/nvptx/nvptx.c (nvptx_goacc_validate_dims): Likewise. * tree-parloops.c (create_parallel_loop): If oacc_kernels_p, assert "oacc kernels" attribute is set. gcc/testsuite/ * c-c++-common/goacc/oaccdevlow-kernels.c: Adjust. * c-c++-common/goacc/oaccdevlow-parallel.c: Likewise. * c-c++-common/goacc/oaccdevlow-routine.c: Likewise. * gfortran.dg/goacc/oaccdevlow-kernels.f95: Likewise. * gfortran.dg/goacc/oaccdevlow-parallel.f95: Likewise. * gfortran.dg/goacc/oaccdevlow-routine.f95: Likewise. trunk r247955 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@247956 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.gomp | 14 +++++ gcc/config/nvptx/nvptx.c | 4 +- gcc/omp-low.c | 65 ++++++++++------------ gcc/omp-low.h | 3 +- gcc/testsuite/ChangeLog.gomp | 7 +++ .../goacc/classify-kernels-unparallelized.c | 8 +-- .../c-c++-common/goacc/classify-kernels.c | 8 +-- .../c-c++-common/goacc/classify-parallel.c | 2 +- .../c-c++-common/goacc/classify-routine.c | 2 +- .../goacc/classify-kernels-unparallelized.f95 | 8 +-- .../gfortran.dg/goacc/classify-kernels.f95 | 8 +-- .../gfortran.dg/goacc/classify-parallel.f95 | 2 +- .../gfortran.dg/goacc/classify-routine.f95 | 2 +- gcc/tree-parloops.c | 5 +- gcc/tree-ssa-loop.c | 5 +- 15 files changed, 76 insertions(+), 67 deletions(-) diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp index 5139796..8cd46c3 100644 --- gcc/ChangeLog.gomp +++ gcc/ChangeLog.gomp @@ -1,3 +1,17 @@ +2017-05-12 Thomas Schwinge <tho...@codesourcery.com> + + * omp-low.c (expand_omp_target) <GF_OMP_TARGET_KIND_OACC_KERNELS>: + Set "oacc kernels" attribute. + (set_oacc_fn_attrib): Remove is_kernel formal parameter. Adjust + all users. + (oacc_fn_attrib_kernels_p): Remove function. + (oacc_validate_dims, execute_oacc_device_lower): Look for "oacc + kernels" attribute instead of calling oacc_fn_attrib_kernels_p. + * tree-ssa-loop.c (gate_oacc_kernels): Likewise. + * config/nvptx/nvptx.c (nvptx_goacc_validate_dims): Likewise. + * tree-parloops.c (create_parallel_loop): If oacc_kernels_p, + assert "oacc kernels" attribute is set. + 2017-05-11 Cesar Philippidis <ce...@codesourcery.com> * gimplify.c (gomp_needs_data_present): Ensure that the diff --git gcc/config/nvptx/nvptx.c gcc/config/nvptx/nvptx.c index f790728..f3c1525 100644 --- gcc/config/nvptx/nvptx.c +++ gcc/config/nvptx/nvptx.c @@ -4284,10 +4284,8 @@ nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level) construct could not be parallelized, but only do that for -O2 and higher, as otherwise we're not expecting any parallelization to happen. */ - tree oacc_function_attr = get_oacc_fn_attrib (decl); if (optimize >= 2 - && oacc_function_attr - && oacc_fn_attrib_kernels_p (oacc_function_attr)) + && lookup_attribute ("oacc kernels", DECL_ATTRIBUTES (decl))) { bool avoid_offloading_p = true; for (unsigned ix = 0; ix != GOMP_DIM_MAX; ix++) diff --git gcc/omp-low.c gcc/omp-low.c index a681800..18872f9 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -13136,11 +13136,10 @@ replace_oacc_fn_attrib (tree fn, tree dims) /* Scan CLAUSES for launch dimensions and attach them to the oacc function attribute. Push any that are non-constant onto the ARGS - list, along with an appropriate GOMP_LAUNCH_DIM tag. IS_KERNEL is - true, if these are for a kernels region offload function. */ + list, along with an appropriate GOMP_LAUNCH_DIM tag. */ void -set_oacc_fn_attrib (tree fn, tree clauses, bool is_kernel, vec<tree> *args) +set_oacc_fn_attrib (tree fn, tree clauses, vec<tree> *args) { /* Must match GOMP_DIM ordering. */ static const omp_clause_code ids[] @@ -13165,9 +13164,6 @@ set_oacc_fn_attrib (tree fn, tree clauses, bool is_kernel, vec<tree> *args) non_const |= GOMP_DIM_MASK (ix); } attr = tree_cons (NULL_TREE, dim, attr); - /* Note kernelness with TREE_PUBLIC. */ - if (is_kernel) - TREE_PUBLIC (attr) = 1; } replace_oacc_fn_attrib (fn, attr); @@ -13423,16 +13419,6 @@ get_oacc_fn_attrib (tree fn) return lookup_attribute (OACC_FN_ATTRIB, DECL_ATTRIBUTES (fn)); } -/* Return true if this oacc fn attrib is for a kernels offload - region. We use the TREE_PUBLIC flag of each dimension -- only - need to check the first one. */ - -bool -oacc_fn_attrib_kernels_p (tree attr) -{ - return TREE_PUBLIC (TREE_VALUE (attr)); -} - /* Return level at which oacc routine may spawn a partitioned loop, or -1 if it is not a routine (i.e. is an offload fn). */ @@ -13815,7 +13801,16 @@ expand_omp_target (struct omp_region *region) exit_bb = region->exit; if (gimple_omp_target_kind (entry_stmt) == GF_OMP_TARGET_KIND_OACC_KERNELS) - mark_loops_in_oacc_kernels_region (region->entry, region->exit); + { + mark_loops_in_oacc_kernels_region (region->entry, region->exit); + + /* Further down, both OpenACC kernels and OpenACC parallel constructs + will be mappted to BUILT_IN_GOACC_PARALLEL, and to distinguish the + two, there is an "oacc kernels" attribute set for OpenACC kernels. */ + DECL_ATTRIBUTES (child_fn) + = tree_cons (get_identifier ("oacc kernels"), + NULL_TREE, DECL_ATTRIBUTES (child_fn)); + } if (offloaded) { @@ -13995,7 +13990,6 @@ expand_omp_target (struct omp_region *region) enum built_in_function start_ix; location_t clause_loc; unsigned int flags_i = 0; - bool oacc_kernels_p = false; switch (gimple_omp_target_kind (entry_stmt)) { @@ -14016,8 +14010,6 @@ expand_omp_target (struct omp_region *region) flags_i |= GOMP_TARGET_FLAG_EXIT_DATA; break; case GF_OMP_TARGET_KIND_OACC_KERNELS: - oacc_kernels_p = true; - /* FALLTHROUGH */ case GF_OMP_TARGET_KIND_OACC_PARALLEL: start_ix = BUILT_IN_GOACC_PARALLEL; break; @@ -14179,10 +14171,8 @@ expand_omp_target (struct omp_region *region) args.quick_push (get_target_arguments (&gsi, entry_stmt)); break; case BUILT_IN_GOACC_PARALLEL: - { - set_oacc_fn_attrib (child_fn, clauses, oacc_kernels_p, &args); - tagging = true; - } + set_oacc_fn_attrib (child_fn, clauses, &args); + tagging = true; /* FALLTHRU */ case BUILT_IN_GOACC_ENTER_EXIT_DATA: case BUILT_IN_GOACC_UPDATE: @@ -20249,7 +20239,6 @@ oacc_validate_dims (tree fn, tree attrs, int *dims, int level, unsigned used) tree purpose[GOMP_DIM_MAX]; unsigned ix; tree pos = TREE_VALUE (attrs); - bool is_kernel = oacc_fn_attrib_kernels_p (attrs); /* Make sure the attribute creator attached the dimension information. */ @@ -20270,7 +20259,8 @@ oacc_validate_dims (tree fn, tree attrs, int *dims, int level, unsigned used) and/or dimensions. */ check = false; #endif - if (!is_kernel && check) + if (check + && !lookup_attribute ("oacc kernels", DECL_ATTRIBUTES (fn))) { static char const *const axes[] = /* Must be kept in sync with GOMP_DIM enumeration. */ @@ -20326,13 +20316,8 @@ oacc_validate_dims (tree fn, tree attrs, int *dims, int level, unsigned used) /* Replace the attribute with new values. */ pos = NULL_TREE; for (ix = GOMP_DIM_MAX; ix--;) - { - pos = tree_cons (purpose[ix], - build_int_cst (integer_type_node, dims[ix]), - pos); - if (is_kernel) - TREE_PUBLIC (pos) = 1; - } + pos = tree_cons (purpose[ix], + build_int_cst (integer_type_node, dims[ix]), pos); replace_oacc_fn_attrib (fn, pos); } } @@ -21191,10 +21176,16 @@ execute_oacc_device_lower () int fn_level = oacc_fn_attrib_level (attrs); if (dump_file) - fprintf (dump_file, oacc_fn_attrib_kernels_p (attrs) - ? "Function is kernels offload\n" - : fn_level < 0 ? "Function is parallel offload\n" - : "Function is routine level %d\n", fn_level); + { + if (fn_level >= 0) + fprintf (dump_file, "Function is OpenACC routine level %d\n", + fn_level); + else if (lookup_attribute ("oacc kernels", + DECL_ATTRIBUTES (current_function_decl))) + fprintf (dump_file, "Function is OpenACC kernels offload\n"); + else + fprintf (dump_file, "Function is OpenACC parallel offload\n"); + } unsigned outer_mask = fn_level >= 0 ? GOMP_DIM_MASK (fn_level) - 1 : 0; unsigned used_mask = oacc_loop_partition (loops, outer_mask); diff --git gcc/omp-low.h gcc/omp-low.h index 2602a12..0ea5308 100644 --- gcc/omp-low.h +++ gcc/omp-low.h @@ -34,8 +34,7 @@ extern void replace_oacc_fn_attrib (tree, tree); extern int verify_oacc_routine_clauses (tree, tree *, location_t, const char *); extern tree build_oacc_routine_dims (tree); extern tree get_oacc_fn_attrib (tree); -extern void set_oacc_fn_attrib (tree, tree, bool, vec<tree> *); -extern bool oacc_fn_attrib_kernels_p (tree); +extern void set_oacc_fn_attrib (tree, tree, vec<tree> *); extern int get_oacc_ifn_dim_arg (const gimple *); extern int get_oacc_fn_dim_size (tree, int); diff --git gcc/testsuite/ChangeLog.gomp gcc/testsuite/ChangeLog.gomp index b5dd1a4..9f2b7be 100644 --- gcc/testsuite/ChangeLog.gomp +++ gcc/testsuite/ChangeLog.gomp @@ -1,5 +1,12 @@ 2017-05-12 Thomas Schwinge <tho...@codesourcery.com> + * c-c++-common/goacc/oaccdevlow-kernels.c: Adjust. + * c-c++-common/goacc/oaccdevlow-parallel.c: Likewise. + * c-c++-common/goacc/oaccdevlow-routine.c: Likewise. + * gfortran.dg/goacc/oaccdevlow-kernels.f95: Likewise. + * gfortran.dg/goacc/oaccdevlow-parallel.f95: Likewise. + * gfortran.dg/goacc/oaccdevlow-routine.f95: Likewise. + * c-c++-common/goacc/classify-kernels-unparallelized.c: New file. * c-c++-common/goacc/classify-kernels.c: Likewise. * c-c++-common/goacc/classify-parallel.c: Likewise. diff --git gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c index a76351c..70ff428 100644 --- gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c +++ gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c @@ -24,16 +24,16 @@ void KERNELS () } /* Check the offloaded function's attributes. - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp target entrypoint\\)\\)" 1 "ompexp" } } */ + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels, omp target entrypoint\\)\\)" 1 "ompexp" } } */ /* Check that exactly one OpenACC kernels construct is analyzed, and that it can't be parallelized. { dg-final { scan-tree-dump-times "FAILED:" 1 "parloops1" } } - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(, , \\), omp target entrypoint\\)\\)" 1 "parloops1" } } + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } { dg-final { scan-tree-dump-not "SUCCESS: may be parallelized" "parloops1" } } */ /* Check the offloaded function's classification and compute dimensions (will always be 1 x 1 x 1 for non-offloading compilation). - { dg-final { scan-tree-dump-times "(?n)Function is kernels offload" 1 "oaccdevlow" } } + { dg-final { scan-tree-dump-times "(?n)Function is OpenACC kernels offload" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } */ + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), oacc kernels, omp target entrypoint\\)\\)" 1 "oaccdevlow" } } */ diff --git gcc/testsuite/c-c++-common/goacc/classify-kernels.c gcc/testsuite/c-c++-common/goacc/classify-kernels.c index 199a73e..c8b0fda 100644 --- gcc/testsuite/c-c++-common/goacc/classify-kernels.c +++ gcc/testsuite/c-c++-common/goacc/classify-kernels.c @@ -20,16 +20,16 @@ void KERNELS () } /* Check the offloaded function's attributes. - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp target entrypoint\\)\\)" 1 "ompexp" } } */ + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels, omp target entrypoint\\)\\)" 1 "ompexp" } } */ /* Check that exactly one OpenACC kernels construct is analyzed, and that it can be parallelized. { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0, , \\), omp target entrypoint\\)\\)" 1 "parloops1" } } + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */ /* Check the offloaded function's classification and compute dimensions (will always be 1 x 1 x 1 for non-offloading compilation). - { dg-final { scan-tree-dump-times "(?n)Function is kernels offload" 1 "oaccdevlow" } } + { dg-final { scan-tree-dump-times "(?n)Function is OpenACC kernels offload" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } - { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } */ + { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), oacc kernels, omp target entrypoint\\)\\)" 1 "oaccdevlow" } } */ diff --git gcc/testsuite/c-c++-common/goacc/classify-parallel.c gcc/testsuite/c-c++-common/goacc/classify-parallel.c index 9d48c1b..4f97301 100644 --- gcc/testsuite/c-c++-common/goacc/classify-parallel.c +++ gcc/testsuite/c-c++-common/goacc/classify-parallel.c @@ -23,6 +23,6 @@ void PARALLEL () /* Check the offloaded function's classification and compute dimensions (will always be 1 x 1 x 1 for non-offloading compilation). - { dg-final { scan-tree-dump-times "(?n)Function is parallel offload" 1 "oaccdevlow" } } + { dg-final { scan-tree-dump-times "(?n)Function is OpenACC parallel offload" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } */ diff --git gcc/testsuite/c-c++-common/goacc/classify-routine.c gcc/testsuite/c-c++-common/goacc/classify-routine.c index d37fb4a..f54c394 100644 --- gcc/testsuite/c-c++-common/goacc/classify-routine.c +++ gcc/testsuite/c-c++-common/goacc/classify-routine.c @@ -25,6 +25,6 @@ void ROUTINE () /* Check the offloaded function's classification and compute dimensions (will always be 1 x 1 x 1 for non-offloading compilation). - { dg-final { scan-tree-dump-times "(?n)Function is routine level 1" 1 "oaccdevlow" } } + { dg-final { scan-tree-dump-times "(?n)Function is OpenACC routine level 1" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0 1, 1 1, 1 1\\), omp declare target \\(worker\\), oacc function \\(0 1, 1 0, 1 0\\)\\)\\)" 1 "oaccdevlow" } } */ diff --git gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95 gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95 index fd46d0d..9887d35 100644 --- gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95 +++ gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95 @@ -26,16 +26,16 @@ program main end program main ! Check the offloaded function's attributes. -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp target entrypoint\\)\\)" 1 "ompexp" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels, omp target entrypoint\\)\\)" 1 "ompexp" } } ! Check that exactly one OpenACC kernels construct is analyzed, and that it ! can't be parallelized. ! { dg-final { scan-tree-dump-times "FAILED:" 1 "parloops1" } } -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(, , \\), omp target entrypoint\\)\\)" 1 "parloops1" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } ! { dg-final { scan-tree-dump-not "SUCCESS: may be parallelized" "parloops1" } } ! Check the offloaded function's classification and compute dimensions (will ! always be 1 x 1 x 1 for non-offloading compilation). -! { dg-final { scan-tree-dump-times "(?n)Function is kernels offload" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)Function is OpenACC kernels offload" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), oacc kernels, omp target entrypoint\\)\\)" 1 "oaccdevlow" } } diff --git gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95 gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95 index 053d27c..69c89a9 100644 --- gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95 +++ gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95 @@ -22,16 +22,16 @@ program main end program main ! Check the offloaded function's attributes. -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp target entrypoint\\)\\)" 1 "ompexp" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels, omp target entrypoint\\)\\)" 1 "ompexp" } } ! Check that exactly one OpenACC kernels construct is analyzed, and that it ! can be parallelized. ! { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0, , \\), omp target entrypoint\\)\\)" 1 "parloops1" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } ! { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } ! Check the offloaded function's classification and compute dimensions (will ! always be 1 x 1 x 1 for non-offloading compilation). -! { dg-final { scan-tree-dump-times "(?n)Function is kernels offload" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)Function is OpenACC kernels offload" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } -! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), oacc kernels, omp target entrypoint\\)\\)" 1 "oaccdevlow" } } diff --git gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95 gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95 index 087ff48..e215c79 100644 --- gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95 +++ gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95 @@ -25,6 +25,6 @@ end program main ! Check the offloaded function's classification and compute dimensions (will ! always be 1 x 1 x 1 for non-offloading compilation). -! { dg-final { scan-tree-dump-times "(?n)Function is parallel offload" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)Function is OpenACC parallel offload" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(1, 1, 1\\), omp target entrypoint\\)\\)" 1 "oaccdevlow" } } diff --git gcc/testsuite/gfortran.dg/goacc/classify-routine.f95 gcc/testsuite/gfortran.dg/goacc/classify-routine.f95 index dd71a84..445ff9a 100644 --- gcc/testsuite/gfortran.dg/goacc/classify-routine.f95 +++ gcc/testsuite/gfortran.dg/goacc/classify-routine.f95 @@ -24,6 +24,6 @@ end subroutine ROUTINE ! Check the offloaded function's classification and compute dimensions (will ! always be 1 x 1 x 1 for non-offloading compilation). -! { dg-final { scan-tree-dump-times "(?n)Function is routine level 1" 1 "oaccdevlow" } } +! { dg-final { scan-tree-dump-times "(?n)Function is OpenACC routine level 1" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } } ! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0 1, 1 1, 1 1\\), omp declare target, oacc function \\(0 1, 1 0, 1 0\\)\\)\\)" 1 "oaccdevlow" } } diff --git gcc/tree-parloops.c gcc/tree-parloops.c index 2e55b79..a94f7a2 100644 --- gcc/tree-parloops.c +++ gcc/tree-parloops.c @@ -2041,10 +2041,13 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data, /* Prepare the GIMPLE_OMP_PARALLEL statement. */ if (oacc_kernels_p) { + gcc_checking_assert (lookup_attribute ("oacc kernels", + DECL_ATTRIBUTES (cfun->decl))); + tree clause = build_omp_clause (loc, OMP_CLAUSE_NUM_GANGS); OMP_CLAUSE_NUM_GANGS_EXPR (clause) = build_int_cst (integer_type_node, n_threads); - set_oacc_fn_attrib (cfun->decl, clause, true, NULL); + set_oacc_fn_attrib (cfun->decl, clause, NULL); } else { diff --git gcc/tree-ssa-loop.c gcc/tree-ssa-loop.c index 06354e3..da9a806 100644 --- gcc/tree-ssa-loop.c +++ gcc/tree-ssa-loop.c @@ -151,10 +151,7 @@ gate_oacc_kernels (function *fn) if (!flag_openacc) return false; - tree oacc_function_attr = get_oacc_fn_attrib (fn->decl); - if (oacc_function_attr == NULL_TREE) - return false; - if (!oacc_fn_attrib_kernels_p (oacc_function_attr)) + if (!lookup_attribute ("oacc kernels", DECL_ATTRIBUTES (fn->decl))) return false; struct loop *loop; Grüße Thomas