]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/omp-offload.c
[PR middle-end/69921] Use "oacc kernels parallelized" attribute for parallelized...
[thirdparty/gcc.git] / gcc / omp-offload.c
index d24f1317a3f48fe3ec92db618f76b3e6ebb36756..9372f9e06110df2235e530413d5cc97ee52f8bb5 100644 (file)
@@ -1444,6 +1444,13 @@ execute_oacc_device_lower ()
       flag_openacc_dims = (char *)&flag_openacc_dims;
     }
 
+  bool is_oacc_kernels
+    = (lookup_attribute ("oacc kernels",
+                        DECL_ATTRIBUTES (current_function_decl)) != NULL);
+  bool is_oacc_kernels_parallelized
+    = (lookup_attribute ("oacc kernels parallelized",
+                        DECL_ATTRIBUTES (current_function_decl)) != NULL);
+
   /* Discover, partition and process the loops.  */
   oacc_loop *loops = oacc_loop_discovery ();
   int fn_level = oacc_fn_attrib_level (attrs);
@@ -1453,17 +1460,26 @@ execute_oacc_device_lower ()
       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 if (is_oacc_kernels)
+       fprintf (dump_file, "Function is %s OpenACC kernels offload\n",
+                (is_oacc_kernels_parallelized
+                 ? "parallelized" : "unparallelized"));
       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);
-  int dims[GOMP_DIM_MAX];
+  /* OpenACC kernels constructs are special: they currently don't use the
+     generic oacc_loop infrastructure and attribute/dimension processing.  */
+  if (is_oacc_kernels && is_oacc_kernels_parallelized)
+    {
+      /* Parallelized OpenACC kernels constructs use gang parallelism.  See
+        also tree-parloops.c:create_parallel_loop.  */
+      used_mask |= GOMP_DIM_MASK (GOMP_DIM_GANG);
+    }
 
+  int dims[GOMP_DIM_MAX];
   oacc_validate_dims (current_function_decl, attrs, dims, fn_level, used_mask);
 
   if (dump_file)