Skip to content

Commit

Permalink
[libc++][PSTL] Fix clang-tidy
Browse files Browse the repository at this point in the history
Reviewed By: ldionne, #libc

Spies: libcxx-commits, miyuki, carlosgalvezp

Differential Revision: https://reviews.llvm.org/D149500
  • Loading branch information
philnik777 committed May 1, 2023
1 parent 284e54d commit 819d1e8
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 76 deletions.
8 changes: 4 additions & 4 deletions libcxx/include/__pstl/internal/execution_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,25 @@ using __tag_type =
__serial_tag<_IsVector>>::type;

template <class... _IteratorTypes>
__serial_tag</*_IsVector = */ std::false_type>
_LIBCPP_HIDE_FROM_ABI __serial_tag</*_IsVector = */ std::false_type>
__select_backend(__pstl::execution::sequenced_policy, _IteratorTypes&&...) {
return {};
}

template <class... _IteratorTypes>
__serial_tag<__internal::__are_random_access_iterators<_IteratorTypes...>>
_LIBCPP_HIDE_FROM_ABI __serial_tag<__internal::__are_random_access_iterators<_IteratorTypes...>>
__select_backend(__pstl::execution::unsequenced_policy, _IteratorTypes&&...) {
return {};
}

template <class... _IteratorTypes>
__tag_type</*_IsVector = */ std::false_type, _IteratorTypes...>
_LIBCPP_HIDE_FROM_ABI __tag_type</*_IsVector = */ std::false_type, _IteratorTypes...>
__select_backend(__pstl::execution::parallel_policy, _IteratorTypes&&...) {
return {};
}

template <class... _IteratorTypes>
__tag_type<__internal::__are_random_access_iterators<_IteratorTypes...>, _IteratorTypes...>
_LIBCPP_HIDE_FROM_ABI __tag_type<__internal::__are_random_access_iterators<_IteratorTypes...>, _IteratorTypes...>
__select_backend(__pstl::execution::parallel_unsequenced_policy, _IteratorTypes&&...) {
return {};
}
Expand Down
25 changes: 13 additions & 12 deletions libcxx/include/__pstl/internal/parallel_backend_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,32 @@ class __buffer
operator=(const __buffer&) = delete;

public:
_LIBCPP_HIDE_FROM_ABI
__buffer(std::size_t __n) : __allocator_(), __ptr_(__allocator_.allocate(__n)), __buf_size_(__n) {}

operator bool() const { return __ptr_ != nullptr; }
_Tp*
_LIBCPP_HIDE_FROM_ABI operator bool() const { return __ptr_ != nullptr; }
_LIBCPP_HIDE_FROM_ABI _Tp*
get() const
{
return __ptr_;
}
~__buffer() { __allocator_.deallocate(__ptr_, __buf_size_); }
_LIBCPP_HIDE_FROM_ABI ~__buffer() { __allocator_.deallocate(__ptr_, __buf_size_); }
};

inline void
_LIBCPP_HIDE_FROM_ABI inline void
__cancel_execution()
{
}

template <class _ExecutionPolicy, class _Index, class _Fp>
void
_LIBCPP_HIDE_FROM_ABI void
__parallel_for(__pstl::__internal::__serial_backend_tag, _ExecutionPolicy&&, _Index __first, _Index __last, _Fp __f)
{
__f(__first, __last);
}

