]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Allow gang-level reductions in OpenACC routines with gang-level parallelism
authorKwok Cheung Yeung <kcy@codesourcery.com>
Thu, 19 Mar 2020 16:44:18 +0000 (09:44 -0700)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Thu, 22 Apr 2021 17:14:22 +0000 (10:14 -0700)
2020-03-19  Kwok Cheung Yeung  <kcy@codesourcery.com>

gcc/
* omp-offload.c (oacc_loop_auto_partitions): Check for 'omp declare
target' attributes with a gang clause attached.

gcc/ChangeLog.omp
gcc/omp-offload.c

index bd5d7de4cd7b7c9222cd4d20eab44f522e556574..301a9ece91b6953de203cf42f515495df8bca598 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-19  Kwok Cheung Yeung  <kcy@codesourcery.com>
+
+       * omp-offload.c (oacc_loop_auto_partitions): Check for 'omp declare
+       target' attributes with a gang clause attached.
+
 2020-03-16  Tobias Burnus  <tobias@codesourcery.com>
 
        * omp-oacc-kernels-decompose.cc (maybe_build_inner_data_region):
index b10047b96d2b43ccd0d49b31a2b1c8ed3846ab36..21e9b923443ef0e74a4bd413995a43c72850f18f 100644 (file)
@@ -1620,10 +1620,28 @@ oacc_loop_auto_partitions (oacc_loop *loop, unsigned outer_mask,
 
       /* Orphan reductions cannot have gang partitioning.  */
       if ((loop->flags & OLF_REDUCTION)
-         && oacc_get_fn_attrib (current_function_decl)
-         && !lookup_attribute ("omp target entrypoint",
+         && oacc_get_fn_attrib (current_function_decl))
+       {
+         bool gang_p = false;
+         tree attr
+             = lookup_attribute ("omp declare target",
+                                 DECL_ATTRIBUTES (current_function_decl));
+
+         if (attr)
+           for (tree c = TREE_VALUE (attr); c; c = OMP_CLAUSE_CHAIN (c))
+             if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_GANG)
+               {
+                 gang_p = true;
+                 break;
+               }
+
+         if (lookup_attribute ("omp target entrypoint",
                                DECL_ATTRIBUTES (current_function_decl)))
-       this_mask = GOMP_DIM_MASK (GOMP_DIM_WORKER);
+           gang_p = true;
+
+         if (!gang_p)
+           this_mask = GOMP_DIM_MASK (GOMP_DIM_WORKER);
+       }
 
       /* Find the first outermost available partition. */
       while (this_mask <= outer_mask)