[libcxx-commits] [PATCH] D112125: A hot fix for a reduction parallel pattern of OpenMP backend

Mikhail Dvorskiy via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 20 02:28:01 PDT 2021


MikeDvorskiy updated this revision to Diff 380881.
MikeDvorskiy added a comment.

clang format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112125/new/

https://reviews.llvm.org/D112125

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


Index: pstl/include/pstl/internal/omp/parallel_reduce.h
===================================================================
--- pstl/include/pstl/internal/omp/parallel_reduce.h
+++ pstl/include/pstl/internal/omp/parallel_reduce.h
@@ -23,6 +23,9 @@
 __parallel_reduce_body(_RandomAccessIterator __first, _RandomAccessIterator __last, _Value __identity,
                        _RealBody __real_body, _Reduction __reduce)
 {
+    if (__last - __first < 2)
+        return __real_body(__first, __last, __identity);
+
     auto __middle = __first + ((__last - __first) / 2);
     _Value __v1(__identity), __v2(__identity);
     __parallel_invoke_body(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112125.380881.patch
Type: text/x-patch
Size: 648 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211020/2f098aa9/attachment.bin>


More information about the libcxx-commits mailing list