template <class _ExecutionPolicy, class _Value, class _Index, typename _RealBody, typename _Reduction>
_Value
_LIBCPP_HIDE_FROM_ABI _Value
__parallel_reduce(__pstl::__internal::__serial_backend_tag, _ExecutionPolicy&&, _Index __first, _Index __last,
const _Value& __identity, const _RealBody& __real_body, const _Reduction&)
{
Expand All @@ -71,15 +72,15 @@ __parallel_reduce(__pstl::__internal::__serial_backend_tag, _ExecutionPolicy&&,
}

template <class _ExecutionPolicy, class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce>
_Tp
_LIBCPP_HIDE_FROM_ABI _Tp
__parallel_transform_reduce(__pstl::__internal::__serial_backend_tag, _ExecutionPolicy&&, _Index __first, _Index __last,
_UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce)
{
return __reduce(__first, __last, __init);
}

template <class _ExecutionPolicy, typename _Index, typename _Tp, typename _Rp, typename _Cp, typename _Sp, typename _Ap>
void
_LIBCPP_HIDE_FROM_ABI void
__parallel_strict_scan(__pstl::__internal::__serial_backend_tag, _ExecutionPolicy&&, _Index __n, _Tp __initial,
_Rp __reduce, _Cp __combine, _Sp __scan, _Ap __apex)
{
Expand All @@ -92,15 +93,15 @@ __parallel_strict_scan(__pstl::__internal::__serial_backend_tag, _ExecutionPolic
}

template <class _ExecutionPolicy, class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce, class _Scan>
_Tp
_LIBCPP_HIDE_FROM_ABI _Tp
__parallel_transform_scan(__pstl::__internal::__serial_backend_tag, _ExecutionPolicy&&, _Index __n, _UnaryOp,
_Tp __init, _BinaryOp, _Reduce, _Scan __scan)
{
return __scan(_Index(0), __n, __init);
}

template <class _ExecutionPolicy, typename _RandomAccessIterator, typename _Compare, typename _LeafSort>
void
_LIBCPP_HIDE_FROM_ABI void
__parallel_stable_sort(__pstl::__internal::__serial_backend_tag, _ExecutionPolicy&&, _RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort, std::size_t = 0)
{
Expand All @@ -109,7 +110,7 @@ __parallel_stable_sort(__pstl::__internal::__serial_backend_tag, _ExecutionPolic

template <class _ExecutionPolicy, typename _RandomAccessIterator1, typename _RandomAccessIterator2,
typename _RandomAccessIterator3, typename _Compare, typename _LeafMerge>
void
_LIBCPP_HIDE_FROM_ABI void
__parallel_merge(__pstl::__internal::__serial_backend_tag, _ExecutionPolicy&&, _RandomAccessIterator1 __first1,
_RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2,
_RandomAccessIterator3 __outit, _Compare __comp, _LeafMerge __leaf_merge)
Expand All @@ -118,7 +119,7 @@ __parallel_merge(__pstl::__internal::__serial_backend_tag, _ExecutionPolicy&&, _
}

template <class _ExecutionPolicy, typename _F1, typename _F2>
void
_LIBCPP_HIDE_FROM_ABI void
__parallel_invoke(__pstl::__internal::__serial_backend_tag, _ExecutionPolicy&&, _F1&& __f1, _F2&& __f2)
{
std::forward<_F1>(__f1)();
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/__pstl/internal/parallel_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace __internal
/** Return extremum value returned by brick f[i,j) for subranges [i,j) of [first,last)
Each f[i,j) must return a value in [i,j). */
template <class _BackendTag, class _ExecutionPolicy, class _Index, class _Brick, class _Compare>
_Index
_LIBCPP_HIDE_FROM_ABI _Index
__parallel_find(_BackendTag __tag, _ExecutionPolicy&& __exec, _Index __first, _Index __last, _Brick __f,
_Compare __comp, bool __b_first)
{
Expand Down Expand Up @@ -65,6 +65,7 @@ __parallel_find(_BackendTag __tag, _ExecutionPolicy&& __exec, _Index __first, _I
//------------------------------------------------------------------------
//! Return true if brick f[i,j) returns true for some subrange [i,j) of [first,last)
template <class _BackendTag, class _ExecutionPolicy, class _Index, class _Brick>
_LIBCPP_HIDE_FROM_ABI
bool __parallel_or(_BackendTag __tag, _ExecutionPolicy&& __exec, _Index __first, _Index __last, _Brick __f) {
std::atomic<bool> __found(false);
__par_backend::__parallel_for(__tag, std::forward<_ExecutionPolicy>(__exec), __first, __last,
Expand Down

0 comments on commit 819d1e8

Please sign in to comment.