[Openmp-commits] [PATCH] D20699: Addition of schedule(simd:static)

Terry Wilmarth via Openmp-commits openmp-commits at lists.llvm.org
Thu May 26 13:06:27 PDT 2016


tlwilmar created this revision.
tlwilmar added reviewers: AndreyChurbanov, jlpeyton.
tlwilmar added subscribers: openmp-commits, ABataev.
tlwilmar set the repository for this revision to rL LLVM.

This patch implements the new kmp_sch_static_balanced_chunked schedule kind that the compiler will generate when it encounters schedule(simd: static). It just adds the new constant and the new switch case __kmp_for_static_init.

Patch by Alex Duran.

Repository:
  rL LLVM

http://reviews.llvm.org/D20699

Files:
  runtime/src/kmp.h
  runtime/src/kmp_sched.cpp

Index: runtime/src/kmp_sched.cpp
===================================================================
--- runtime/src/kmp_sched.cpp
+++ runtime/src/kmp_sched.cpp
@@ -324,6 +324,29 @@
                 *plastiter = (tid == ((trip_count - 1)/( UT )chunk) % nth);
             break;
         }
+#if OMP_41_ENABLED
+    case kmp_sch_static_balanced_chunked:
+        {
+            register T old_upper = *pupper;
+            // round up to make sure the chunk is enough to cover all iterations
+            register UT span = (trip_count+nth-1) / nth;
+
+            // perform chunk adjustment
+            chunk = (span + chunk - 1) & ~(chunk-1);
+
+            span = chunk * incr;
+            *plower = *plower + (span * tid);
+            *pupper = *plower + span - incr;
+            if ( incr > 0 ) {
+              if ( *pupper > old_upper ) *pupper = old_upper;
+            } else
+              if ( *pupper < old_upper ) *pupper = old_upper;
+
+            if( plastiter != NULL )
+                *plastiter = ( tid == ((trip_count - 1)/( UT )chunk) );
+            break;
+        }
+#endif
     default:
         KMP_ASSERT2( 0, "__kmpc_for_static_init: unknown scheduling type" );
         break;
Index: runtime/src/kmp.h
===================================================================
--- runtime/src/kmp.h
+++ runtime/src/kmp.h
@@ -317,8 +317,12 @@
 
     kmp_sch_static_steal              = 44,   /**< accessible only through KMP_SCHEDULE environment variable */
 
+#if OMP_41_ENABLED
+    kmp_sch_static_balanced_chunked   = 45,   /**< static with chunk adjustment (e.g., simd) */
+#endif
+
     /* accessible only through KMP_SCHEDULE environment variable */
-    kmp_sch_upper                     = 45,   /**< upper bound for unordered values */
+    kmp_sch_upper                     = 46,   /**< upper bound for unordered values */
 
     kmp_ord_lower                     = 64,   /**< lower bound for ordered values, must be power of 2 */
     kmp_ord_static_chunked            = 65,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20699.58674.patch
Type: text/x-patch
Size: 2011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20160526/6dc3a9ca/attachment.bin>


More information about the Openmp-commits mailing list