[libcxx-commits] [pstl] 05a4b0d - [pstl] A hot compilation fix for MacOS, OpenMP backend; + full qualified names for some internal functions

Mikhail Dvorskiy via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 27 03:10:14 PDT 2021


Author: Mikhail Dvorskiy
Date: 2021-10-27T13:09:57+03:00
New Revision: 05a4b0d605f3b7fa7924ce5660b8928b2e05e299

URL: https://github.com/llvm/llvm-project/commit/05a4b0d605f3b7fa7924ce5660b8928b2e05e299
DIFF: https://github.com/llvm/llvm-project/commit/05a4b0d605f3b7fa7924ce5660b8928b2e05e299.diff

LOG: [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

Added: 
    

Modified: 
    pstl/include/pstl/internal/omp/parallel_for.h
    pstl/include/pstl/internal/omp/parallel_invoke.h
    pstl/include/pstl/internal/omp/parallel_merge.h
    pstl/include/pstl/internal/omp/parallel_stable_sort.h
    pstl/include/pstl/internal/omp/parallel_transform_reduce.h

Removed: 
    


################################################################################
diff  --git a/pstl/include/pstl/internal/omp/parallel_for.h b/pstl/include/pstl/internal/omp/parallel_for.h
index 171b8419a9f03..729f26f531428 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 f9afe13dc1a4b..0db8677798f86 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 869b7c9322b16..23feb9e9ef82f 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 cda9d23594626..6f9dce528960c 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 72ea37f5faebe..e7422872eab24 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();


        


More information about the libcxx-commits mailing list