Skip to content

Commit

Permalink
[pstl] A hot fix for a reduction parallel pattern of OpenMP backend
Browse files Browse the repository at this point in the history
Reviewed By: nadiasvertex, ldionne

Differential Revision: https://reviews.llvm.org/D112125
  • Loading branch information
MikeDvorskiy committed Oct 27, 2021
1 parent 64d1617 commit 8f5cb64
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pstl/include/pstl/internal/omp/parallel_reduce.h
Expand Up @@ -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(
Expand Down

0 comments on commit 8f5cb64

Please sign in to comment.