[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 04:53:04 PDT 2021


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

A hot performance fix for parallel reduce pattern of OpenMP backend. The recursion should be limited by a gain size - __default_chunk_size.


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


More information about the libcxx-commits mailing list