]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openacc: Turn off worker partitioning if num_workers==1
authorJulian Brown <julian@codesourcery.com>
Mon, 20 Jan 2020 19:42:28 +0000 (11:42 -0800)
committerJulian Brown <julian@codesourcery.com>
Wed, 15 Jul 2020 17:20:01 +0000 (10:20 -0700)
This patch turns off the middle-end worker-partitioning support if the
number of workers for an outlined offload function is one.  In that case,
we do not need to perform the broadcasting/neutering code transformation.

2020-07-15  Julian Brown  <julian@codesourcery.com>

gcc/
* omp-offload.c (pass_oacc_gimple_workers::gate): Disable worker
partitioning if num_workers is 1.

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

index 8ceb7af771243b6bb002a6b2da5d9e33b8b94462..b1553758db23f40052b7b3d81251380451657e90 100644 (file)
@@ -1,3 +1,8 @@
+2020-07-15  Julian Brown  <julian@codesourcery.com>
+
+       * omp-offload.c (pass_oacc_gimple_workers::gate): Disable worker
+       partitioning if num_workers is 1.
+
 2020-07-15  Julian Brown  <julian@codesourcery.com>
 
        * config/gcn/mkoffload.c (process_asm): Initialise regcount.  Update
index bf72782ba4ce3727d1b25902fd430ad1ad3f3cdf..2b730d0577812c6bdb4daa82bf28edb87b0f1c2a 100644 (file)
@@ -2165,7 +2165,20 @@ public:
   /* opt_pass methods: */
   virtual bool gate (function *)
   {
-    return flag_openacc && targetm.goacc.worker_partitioning;
+    if (!flag_openacc || !targetm.goacc.worker_partitioning)
+      return false;
+
+    tree attr = oacc_get_fn_attrib (current_function_decl);
+
+    if (!attr)
+      /* Not an offloaded function.  */
+      return false;
+
+    int worker_dim
+      = oacc_get_fn_dim_size (current_function_decl, GOMP_DIM_WORKER);
+
+    /* No worker partitioning if we know the number of workers is 1.  */
+    return worker_dim != 1;
   };
 
   virtual unsigned int execute (function *)