forked from OSchip/llvm-project
[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
This commit is contained in:
parent
b4b21d807e
commit
b152f9f392
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue