From 8f5cb64c7147c27953933dbaea107454ff066ed1 Mon Sep 17 00:00:00 2001 From: Mikhail Dvorskiy Date: Wed, 27 Oct 2021 18:51:36 +0300 Subject: [pstl] A hot fix for a reduction parallel pattern of OpenMP backend Reviewed By: nadiasvertex, ldionne Differential Revision: https://reviews.llvm.org/D112125 --- pstl/include/pstl/internal/omp/parallel_reduce.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pstl') diff --git a/pstl/include/pstl/internal/omp/parallel_reduce.h b/pstl/include/pstl/internal/omp/parallel_reduce.h index 71fc8a261bbd..f0b5afc459f5 100644 --- a/pstl/include/pstl/internal/omp/parallel_reduce.h +++ b/pstl/include/pstl/internal/omp/parallel_reduce.h @@ -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( -- cgit v1.2.1