[libcxx-commits] [pstl] 8f5cb64 - [pstl] A hot fix for a reduction parallel pattern of OpenMP backend

Mikhail Dvorskiy via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 27 08:52:55 PDT 2021


Author: Mikhail Dvorskiy
Date: 2021-10-27T18:52:41+03:00
New Revision: 8f5cb64c7147c27953933dbaea107454ff066ed1

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

LOG: [pstl] A hot fix for a reduction parallel pattern of OpenMP backend

Reviewed By: nadiasvertex, ldionne

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

Added: 
    

Modified: 
    pstl/include/pstl/internal/omp/parallel_reduce.h

Removed: 
    


################################################################################
diff  --git a/pstl/include/pstl/internal/omp/parallel_reduce.h b/pstl/include/pstl/internal/omp/parallel_reduce.h
index 71fc8a261bbd8..f0b5afc459f52 100644
--- a/pstl/include/pstl/internal/omp/parallel_reduce.h
+++ b/pstl/include/pstl/internal/omp/parallel_reduce.h
@@ -23,6 +23,11 @@ _Value
 __parallel_reduce_body(_RandomAccessIterator __first, _RandomAccessIterator __last, _Value __identity,
                        _RealBody __real_body, _Reduction __reduce)
 {
+    if (__should_run_serial(__first, __last))
+    {
+        return __real_body(__first, __last, __identity);
+    }
+
     auto __middle = __first + ((__last - __first) / 2);
     _Value __v1(__identity), __v2(__identity);
     __parallel_invoke_body(


        


More information about the libcxx-commits mailing list