]> 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>
Tue, 9 Jun 2020 22:32:09 +0000 (15:32 -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 5db79be770030477aa68b83ec034c2095ea75089..7c4a32a153e0fa137a82ec2b040caedf8d6e10af 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.c (maybe_build_inner_data_region): is_gimple_reg vars
index 638bf6bea73a7f3db90c8c7affd28166fd790007..9a67287747303a9be7e0f69c102bf4999ae0bb49 100644 (file)
@@ -1386,14 +1386,32 @@ oacc_loop_auto_partitions (oacc_loop *loop, unsigned outer_mask,
 
       /* Gang partitioning is not available in a gang-single region.  */
       if (is_oacc_gang_single)
-        this_mask = GOMP_DIM_MASK (GOMP_DIM_WORKER);
+       this_mask = GOMP_DIM_MASK (GOMP_DIM_WORKER);
 
       /* 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)