]> 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)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Thu, 22 Apr 2021 17:14:25 +0000 (10:14 -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 d1b0640c9eaff30e47a7b82685272d5a873ad0a3..500a58e5fd32775cff0c66e17f0db0b41f4b7c13 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-06-06  Kwok Cheung Yeung  <kcy@codesourcery.com>
 
        * omp-sese.c (oacc_build_component_ref): Apply address space of
index 21e9b923443ef0e74a4bd413995a43c72850f18f..22bb3ac1c407ad9c9f0bf38e69d1e7d4bfe2f81a 100644 (file)
@@ -2400,7 +2400,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 *)