[Openmp-commits] [PATCH] D11988: Force serial reduction when team size == 1

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 12 13:04:52 PDT 2015


jlpeyton created this revision.
jlpeyton added a reviewer: hfinkel.
jlpeyton added a subscriber: openmp-commits.
jlpeyton set the repository for this revision to rL LLVM.

This change enforces the use of the serial reduction method when the team size is 1 even if KMP_FORCE_REDUCTION is set.  Using the serial reduction method avoids unnecessary synchronization and should always be used when the team size is 1.

Repository:
  rL LLVM

http://reviews.llvm.org/D11988

Files:
  runtime/src/kmp_runtime.c

Index: runtime/src/kmp_runtime.c
===================================================================
--- runtime/src/kmp_runtime.c
+++ runtime/src/kmp_runtime.c
@@ -7640,7 +7640,9 @@
 
     // KMP_FORCE_REDUCTION
 
-    if( __kmp_force_reduction_method != reduction_method_not_defined ) {
+    // If the team is serialized (team_size == 1), ignore the forced reduction
+    // method and stay with the unsynchronized method (empty_reduce_block)
+    if( __kmp_force_reduction_method != reduction_method_not_defined && team_size != 1) {
 
         PACKED_REDUCTION_METHOD_T forced_retval;
 
@@ -7650,9 +7652,6 @@
         {
             case critical_reduce_block:
                 KMP_ASSERT( lck );              // lck should be != 0
-                if( team_size <= 1 ) {
-                    forced_retval = empty_reduce_block;
-                }
                 break;
 
             case atomic_reduce_block:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11988.31972.patch
Type: text/x-patch
Size: 916 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20150812/1907d36f/attachment.bin>


More information about the Openmp-commits mailing list