[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 00:58:29 PDT 2021


MikeDvorskiy created this revision.
MikeDvorskiy added a reviewer: ldionne.
Herald added subscribers: guansong, yaxunl.
MikeDvorskiy requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: libcxx-commits, sstefan1.
Herald added a project: libc++.
Herald added a reviewer: libc++.

A hot fix for OpenMP backend; + "exit" condition for recursion of "__parallel_reduce_body"


Repository:
  rG LLVM Github Monorepo

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.380867.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211020/01402ccf/attachment.bin>


More information about the libcxx-commits mailing list