From 05a4b0d605f3b7fa7924ce5660b8928b2e05e299 Mon Sep 17 00:00:00 2001 From: Mikhail Dvorskiy Date: Fri, 22 Oct 2021 18:58:06 +0300 Subject: [PATCH] [pstl] A hot compilation fix for MacOS, OpenMP backend; + full qualified names for some internal functions Reviewed By: nadiasvertex, ldionne Differential Revision: https://reviews.llvm.org/D112528 --- pstl/include/pstl/internal/omp/parallel_for.h | 2 +- pstl/include/pstl/internal/omp/parallel_invoke.h | 4 ++-- pstl/include/pstl/internal/omp/parallel_merge.h | 12 +++++++---- .../pstl/internal/omp/parallel_stable_sort.h | 24 ++++++++++++---------- .../pstl/internal/omp/parallel_transform_reduce.h | 2 +- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/pstl/include/pstl/internal/omp/parallel_for.h b/pstl/include/pstl/internal/omp/parallel_for.h index 171b841..729f26f 100644 --- a/pstl/include/pstl/internal/omp/parallel_for.h +++ b/pstl/include/pstl/internal/omp/parallel_for.h @@ -31,7 +31,7 @@ __parallel_for_body(_Index __first, _Index __last, _Fp __f) _PSTL_PRAGMA(omp taskloop untied mergeable) for (std::size_t __chunk = 0; __chunk < __policy.__n_chunks; ++__chunk) { - __omp_backend::__process_chunk(__policy, __first, __chunk, __f); + __pstl::__omp_backend::__process_chunk(__policy, __first, __chunk, __f); } } diff --git a/pstl/include/pstl/internal/omp/parallel_invoke.h b/pstl/include/pstl/internal/omp/parallel_invoke.h index f9afe13..0db8677 100644 --- a/pstl/include/pstl/internal/omp/parallel_invoke.h +++ b/pstl/include/pstl/internal/omp/parallel_invoke.h @@ -35,13 +35,13 @@ __parallel_invoke(_ExecutionPolicy&&, _F1&& __f1, _F2&& __f2) { if (omp_in_parallel()) { - __parallel_invoke_body(std::forward<_F1>(__f1), std::forward<_F2>(__f2)); + __pstl::__omp_backend::__parallel_invoke_body(std::forward<_F1>(__f1), std::forward<_F2>(__f2)); } else { _PSTL_PRAGMA(omp parallel) _PSTL_PRAGMA(omp single nowait) - __parallel_invoke_body(std::forward<_F1>(__f1), std::forward<_F2>(__f2)); + __pstl::__omp_backend::__parallel_invoke_body(std::forward<_F1>(__f1), std::forward<_F2>(__f2)); } } diff --git a/pstl/include/pstl/internal/omp/parallel_merge.h b/pstl/include/pstl/internal/omp/parallel_merge.h index 869b7c9..23feb9e 100644 --- a/pstl/include/pstl/internal/omp/parallel_merge.h +++ b/pstl/include/pstl/internal/omp/parallel_merge.h @@ -50,11 +50,13 @@ __parallel_merge_body(std::size_t __size_x, std::size_t __size_y, _RandomAccessI _PSTL_PRAGMA(omp task untied mergeable default(none) firstprivate(__xs, __xm, __ys, __ym, __zs, __comp, __leaf_merge)) - __parallel_merge_body(__xm - __xs, __ym - __ys, __xs, __xm, __ys, __ym, __zs, __comp, __leaf_merge); + __pstl::__omp_backend::__parallel_merge_body(__xm - __xs, __ym - __ys, __xs, __xm, __ys, __ym, __zs, __comp, + __leaf_merge); _PSTL_PRAGMA(omp task untied mergeable default(none) firstprivate(__xm, __xe, __ym, __ye, __zm, __comp, __leaf_merge)) - __parallel_merge_body(__xe - __xm, __ye - __ym, __xm, __xe, __ym, __ye, __zm, __comp, __leaf_merge); + __pstl::__omp_backend::__parallel_merge_body(__xe - __xm, __ye - __ym, __xm, __xe, __ym, __ye, __zm, __comp, + __leaf_merge); _PSTL_PRAGMA(omp taskwait) } @@ -77,14 +79,16 @@ __parallel_merge(_ExecutionPolicy&& /*__exec*/, _RandomAccessIterator1 __xs, _Ra if (omp_in_parallel()) { - __parallel_merge_body(__size_x, __size_y, __xs, __xe, __ys, __ye, __zs, __comp, __leaf_merge); + __pstl::__omp_backend::__parallel_merge_body(__size_x, __size_y, __xs, __xe, __ys, __ye, __zs, __comp, + __leaf_merge); } else { _PSTL_PRAGMA(omp parallel) { _PSTL_PRAGMA(omp single nowait) - __parallel_merge_body(__size_x, __size_y, __xs, __xe, __ys, __ye, __zs, __comp, __leaf_merge); + __pstl::__omp_backend::__parallel_merge_body(__size_x, __size_y, __xs, __xe, __ys, __ye, __zs, __comp, + __leaf_merge); } } } diff --git a/pstl/include/pstl/internal/omp/parallel_stable_sort.h b/pstl/include/pstl/internal/omp/parallel_stable_sort.h index cda9d23..6f9dce5 100644 --- a/pstl/include/pstl/internal/omp/parallel_stable_sort.h +++ b/pstl/include/pstl/internal/omp/parallel_stable_sort.h @@ -12,6 +12,7 @@ #define _PSTL_INTERNAL_OMP_PARALLEL_STABLE_SORT_H #include "util.h" +#include "parallel_merge.h" namespace __pstl { @@ -44,12 +45,12 @@ __parallel_move_range(_RandomAccessIterator __first1, _RandomAccessIterator __la } // Perform parallel moving of larger chunks - auto __policy = __omp_backend::__chunk_partitioner(__first1, __last1); + auto __policy = __pstl::__omp_backend::__chunk_partitioner(__first1, __last1); _PSTL_PRAGMA(omp taskloop) for (std::size_t __chunk = 0; __chunk < __policy.__n_chunks; ++__chunk) { - __omp_backend::__process_chunk(__policy, __first1, __chunk, + __pstl::__omp_backend::__process_chunk(__policy, __first1, __chunk, [&](auto __chunk_first, auto __chunk_last) { auto __chunk_offset = __chunk_first - __first1; @@ -67,7 +68,7 @@ struct __move_range _OutputIterator operator()(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _OutputIterator __d_first) const { - return __parallel_move_range(__first1, __last1, __d_first); + return __pstl::__omp_backend::__sort_details::__parallel_move_range(__first1, __last1, __d_first); } }; } // namespace __sort_details @@ -91,15 +92,16 @@ __parallel_stable_sort_body(_RandomAccessIterator __xs, _RandomAccessIterator __ { std::size_t __size = __xe - __xs; auto __mid = __xs + (__size / 2); - __parallel_invoke_body([&]() { __parallel_stable_sort_body(__xs, __mid, __comp, __leaf_sort); }, - [&]() { __parallel_stable_sort_body(__mid, __xe, __comp, __leaf_sort); }); + __pstl::__omp_backend::__parallel_invoke_body( + [&]() { __parallel_stable_sort_body(__xs, __mid, __comp, __leaf_sort); }, + [&]() { __parallel_stable_sort_body(__mid, __xe, __comp, __leaf_sort); }); // Perform a parallel merge of the sorted ranges into __output_data. _VecType __output_data(__size); _MoveValue __move_value; _MoveRange __move_range; __utils::__serial_move_merge __merge(__size); - __parallel_merge_body( + __pstl::__omp_backend::__parallel_merge_body( __mid - __xs, __xe - __mid, __xs, __mid, __mid, __xe, __output_data.begin(), __comp, [&__merge, &__move_value, &__move_range](_RandomAccessIterator __as, _RandomAccessIterator __ae, _RandomAccessIterator __bs, _RandomAccessIterator __be, @@ -107,7 +109,7 @@ __parallel_stable_sort_body(_RandomAccessIterator __xs, _RandomAccessIterator __ { __merge(__as, __ae, __bs, __be, __cs, __comp, __move_value, __move_value, __move_range, __move_range); }); // Move the values from __output_data back in the original source range. - __omp_backend::__sort_details::__parallel_move_range(__output_data.begin(), __output_data.end(), __xs); + __pstl::__omp_backend::__sort_details::__parallel_move_range(__output_data.begin(), __output_data.end(), __xs); } } @@ -130,11 +132,11 @@ __parallel_stable_sort(_ExecutionPolicy&& /*__exec*/, _RandomAccessIterator __xs { if (__count <= __nsort) { - __parallel_stable_sort_body(__xs, __xe, __comp, __leaf_sort); + __pstl::__omp_backend::__parallel_stable_sort_body(__xs, __xe, __comp, __leaf_sort); } else { - __parallel_stable_partial_sort(__xs, __xe, __comp, __leaf_sort, __nsort); + __pstl::__omp_backend::__parallel_stable_partial_sort(__xs, __xe, __comp, __leaf_sort, __nsort); } } else @@ -143,11 +145,11 @@ __parallel_stable_sort(_ExecutionPolicy&& /*__exec*/, _RandomAccessIterator __xs _PSTL_PRAGMA(omp single nowait) if (__count <= __nsort) { - __parallel_stable_sort_body(__xs, __xe, __comp, __leaf_sort); + __pstl::__omp_backend::__parallel_stable_sort_body(__xs, __xe, __comp, __leaf_sort); } else { - __parallel_stable_partial_sort(__xs, __xe, __comp, __leaf_sort, __nsort); + __pstl::__omp_backend::__parallel_stable_partial_sort(__xs, __xe, __comp, __leaf_sort, __nsort); } } } diff --git a/pstl/include/pstl/internal/omp/parallel_transform_reduce.h b/pstl/include/pstl/internal/omp/parallel_transform_reduce.h index 72ea37f..e742287 100644 --- a/pstl/include/pstl/internal/omp/parallel_transform_reduce.h +++ b/pstl/include/pstl/internal/omp/parallel_transform_reduce.h @@ -60,7 +60,7 @@ __transform_reduce_body(_RandomAccessIterator __first, _RandomAccessIterator __l _PSTL_PRAGMA(omp taskloop shared(__accums)) for (std::size_t __chunk = 0; __chunk < __policy.__n_chunks; ++__chunk) { - __omp_backend::__process_chunk(__policy, __first + __num_threads, __chunk, + __pstl::__omp_backend::__process_chunk(__policy, __first + __num_threads, __chunk, [&](auto __chunk_first, auto __chunk_last) { auto __thread_num = omp_get_thread_num(); -- 2.7.4