Skip to content

Commit 5b81156

Browse files
authored
[libc++] Rename __cpu_traits functions (llvm#88741)
Functions inside __cpu_traits were needlessly prefixed with __parallel, which doesn't serve a real purpose anymore now that they are inside a traits class.
1 parent d34a2c2 commit 5b81156

File tree

12 files changed

+59
-60
lines changed

12 files changed

+59
-60
lines changed

libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3434
template <class _Backend, class _Index, class _Brick>
3535
_LIBCPP_HIDE_FROM_ABI optional<bool> __parallel_or(_Index __first, _Index __last, _Brick __f) {
3636
std::atomic<bool> __found(false);
37-
auto __ret = __pstl::__cpu_traits<_Backend>::__parallel_for(__first, __last, [__f, &__found](_Index __i, _Index __j) {
37+
auto __ret = __pstl::__cpu_traits<_Backend>::__for_each(__first, __last, [__f, &__found](_Index __i, _Index __j) {
3838
if (!__found.load(std::memory_order_relaxed) && __f(__i, __j)) {
3939
__found.store(true, std::memory_order_relaxed);
4040
__pstl::__cpu_traits<_Backend>::__cancel_execution();

libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI optional<__empty>
4040
__pstl_fill(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
4141
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
4242
__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
43-
return __pstl::__cpu_traits<__cpu_backend_tag>::__parallel_for(
43+
return __pstl::__cpu_traits<__cpu_backend_tag>::__for_each(
4444
__first, __last, [&__value](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
4545
[[maybe_unused]] auto __res = std::__pstl_fill<__remove_parallel_policy_t<_ExecutionPolicy>>(
4646
__cpu_backend_tag{}, __brick_first, __brick_last, __value);

libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ __parallel_find(_Index __first, _Index __last, _Brick __f, _Compare __comp, bool
4242
_DifferenceType __initial_dist = __b_first ? __n : -1;
4343
std::atomic<_DifferenceType> __extremum(__initial_dist);
4444
// TODO: find out what is better here: parallel_for or parallel_reduce
45-
auto __res = __pstl::__cpu_traits<_Backend>::__parallel_for(
45+
auto __res = __pstl::__cpu_traits<_Backend>::__for_each(
4646
__first, __last, [__comp, __f, __first, &__extremum](_Index __i, _Index __j) {
4747
// See "Reducing Contention Through Priority Updates", PPoPP '13, for discussion of
4848
// why using a shared variable scales fairly well in this situation.

libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI optional<__empty>
4040
__pstl_for_each(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Functor __func) {
4141
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
4242
__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
43-
return __pstl::__cpu_traits<__cpu_backend_tag>::__parallel_for(
43+
return __pstl::__cpu_traits<__cpu_backend_tag>::__for_each(
4444
__first, __last, [__func](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
4545
[[maybe_unused]] auto __res = std::__pstl_for_each<__remove_parallel_policy_t<_ExecutionPolicy>>(
4646
__cpu_backend_tag{}, __brick_first, __brick_last, __func);

libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ template <>
8585
struct __cpu_traits<__libdispatch_backend_tag> {
8686
template <class _RandomAccessIterator, class _Functor>
8787
_LIBCPP_HIDE_FROM_ABI static optional<__empty>
88-
__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) {
88+
__for_each(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) {
8989
return __libdispatch::__dispatch_parallel_for(
9090
__libdispatch::__partition_chunks(__last - __first), std::move(__first), std::move(__func));
9191
}
@@ -105,14 +105,14 @@ struct __cpu_traits<__libdispatch_backend_tag> {
105105
typename _RandomAccessIterator3,
106106
typename _Compare,
107107
typename _LeafMerge>
108-
_LIBCPP_HIDE_FROM_ABI static optional<__empty> __parallel_merge(
109-
_RandomAccessIterator1 __first1,
110-
_RandomAccessIterator1 __last1,
111-
_RandomAccessIterator2 __first2,
112-
_RandomAccessIterator2 __last2,
113-
_RandomAccessIterator3 __result,
114-
_Compare __comp,
115-
_LeafMerge __leaf_merge) noexcept {
108+
_LIBCPP_HIDE_FROM_ABI static optional<__empty>
109+
__merge(_RandomAccessIterator1 __first1,
110+
_RandomAccessIterator1 __last1,
111+
_RandomAccessIterator2 __first2,
112+
_RandomAccessIterator2 __last2,
113+
_RandomAccessIterator3 __result,
114+
_Compare __comp,
115+
_LeafMerge __leaf_merge) noexcept {
116116
__libdispatch::__chunk_partitions __partitions =
117117
__libdispatch::__partition_chunks(std::max<ptrdiff_t>(__last1 - __first1, __last2 - __first2));
118118

@@ -201,7 +201,7 @@ struct __cpu_traits<__libdispatch_backend_tag> {
201201
}
202202

203203
template <class _RandomAccessIterator, class _Transform, class _Value, class _Combiner, class _Reduction>
204-
_LIBCPP_HIDE_FROM_ABI static optional<_Value> __parallel_transform_reduce(
204+
_LIBCPP_HIDE_FROM_ABI static optional<_Value> __transform_reduce(
205205
_RandomAccessIterator __first,
206206
_RandomAccessIterator __last,
207207
_Transform __transform,
@@ -248,8 +248,8 @@ struct __cpu_traits<__libdispatch_backend_tag> {
248248
}
249249

250250
template <class _RandomAccessIterator, class _Comp, class _LeafSort>
251-
_LIBCPP_HIDE_FROM_ABI static optional<__empty> __parallel_stable_sort(
252-
_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp, _LeafSort __leaf_sort) {
251+
_LIBCPP_HIDE_FROM_ABI static optional<__empty>
252+
__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp, _LeafSort __leaf_sort) {
253253
const auto __size = __last - __first;
254254
auto __partitions = __libdispatch::__partition_chunks(__size);
255255

libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_merge(
4646
__has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
4747
__has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
4848
__has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
49-
auto __res = __pstl::__cpu_traits<__cpu_backend_tag>::__parallel_merge(
49+
auto __res = __pstl::__cpu_traits<__cpu_backend_tag>::__merge(
5050
__first1,
5151
__last1,
5252
__first2,

libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ template <>
3535
struct __cpu_traits<__serial_backend_tag> {
3636
template <class _RandomAccessIterator, class _Fp>
3737
_LIBCPP_HIDE_FROM_ABI static optional<__empty>
38-
__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
38+
__for_each(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
3939
__f(__first, __last);
4040
return __empty{};
4141
}
4242

4343
template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce>
4444
_LIBCPP_HIDE_FROM_ABI static optional<_Tp>
45-
__parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) {
45+
__transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) {
4646
return __reduce(std::move(__first), std::move(__last), std::move(__init));
4747
}
4848

4949
template <class _RandomAccessIterator, class _Compare, class _LeafSort>
50-
_LIBCPP_HIDE_FROM_ABI static optional<__empty> __parallel_stable_sort(
51-
_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) {
50+
_LIBCPP_HIDE_FROM_ABI static optional<__empty>
51+
__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) {
5252
__leaf_sort(__first, __last, __comp);
5353
return __empty{};
5454
}
@@ -60,14 +60,14 @@ struct __cpu_traits<__serial_backend_tag> {
6060
class _RandomAccessIterator3,
6161
class _Compare,
6262
class _LeafMerge>
63-
_LIBCPP_HIDE_FROM_ABI static optional<__empty> __parallel_merge(
64-
_RandomAccessIterator1 __first1,
65-
_RandomAccessIterator1 __last1,
66-
_RandomAccessIterator2 __first2,
67-
_RandomAccessIterator2 __last2,
68-
_RandomAccessIterator3 __outit,
69-
_Compare __comp,
70-
_LeafMerge __leaf_merge) {
63+
_LIBCPP_HIDE_FROM_ABI static optional<__empty>
64+
__merge(_RandomAccessIterator1 __first1,
65+
_RandomAccessIterator1 __last1,
66+
_RandomAccessIterator2 __first2,
67+
_RandomAccessIterator2 __last2,
68+
_RandomAccessIterator3 __outit,
69+
_Compare __comp,
70+
_LeafMerge __leaf_merge) {
7171
__leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp);
7272
return __empty{};
7373
}

libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp>
2929
_LIBCPP_HIDE_FROM_ABI optional<__empty>
3030
__pstl_stable_sort(__cpu_backend_tag, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
3131
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy>) {
32-
return __pstl::__cpu_traits<__cpu_backend_tag>::__parallel_stable_sort(
32+
return __pstl::__cpu_traits<__cpu_backend_tag>::__stable_sort(
3333
__first, __last, __comp, [](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) {
3434
std::stable_sort(__g_first, __g_last, __g_comp);
3535
});

libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ template <>
3838
struct __cpu_traits<__std_thread_backend_tag> {
3939
template <class _RandomAccessIterator, class _Fp>
4040
_LIBCPP_HIDE_FROM_ABI static optional<__empty>
41-
__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
41+
__for_each(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
4242
__f(__first, __last);
4343
return __empty{};
4444
}
4545

4646
template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce>
4747
_LIBCPP_HIDE_FROM_ABI static optional<_Tp>
48-
__parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) {
48+
__transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) {
4949
return __reduce(std::move(__first), std::move(__last), std::move(__init));
5050
}
5151

5252
template <class _RandomAccessIterator, class _Compare, class _LeafSort>
53-
_LIBCPP_HIDE_FROM_ABI static optional<__empty> __parallel_stable_sort(
54-
_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) {
53+
_LIBCPP_HIDE_FROM_ABI static optional<__empty>
54+
__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) {
5555
__leaf_sort(__first, __last, __comp);
5656
return __empty{};
5757
}
@@ -63,14 +63,14 @@ struct __cpu_traits<__std_thread_backend_tag> {
6363
class _RandomAccessIterator3,
6464
class _Compare,
6565
class _LeafMerge>
66-
_LIBCPP_HIDE_FROM_ABI static optional<__empty> __parallel_merge(
67-
_RandomAccessIterator1 __first1,
68-
_RandomAccessIterator1 __last1,
69-
_RandomAccessIterator2 __first2,
70-
_RandomAccessIterator2 __last2,
71-
_RandomAccessIterator3 __outit,
72-
_Compare __comp,
73-
_LeafMerge __leaf_merge) {
66+
_LIBCPP_HIDE_FROM_ABI static optional<__empty>
67+
__merge(_RandomAccessIterator1 __first1,
68+
_RandomAccessIterator1 __last1,
69+
_RandomAccessIterator2 __first2,
70+
_RandomAccessIterator2 __last2,
71+
_RandomAccessIterator3 __outit,
72+
_Compare __comp,
73+
_LeafMerge __leaf_merge) {
7474
__leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp);
7575
return __empty{};
7676
}

libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_transform(
5050
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
5151
__has_random_access_iterator_category_or_concept<_ForwardIterator>::value &&
5252
__has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
53-
__pstl::__cpu_traits<__cpu_backend_tag>::__parallel_for(
53+
__pstl::__cpu_traits<__cpu_backend_tag>::__for_each(
5454
__first, __last, [__op, __first, __result](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
5555
auto __res = std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>(
5656
__cpu_backend_tag{}, __brick_first, __brick_last, __result + (__brick_first - __first), __op);
@@ -98,7 +98,7 @@ _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_transform(
9898
__has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
9999
__has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
100100
__has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
101-
auto __res = __pstl::__cpu_traits<__cpu_backend_tag>::__parallel_for(
101+
auto __res = __pstl::__cpu_traits<__cpu_backend_tag>::__for_each(
102102
__first1,
103103
__last1,
104104
[__op, __first1, __first2, __result](_ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last) {

0 commit comments

Comments
 (0)