summaryrefslogtreecommitdiff
path: root/pstl
diff options
context:
space:
mode:
authorLouis Dionne <ldionne@apple.com>2019-07-08 16:05:00 +0000
committerLouis Dionne <ldionne@apple.com>2019-07-08 16:05:00 +0000
commitb152f9f392d42e1c8e29f382f876480631575190 (patch)
treefb53af7fab4f5993a79880e0dd8804f5f3493139 /pstl
parentb4b21d807e4f47f1f87b05fddf6bb3167b14476e (diff)
downloadllvm-b152f9f392d42e1c8e29f382f876480631575190.tar.gz
[pstl] Use a different namespace for each backend
Also, use a single point of customization to set what namespace __par_backend "points to", which provides a better separation of concerns. llvm-svn: 365337
Diffstat (limited to 'pstl')
-rw-r--r--pstl/include/pstl/internal/algorithm_impl.h4
-rw-r--r--pstl/include/pstl/internal/parallel_backend.h8
-rw-r--r--pstl/include/pstl/internal/parallel_backend_serial.h12
-rw-r--r--pstl/include/pstl/internal/parallel_backend_tbb.h14
-rw-r--r--pstl/include/pstl/internal/parallel_backend_utils.h5
5 files changed, 22 insertions, 21 deletions
diff --git a/pstl/include/pstl/internal/algorithm_impl.h b/pstl/include/pstl/internal/algorithm_impl.h
index a584088add17..a9bf29a6fb27 100644
--- a/pstl/include/pstl/internal/algorithm_impl.h
+++ b/pstl/include/pstl/internal/algorithm_impl.h
@@ -2667,8 +2667,8 @@ __pattern_inplace_merge(_ExecutionPolicy&& __exec, _BidirectionalIterator __firs
[__n, __move_values, __move_sequences](_BidirectionalIterator __f1, _BidirectionalIterator __l1,
_BidirectionalIterator __f2, _BidirectionalIterator __l2, _Tp* __f3,
_Compare __comp) {
- (__par_backend::__serial_move_merge(__n))(__f1, __l1, __f2, __l2, __f3, __comp, __move_values,
- __move_values, __move_sequences, __move_sequences);
+ (__utils::__serial_move_merge(__n))(__f1, __l1, __f2, __l2, __f3, __comp, __move_values, __move_values,
+ __move_sequences, __move_sequences);
return __f3 + (__l1 - __f1) + (__l2 - __f2);
});
__par_backend::__parallel_for(std::forward<_ExecutionPolicy>(__exec), __r, __r + __n,
diff --git a/pstl/include/pstl/internal/parallel_backend.h b/pstl/include/pstl/internal/parallel_backend.h
index c18007e13eb9..134ec502cbab 100644
--- a/pstl/include/pstl/internal/parallel_backend.h
+++ b/pstl/include/pstl/internal/parallel_backend.h
@@ -14,8 +14,16 @@
#if defined(_PSTL_PAR_BACKEND_SERIAL)
# include "parallel_backend_serial.h"
+namespace __pstl
+{
+namespace __par_backend = __serial_backend;
+}
#elif defined(_PSTL_PAR_BACKEND_TBB)
# include "parallel_backend_tbb.h"
+namespace __pstl
+{
+namespace __par_backend = __tbb_backend;
+}
#else
_PSTL_PRAGMA_MESSAGE("Parallel backend was not specified");
#endif
diff --git a/pstl/include/pstl/internal/parallel_backend_serial.h b/pstl/include/pstl/internal/parallel_backend_serial.h
index 5f79f60965b1..969f19931502 100644
--- a/pstl/include/pstl/internal/parallel_backend_serial.h
+++ b/pstl/include/pstl/internal/parallel_backend_serial.h
@@ -20,7 +20,7 @@
namespace __pstl
{
-namespace __serial
+namespace __serial_backend
{
template <typename _Tp>
@@ -126,15 +126,7 @@ __parallel_invoke(_ExecutionPolicy&&, _F1&& __f1, _F2&& __f2)
std::forward<_F2>(__f2)();
}
-} // namespace __serial
-} // namespace __pstl
-
-namespace __pstl
-{
-namespace __par_backend
-{
-using namespace __pstl::__serial;
-}
+} // namespace __serial_backend
} // namespace __pstl
#endif /* _PSTL_PARALLEL_BACKEND_SERIAL_H */
diff --git a/pstl/include/pstl/internal/parallel_backend_tbb.h b/pstl/include/pstl/internal/parallel_backend_tbb.h
index 81b23476e3ad..a32fd995c750 100644
--- a/pstl/include/pstl/internal/parallel_backend_tbb.h
+++ b/pstl/include/pstl/internal/parallel_backend_tbb.h
@@ -32,7 +32,7 @@
namespace __pstl
{
-namespace __par_backend
+namespace __tbb_backend
{
//! Raw memory buffer with automatic freeing and no exceptions.
@@ -875,7 +875,7 @@ tbb::task*
__stable_sort_task<_RandomAccessIterator1, _RandomAccessIterator2, _Compare, _LeafSort>::execute()
{
typedef __merge_task<_RandomAccessIterator1, _RandomAccessIterator2, _Compare, __serial_destroy,
- __serial_move_merge>
+ __utils::__serial_move_merge>
_MergeTaskType;
const _SizeType __n = _M_xe - _M_xs;
@@ -897,10 +897,10 @@ __stable_sort_task<_RandomAccessIterator1, _RandomAccessIterator2, _Compare, _Le
const _RandomAccessIterator1 __xm = _M_xs + __n / 2;
const _RandomAccessIterator2 __zm = _M_zs + (__xm - _M_xs);
const _RandomAccessIterator2 __ze = _M_zs + __n;
- _MergeTaskType* __m = new (allocate_continuation())
- _MergeTaskType(_M_xs - _M_x_beg, __xm - _M_x_beg, __xm - _M_x_beg, _M_xe - _M_x_beg, _M_zs - _M_z_beg, _M_comp,
- __serial_destroy(), __serial_move_merge(__nmerge), _M_nsort, _M_x_beg, _M_z_beg,
- /*x_orig*/ true, /*y_orig*/ true, /*root*/ _M_root);
+ _MergeTaskType* __m = new (allocate_continuation()) _MergeTaskType(
+ _M_xs - _M_x_beg, __xm - _M_x_beg, __xm - _M_x_beg, _M_xe - _M_x_beg, _M_zs - _M_z_beg, _M_comp,
+ __utils::__serial_destroy(), __utils::__serial_move_merge(__nmerge), _M_nsort, _M_x_beg, _M_z_beg,
+ /*x_orig*/ true, /*y_orig*/ true, /*root*/ _M_root);
_M_root = false;
@@ -1049,7 +1049,7 @@ __parallel_invoke(_ExecutionPolicy&&, _F1&& __f1, _F2&& __f2)
tbb::this_task_arena::isolate([&]() { tbb::parallel_invoke(std::forward<_F1>(__f1), std::forward<_F2>(__f2)); });
}
-} // namespace __par_backend
+} // namespace __tbb_backend
} // namespace __pstl
#endif /* _PSTL_PARALLEL_BACKEND_TBB_H */
diff --git a/pstl/include/pstl/internal/parallel_backend_utils.h b/pstl/include/pstl/internal/parallel_backend_utils.h
index cd4f72b1967f..ced49631c7b6 100644
--- a/pstl/include/pstl/internal/parallel_backend_utils.h
+++ b/pstl/include/pstl/internal/parallel_backend_utils.h
@@ -19,7 +19,8 @@
namespace __pstl
{
-namespace __par_backend
+
+namespace __utils
{
//! Destroy sequence [xs,xe)
@@ -219,7 +220,7 @@ class __stack
}
};
-} // namespace __par_backend
+} // namespace __utils
} // namespace __pstl
#endif /* _PSTL_PARALLEL_BACKEND_UTILS_H */