[Openmp-commits] [openmp] a619072 - [OpenMP] Manually unroll the argument copy loop

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Mon Mar 21 17:54:23 PDT 2022


Author: Joseph Huber
Date: 2022-03-21T20:54:11-04:00
New Revision: a619072c6189a2eac82e30d5ebb5946cb1297281

URL: https://github.com/llvm/llvm-project/commit/a619072c6189a2eac82e30d5ebb5946cb1297281
DIFF: https://github.com/llvm/llvm-project/commit/a619072c6189a2eac82e30d5ebb5946cb1297281.diff

LOG: [OpenMP] Manually unroll the argument copy loop

The unroll pragma did not properly work as the loop bound was not known
when we optimize the runtime and we then added a "unroll disable"
metadata which prevented unrolling later when the bounds were known.
For now we manually unroll to make sure up to 16 elements are handled
nicely. This helps optimizations to look through the argument passing.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D109164

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/src/Parallelism.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp b/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp
index 4ce24937d26ee..5584f34e63ed7 100644
--- a/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp
@@ -151,9 +151,62 @@ void __kmpc_parallel_51(IdentTy *ident, int32_t, int32_t if_expr,
   void **GlobalArgs = nullptr;
   if (nargs) {
     __kmpc_begin_sharing_variables(&GlobalArgs, nargs);
-#pragma unroll
-    for (int I = 0; I < nargs; I++)
-      GlobalArgs[I] = args[I];
+    switch (nargs) {
+    default:
+      for (int I = 0; I < nargs; I++)
+        GlobalArgs[I] = args[I];
+      break;
+    case 16:
+      GlobalArgs[15] = args[15];
+      // FALLTHROUGH
+    case 15:
+      GlobalArgs[14] = args[14];
+      // FALLTHROUGH
+    case 14:
+      GlobalArgs[13] = args[13];
+      // FALLTHROUGH
+    case 13:
+      GlobalArgs[12] = args[12];
+      // FALLTHROUGH
+    case 12:
+      GlobalArgs[11] = args[11];
+      // FALLTHROUGH
+    case 11:
+      GlobalArgs[10] = args[10];
+      // FALLTHROUGH
+    case 10:
+      GlobalArgs[9] = args[9];
+      // FALLTHROUGH
+    case 9:
+      GlobalArgs[8] = args[8];
+      // FALLTHROUGH
+    case 8:
+      GlobalArgs[7] = args[7];
+      // FALLTHROUGH
+    case 7:
+      GlobalArgs[6] = args[6];
+      // FALLTHROUGH
+    case 6:
+      GlobalArgs[5] = args[5];
+      // FALLTHROUGH
+    case 5:
+      GlobalArgs[4] = args[4];
+      // FALLTHROUGH
+    case 4:
+      GlobalArgs[3] = args[3];
+      // FALLTHROUGH
+    case 3:
+      GlobalArgs[2] = args[2];
+      // FALLTHROUGH
+    case 2:
+      GlobalArgs[1] = args[1];
+      // FALLTHROUGH
+    case 1:
+      GlobalArgs[0] = args[0];
+      // FALLTHROUGH
+    case 0:
+      break;
+    }
   }
 
   {


        


More information about the Openmp-commits mailing list