[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 27 08:53:06 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f5cb64c7147: [pstl] A hot fix for a reduction parallel pattern of OpenMP backend (authored by MikeDvorskiy).

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,11 @@
 __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(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112125.382685.patch
Type: text/x-patch
Size: 679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211027/ac1be9bb/attachment-0001.bin>


More information about the libcxx-commits mailing list