[libcxx-commits] [pstl] r365337 - [pstl] Use a different namespace for each backend
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jul 8 09:05:01 PDT 2019
Author: ldionne
Date: Mon Jul 8 09:05:00 2019
New Revision: 365337
URL: http://llvm.org/viewvc/llvm-project?rev=365337&view=rev
Log:
[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.
Modified:
pstl/trunk/include/pstl/internal/algorithm_impl.h
pstl/trunk/include/pstl/internal/parallel_backend.h
pstl/trunk/include/pstl/internal/parallel_backend_serial.h
pstl/trunk/include/pstl/internal/parallel_backend_tbb.h
pstl/trunk/include/pstl/internal/parallel_backend_utils.h
Modified: pstl/trunk/include/pstl/internal/algorithm_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/algorithm_impl.h?rev=365337&r1=365336&r2=365337&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/algorithm_impl.h (original)
+++ pstl/trunk/include/pstl/internal/algorithm_impl.h Mon Jul 8 09:05:00 2019
@@ -2667,8 +2667,8 @@ __pattern_inplace_merge(_ExecutionPolicy
[__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,
Modified: pstl/trunk/include/pstl/internal/parallel_backend.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/parallel_backend.h?rev=365337&r1=365336&r2=365337&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/parallel_backend.h (original)
+++ pstl/trunk/include/pstl/internal/parallel_backend.h Mon Jul 8 09:05:00 2019
@@ -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
Modified: pstl/trunk/include/pstl/internal/parallel_backend_serial.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/parallel_backend_serial.h?rev=365337&r1=365336&r2=365337&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/parallel_backend_serial.h (original)
+++ pstl/trunk/include/pstl/internal/parallel_backend_serial.h Mon Jul 8 09:05:00 2019
@@ -20,7 +20,7 @@
namespace __pstl
{
-namespace __serial
+namespace __serial_backend
{
template <typename _Tp>
@@ -126,15 +126,7 @@ __parallel_invoke(_ExecutionPolicy&&, _F
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 */
Modified: pstl/trunk/include/pstl/internal/parallel_backend_tbb.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/parallel_backend_tbb.h?rev=365337&r1=365336&r2=365337&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/parallel_backend_tbb.h (original)
+++ pstl/trunk/include/pstl/internal/parallel_backend_tbb.h Mon Jul 8 09:05:00 2019
@@ -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<_RandomAccessIterator
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&&, _F
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 */
Modified: pstl/trunk/include/pstl/internal/parallel_backend_utils.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/parallel_backend_utils.h?rev=365337&r1=365336&r2=365337&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/parallel_backend_utils.h (original)
+++ pstl/trunk/include/pstl/internal/parallel_backend_utils.h Mon Jul 8 09:05:00 2019
@@ -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 */
More information about the libcxx-commits
mailing list