Skip to content

Commit 0e08bce

Browse files
authored
[libc++][pstl] Move the CPU algorithm implementations to __pstl (#89109)
This colocates the CPU algorithms closer to the rest of the PSTL implementation details.
1 parent 3f0d52b commit 0e08bce

14 files changed

+70
-78
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,6 @@ set(files
7373
__algorithm/pop_heap.h
7474
__algorithm/prev_permutation.h
7575
__algorithm/pstl_any_all_none_of.h
76-
__algorithm/pstl_backends/cpu_backends/any_of.h
77-
__algorithm/pstl_backends/cpu_backends/fill.h
78-
__algorithm/pstl_backends/cpu_backends/find_if.h
79-
__algorithm/pstl_backends/cpu_backends/for_each.h
80-
__algorithm/pstl_backends/cpu_backends/merge.h
81-
__algorithm/pstl_backends/cpu_backends/stable_sort.h
82-
__algorithm/pstl_backends/cpu_backends/transform.h
83-
__algorithm/pstl_backends/cpu_backends/transform_reduce.h
8476
__algorithm/pstl_copy.h
8577
__algorithm/pstl_count.h
8678
__algorithm/pstl_equal.h
@@ -593,7 +585,15 @@ set(files
593585
__pstl/backends/std_thread.h
594586
__pstl/configuration.h
595587
__pstl/configuration_fwd.h
588+
__pstl/cpu_algos/any_of.h
596589
__pstl/cpu_algos/cpu_traits.h
590+
__pstl/cpu_algos/fill.h
591+
__pstl/cpu_algos/find_if.h
592+
__pstl/cpu_algos/for_each.h
593+
__pstl/cpu_algos/merge.h
594+
__pstl/cpu_algos/stable_sort.h
595+
__pstl/cpu_algos/transform.h
596+
__pstl/cpu_algos/transform_reduce.h
597597
__random/bernoulli_distribution.h
598598
__random/binomial_distribution.h
599599
__random/cauchy_distribution.h

libcxx/include/__pstl/backends/libdispatch.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,13 @@ _LIBCPP_END_NAMESPACE_STD
349349
_LIBCPP_POP_MACROS
350350

351351
// Implement PSTL algorithms based on the __cpu_traits specialized above
352-
#include <__algorithm/pstl_backends/cpu_backends/any_of.h>
353-
#include <__algorithm/pstl_backends/cpu_backends/fill.h>
354-
#include <__algorithm/pstl_backends/cpu_backends/find_if.h>
355-
#include <__algorithm/pstl_backends/cpu_backends/for_each.h>
356-
#include <__algorithm/pstl_backends/cpu_backends/merge.h>
357-
#include <__algorithm/pstl_backends/cpu_backends/stable_sort.h>
358-
#include <__algorithm/pstl_backends/cpu_backends/transform.h>
359-
#include <__algorithm/pstl_backends/cpu_backends/transform_reduce.h>
352+
#include <__pstl/cpu_algos/any_of.h>
353+
#include <__pstl/cpu_algos/fill.h>
354+
#include <__pstl/cpu_algos/find_if.h>
355+
#include <__pstl/cpu_algos/for_each.h>
356+
#include <__pstl/cpu_algos/merge.h>
357+
#include <__pstl/cpu_algos/stable_sort.h>
358+
#include <__pstl/cpu_algos/transform.h>
359+
#include <__pstl/cpu_algos/transform_reduce.h>
360360

361361
#endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H

libcxx/include/__pstl/backends/serial.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ _LIBCPP_POP_MACROS
8282
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17
8383

8484
// Implement PSTL algorithms based on the __cpu_traits specialized above
85-
#include <__algorithm/pstl_backends/cpu_backends/any_of.h>
86-
#include <__algorithm/pstl_backends/cpu_backends/fill.h>
87-
#include <__algorithm/pstl_backends/cpu_backends/find_if.h>
88-
#include <__algorithm/pstl_backends/cpu_backends/for_each.h>
89-
#include <__algorithm/pstl_backends/cpu_backends/merge.h>
90-
#include <__algorithm/pstl_backends/cpu_backends/stable_sort.h>
91-
#include <__algorithm/pstl_backends/cpu_backends/transform.h>
92-
#include <__algorithm/pstl_backends/cpu_backends/transform_reduce.h>
85+
#include <__pstl/cpu_algos/any_of.h>
86+
#include <__pstl/cpu_algos/fill.h>
87+
#include <__pstl/cpu_algos/find_if.h>
88+
#include <__pstl/cpu_algos/for_each.h>
89+
#include <__pstl/cpu_algos/merge.h>
90+
#include <__pstl/cpu_algos/stable_sort.h>
91+
#include <__pstl/cpu_algos/transform.h>
92+
#include <__pstl/cpu_algos/transform_reduce.h>
9393

9494
#endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H

libcxx/include/__pstl/backends/std_thread.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ _LIBCPP_END_NAMESPACE_STD
8585
_LIBCPP_POP_MACROS
8686

8787
// Implement PSTL algorithms based on the __cpu_traits specialized above
88-
#include <__algorithm/pstl_backends/cpu_backends/any_of.h>
89-
#include <__algorithm/pstl_backends/cpu_backends/fill.h>
90-
#include <__algorithm/pstl_backends/cpu_backends/find_if.h>
91-
#include <__algorithm/pstl_backends/cpu_backends/for_each.h>
92-
#include <__algorithm/pstl_backends/cpu_backends/merge.h>
93-
#include <__algorithm/pstl_backends/cpu_backends/stable_sort.h>
94-
#include <__algorithm/pstl_backends/cpu_backends/transform.h>
95-
#include <__algorithm/pstl_backends/cpu_backends/transform_reduce.h>
88+
#include <__pstl/cpu_algos/any_of.h>
89+
#include <__pstl/cpu_algos/fill.h>
90+
#include <__pstl/cpu_algos/find_if.h>
91+
#include <__pstl/cpu_algos/for_each.h>
92+
#include <__pstl/cpu_algos/merge.h>
93+
#include <__pstl/cpu_algos/stable_sort.h>
94+
#include <__pstl/cpu_algos/transform.h>
95+
#include <__pstl/cpu_algos/transform_reduce.h>
9696

9797
#endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H

libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h renamed to libcxx/include/__pstl/cpu_algos/any_of.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H
10-
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H
9+
#ifndef _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H
10+
#define _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H
1111

1212
#include <__algorithm/any_of.h>
1313
#include <__algorithm/find_if.h>
@@ -96,4 +96,4 @@ _LIBCPP_POP_MACROS
9696

9797
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
9898

99-
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H
99+
#endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H

libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h renamed to libcxx/include/__pstl/cpu_algos/fill.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H
10-
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H
9+
#ifndef _LIBCPP___PSTL_CPU_ALGOS_FILL_H
10+
#define _LIBCPP___PSTL_CPU_ALGOS_FILL_H
1111

1212
#include <__algorithm/fill.h>
1313
#include <__config>
@@ -60,4 +60,4 @@ _LIBCPP_END_NAMESPACE_STD
6060

6161
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
6262

63-
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H
63+
#endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H

libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h renamed to libcxx/include/__pstl/cpu_algos/find_if.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H
10-
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H
9+
#ifndef _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H
10+
#define _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H
1111

1212
#include <__algorithm/find_if.h>
1313
#include <__atomic/atomic.h>
@@ -132,4 +132,4 @@ _LIBCPP_POP_MACROS
132132

133133
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
134134

135-
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H
135+
#endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H

libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h renamed to libcxx/include/__pstl/cpu_algos/for_each.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H
10-
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H
9+
#ifndef _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H
10+
#define _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H
1111

1212
#include <__algorithm/for_each.h>
1313
#include <__config>
@@ -60,4 +60,4 @@ _LIBCPP_END_NAMESPACE_STD
6060

6161
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
6262

63-
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H
63+
#endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H

libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h renamed to libcxx/include/__pstl/cpu_algos/merge.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H
10-
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H
9+
#ifndef _LIBCPP___PSTL_CPU_ALGOS_MERGE_H
10+
#define _LIBCPP___PSTL_CPU_ALGOS_MERGE_H
1111

1212
#include <__algorithm/merge.h>
1313
#include <__config>
@@ -83,4 +83,4 @@ _LIBCPP_POP_MACROS
8383

8484
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
8585

86-
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H
86+
#endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H

libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h renamed to libcxx/include/__pstl/cpu_algos/stable_sort.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H
10-
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H
9+
#ifndef _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H
10+
#define _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H
1111

1212
#include <__algorithm/stable_sort.h>
1313
#include <__config>
@@ -43,4 +43,4 @@ _LIBCPP_END_NAMESPACE_STD
4343

4444
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
4545

46-
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H
46+
#endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H

libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h renamed to libcxx/include/__pstl/cpu_algos/transform.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H
10-
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H
9+
#ifndef _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H
10+
#define _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H
1111

1212
#include <__algorithm/transform.h>
1313
#include <__config>
@@ -136,4 +136,4 @@ _LIBCPP_POP_MACROS
136136

137137
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
138138

139-
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H
139+
#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H

libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h renamed to libcxx/include/__pstl/cpu_algos/transform_reduce.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H
10-
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H
9+
#ifndef _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H
10+
#define _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H
1111

1212
#include <__config>
1313
#include <__iterator/concepts.h>
@@ -203,4 +203,4 @@ _LIBCPP_END_NAMESPACE_STD
203203

204204
_LIBCPP_POP_MACROS
205205

206-
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H
206+
#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H

libcxx/include/libcxx.imp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,6 @@
7373
{ include: [ "<__algorithm/pop_heap.h>", "private", "<algorithm>", "public" ] },
7474
{ include: [ "<__algorithm/prev_permutation.h>", "private", "<algorithm>", "public" ] },
7575
{ include: [ "<__algorithm/pstl_any_all_none_of.h>", "private", "<algorithm>", "public" ] },
76-
{ include: [ "<__algorithm/pstl_backends/cpu_backends/any_of.h>", "private", "<algorithm>", "public" ] },
77-
{ include: [ "<__algorithm/pstl_backends/cpu_backends/fill.h>", "private", "<algorithm>", "public" ] },
78-
{ include: [ "<__algorithm/pstl_backends/cpu_backends/find_if.h>", "private", "<algorithm>", "public" ] },
79-
{ include: [ "<__algorithm/pstl_backends/cpu_backends/for_each.h>", "private", "<algorithm>", "public" ] },
80-
{ include: [ "<__algorithm/pstl_backends/cpu_backends/merge.h>", "private", "<algorithm>", "public" ] },
81-
{ include: [ "<__algorithm/pstl_backends/cpu_backends/stable_sort.h>", "private", "<algorithm>", "public" ] },
82-
{ include: [ "<__algorithm/pstl_backends/cpu_backends/transform.h>", "private", "<algorithm>", "public" ] },
83-
{ include: [ "<__algorithm/pstl_backends/cpu_backends/transform_reduce.h>", "private", "<algorithm>", "public" ] },
8476
{ include: [ "<__algorithm/pstl_copy.h>", "private", "<algorithm>", "public" ] },
8577
{ include: [ "<__algorithm/pstl_count.h>", "private", "<algorithm>", "public" ] },
8678
{ include: [ "<__algorithm/pstl_equal.h>", "private", "<algorithm>", "public" ] },

libcxx/include/module.modulemap

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -714,14 +714,6 @@ module std_private_algorithm_partition_point [system
714714
module std_private_algorithm_pop_heap [system] { header "__algorithm/pop_heap.h" }
715715
module std_private_algorithm_prev_permutation [system] { header "__algorithm/prev_permutation.h" }
716716
module std_private_algorithm_pstl_any_all_none_of [system] { header "__algorithm/pstl_any_all_none_of.h" }
717-
module std_private_algorithm_pstl_backends_cpu_backends_any_of [system] { textual header "__algorithm/pstl_backends/cpu_backends/any_of.h" }
718-
module std_private_algorithm_pstl_backends_cpu_backends_fill [system] { textual header "__algorithm/pstl_backends/cpu_backends/fill.h" }
719-
module std_private_algorithm_pstl_backends_cpu_backends_find_if [system] { textual header "__algorithm/pstl_backends/cpu_backends/find_if.h" }
720-
module std_private_algorithm_pstl_backends_cpu_backends_for_each [system] { textual header "__algorithm/pstl_backends/cpu_backends/for_each.h" }
721-
module std_private_algorithm_pstl_backends_cpu_backends_merge [system] { textual header "__algorithm/pstl_backends/cpu_backends/merge.h" }
722-
module std_private_algorithm_pstl_backends_cpu_backends_stable_sort [system] { textual header "__algorithm/pstl_backends/cpu_backends/stable_sort.h" }
723-
module std_private_algorithm_pstl_backends_cpu_backends_transform [system] { textual header "__algorithm/pstl_backends/cpu_backends/transform.h" }
724-
module std_private_algorithm_pstl_backends_cpu_backends_transform_reduce [system] { textual header "__algorithm/pstl_backends/cpu_backends/transform_reduce.h" }
725717
module std_private_algorithm_pstl_copy [system] { header "__algorithm/pstl_copy.h" }
726718
module std_private_algorithm_pstl_count [system] { header "__algorithm/pstl_count.h" }
727719
module std_private_algorithm_pstl_equal [system] { header "__algorithm/pstl_equal.h" }
@@ -1595,15 +1587,23 @@ module std_private_numeric_transform_exclusive_scan [system] { header "__numeric
15951587
module std_private_numeric_transform_inclusive_scan [system] { header "__numeric/transform_inclusive_scan.h" }
15961588
module std_private_numeric_transform_reduce [system] { header "__numeric/transform_reduce.h" }
15971589

1598-
module std_private_pstl_backends_libdispatch [system] { header "__pstl/backends/libdispatch.h" }
1599-
module std_private_pstl_backends_serial [system] { header "__pstl/backends/serial.h" }
1600-
module std_private_pstl_backends_std_thread [system] { header "__pstl/backends/std_thread.h" }
1601-
module std_private_pstl_cpu_algos_cpu_traits [system] { header "__pstl/cpu_algos/cpu_traits.h" }
1602-
module std_private_pstl_configuration_fwd [system] {
1590+
module std_private_pstl_backends_libdispatch [system] { header "__pstl/backends/libdispatch.h" }
1591+
module std_private_pstl_backends_serial [system] { header "__pstl/backends/serial.h" }
1592+
module std_private_pstl_backends_std_thread [system] { header "__pstl/backends/std_thread.h" }
1593+
module std_private_pstl_cpu_algos_any_of [system] { textual header "__pstl/cpu_algos/any_of.h" }
1594+
module std_private_pstl_cpu_algos_cpu_traits [system] { header "__pstl/cpu_algos/cpu_traits.h" }
1595+
module std_private_pstl_cpu_algos_fill [system] { textual header "__pstl/cpu_algos/fill.h" }
1596+
module std_private_pstl_cpu_algos_find_if [system] { textual header "__pstl/cpu_algos/find_if.h" }
1597+
module std_private_pstl_cpu_algos_for_each [system] { textual header "__pstl/cpu_algos/for_each.h" }
1598+
module std_private_pstl_cpu_algos_merge [system] { textual header "__pstl/cpu_algos/merge.h" }
1599+
module std_private_pstl_cpu_algos_stable_sort [system] { textual header "__pstl/cpu_algos/stable_sort.h" }
1600+
module std_private_pstl_cpu_algos_transform [system] { textual header "__pstl/cpu_algos/transform.h" }
1601+
module std_private_pstl_cpu_algos_transform_reduce [system] { textual header "__pstl/cpu_algos/transform_reduce.h" }
1602+
module std_private_pstl_configuration_fwd [system] {
16031603
header "__pstl/configuration_fwd.h"
16041604
export *
16051605
}
1606-
module std_private_pstl_configuration [system] {
1606+
module std_private_pstl_configuration [system] {
16071607
header "__pstl/configuration.h"
16081608
export *
16091609
}

0 commit comments

Comments
 (0)