Skip to content

Commit

Permalink
[libc++][pstl] Move the CPU algorithm implementations to __pstl (#89109)
Browse files Browse the repository at this point in the history
This colocates the CPU algorithms closer to the rest of the PSTL
implementation details.
  • Loading branch information
ldionne committed Apr 18, 2024
1 parent 3f0d52b commit 0e08bce
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 78 deletions.
16 changes: 8 additions & 8 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ set(files
__algorithm/pop_heap.h
__algorithm/prev_permutation.h
__algorithm/pstl_any_all_none_of.h
__algorithm/pstl_backends/cpu_backends/any_of.h
__algorithm/pstl_backends/cpu_backends/fill.h
__algorithm/pstl_backends/cpu_backends/find_if.h
__algorithm/pstl_backends/cpu_backends/for_each.h
__algorithm/pstl_backends/cpu_backends/merge.h
__algorithm/pstl_backends/cpu_backends/stable_sort.h
__algorithm/pstl_backends/cpu_backends/transform.h
__algorithm/pstl_backends/cpu_backends/transform_reduce.h
__algorithm/pstl_copy.h
__algorithm/pstl_count.h
__algorithm/pstl_equal.h
Expand Down Expand Up @@ -593,7 +585,15 @@ set(files
__pstl/backends/std_thread.h
__pstl/configuration.h
__pstl/configuration_fwd.h
__pstl/cpu_algos/any_of.h
__pstl/cpu_algos/cpu_traits.h
__pstl/cpu_algos/fill.h
__pstl/cpu_algos/find_if.h
__pstl/cpu_algos/for_each.h
__pstl/cpu_algos/merge.h
__pstl/cpu_algos/stable_sort.h
__pstl/cpu_algos/transform.h
__pstl/cpu_algos/transform_reduce.h
__random/bernoulli_distribution.h
__random/binomial_distribution.h
__random/cauchy_distribution.h
Expand Down
16 changes: 8 additions & 8 deletions libcxx/include/__pstl/backends/libdispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,13 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

// Implement PSTL algorithms based on the __cpu_traits specialized above
#include <__algorithm/pstl_backends/cpu_backends/any_of.h>
#include <__algorithm/pstl_backends/cpu_backends/fill.h>
#include <__algorithm/pstl_backends/cpu_backends/find_if.h>
#include <__algorithm/pstl_backends/cpu_backends/for_each.h>
#include <__algorithm/pstl_backends/cpu_backends/merge.h>
#include <__algorithm/pstl_backends/cpu_backends/stable_sort.h>
#include <__algorithm/pstl_backends/cpu_backends/transform.h>
#include <__algorithm/pstl_backends/cpu_backends/transform_reduce.h>
#include <__pstl/cpu_algos/any_of.h>
#include <__pstl/cpu_algos/fill.h>
#include <__pstl/cpu_algos/find_if.h>
#include <__pstl/cpu_algos/for_each.h>
#include <__pstl/cpu_algos/merge.h>
#include <__pstl/cpu_algos/stable_sort.h>
#include <__pstl/cpu_algos/transform.h>
#include <__pstl/cpu_algos/transform_reduce.h>

#endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H
16 changes: 8 additions & 8 deletions libcxx/include/__pstl/backends/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ _LIBCPP_POP_MACROS
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17

// Implement PSTL algorithms based on the __cpu_traits specialized above
#include <__algorithm/pstl_backends/cpu_backends/any_of.h>
#include <__algorithm/pstl_backends/cpu_backends/fill.h>
#include <__algorithm/pstl_backends/cpu_backends/find_if.h>
#include <__algorithm/pstl_backends/cpu_backends/for_each.h>
#include <__algorithm/pstl_backends/cpu_backends/merge.h>
#include <__algorithm/pstl_backends/cpu_backends/stable_sort.h>
#include <__algorithm/pstl_backends/cpu_backends/transform.h>
#include <__algorithm/pstl_backends/cpu_backends/transform_reduce.h>
#include <__pstl/cpu_algos/any_of.h>
#include <__pstl/cpu_algos/fill.h>
#include <__pstl/cpu_algos/find_if.h>
#include <__pstl/cpu_algos/for_each.h>
#include <__pstl/cpu_algos/merge.h>
#include <__pstl/cpu_algos/stable_sort.h>
#include <__pstl/cpu_algos/transform.h>
#include <__pstl/cpu_algos/transform_reduce.h>

#endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H
16 changes: 8 additions & 8 deletions libcxx/include/__pstl/backends/std_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

// Implement PSTL algorithms based on the __cpu_traits specialized above
#include <__algorithm/pstl_backends/cpu_backends/any_of.h>
#include <__algorithm/pstl_backends/cpu_backends/fill.h>
#include <__algorithm/pstl_backends/cpu_backends/find_if.h>
#include <__algorithm/pstl_backends/cpu_backends/for_each.h>
#include <__algorithm/pstl_backends/cpu_backends/merge.h>
#include <__algorithm/pstl_backends/cpu_backends/stable_sort.h>
#include <__algorithm/pstl_backends/cpu_backends/transform.h>
#include <__algorithm/pstl_backends/cpu_backends/transform_reduce.h>
#include <__pstl/cpu_algos/any_of.h>
#include <__pstl/cpu_algos/fill.h>
#include <__pstl/cpu_algos/find_if.h>
#include <__pstl/cpu_algos/for_each.h>
#include <__pstl/cpu_algos/merge.h>
#include <__pstl/cpu_algos/stable_sort.h>
#include <__pstl/cpu_algos/transform.h>
#include <__pstl/cpu_algos/transform_reduce.h>

#endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H
#ifndef _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H
#define _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H

#include <__algorithm/any_of.h>
#include <__algorithm/find_if.h>
Expand Down Expand Up @@ -96,4 +96,4 @@ _LIBCPP_POP_MACROS

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

#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H
#endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H
#ifndef _LIBCPP___PSTL_CPU_ALGOS_FILL_H
#define _LIBCPP___PSTL_CPU_ALGOS_FILL_H

#include <__algorithm/fill.h>
#include <__config>
Expand Down Expand Up @@ -60,4 +60,4 @@ _LIBCPP_END_NAMESPACE_STD

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

#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H
#endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H
#ifndef _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H
#define _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H

#include <__algorithm/find_if.h>
#include <__atomic/atomic.h>
Expand Down Expand Up @@ -132,4 +132,4 @@ _LIBCPP_POP_MACROS

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

#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H
#endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H
#ifndef _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H
#define _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H

#include <__algorithm/for_each.h>
#include <__config>
Expand Down Expand Up @@ -60,4 +60,4 @@ _LIBCPP_END_NAMESPACE_STD

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

#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H
#endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H
#ifndef _LIBCPP___PSTL_CPU_ALGOS_MERGE_H
#define _LIBCPP___PSTL_CPU_ALGOS_MERGE_H

#include <__algorithm/merge.h>
#include <__config>
Expand Down Expand Up @@ -83,4 +83,4 @@ _LIBCPP_POP_MACROS

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

#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H
#endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H
#ifndef _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H
#define _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H

#include <__algorithm/stable_sort.h>
#include <__config>
Expand Down Expand Up @@ -43,4 +43,4 @@ _LIBCPP_END_NAMESPACE_STD

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

#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H
#endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H
#ifndef _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H
#define _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H

#include <__algorithm/transform.h>
#include <__config>
Expand Down Expand Up @@ -136,4 +136,4 @@ _LIBCPP_POP_MACROS

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

#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H
#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H
#ifndef _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H
#define _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H

#include <__config>
#include <__iterator/concepts.h>
Expand Down Expand Up @@ -203,4 +203,4 @@ _LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS

#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H
#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H
8 changes: 0 additions & 8 deletions libcxx/include/libcxx.imp
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@
{ include: [ "<__algorithm/pop_heap.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/prev_permutation.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_any_all_none_of.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_backends/cpu_backends/any_of.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_backends/cpu_backends/fill.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_backends/cpu_backends/find_if.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_backends/cpu_backends/for_each.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_backends/cpu_backends/merge.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_backends/cpu_backends/stable_sort.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_backends/cpu_backends/transform.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_backends/cpu_backends/transform_reduce.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_copy.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_count.h>", "private", "<algorithm>", "public" ] },
{ include: [ "<__algorithm/pstl_equal.h>", "private", "<algorithm>", "public" ] },
Expand Down
28 changes: 14 additions & 14 deletions libcxx/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -714,14 +714,6 @@ module std_private_algorithm_partition_point [system
module std_private_algorithm_pop_heap [system] { header "__algorithm/pop_heap.h" }
module std_private_algorithm_prev_permutation [system] { header "__algorithm/prev_permutation.h" }
module std_private_algorithm_pstl_any_all_none_of [system] { header "__algorithm/pstl_any_all_none_of.h" }
module std_private_algorithm_pstl_backends_cpu_backends_any_of [system] { textual header "__algorithm/pstl_backends/cpu_backends/any_of.h" }
module std_private_algorithm_pstl_backends_cpu_backends_fill [system] { textual header "__algorithm/pstl_backends/cpu_backends/fill.h" }
module std_private_algorithm_pstl_backends_cpu_backends_find_if [system] { textual header "__algorithm/pstl_backends/cpu_backends/find_if.h" }
module std_private_algorithm_pstl_backends_cpu_backends_for_each [system] { textual header "__algorithm/pstl_backends/cpu_backends/for_each.h" }
module std_private_algorithm_pstl_backends_cpu_backends_merge [system] { textual header "__algorithm/pstl_backends/cpu_backends/merge.h" }
module std_private_algorithm_pstl_backends_cpu_backends_stable_sort [system] { textual header "__algorithm/pstl_backends/cpu_backends/stable_sort.h" }
module std_private_algorithm_pstl_backends_cpu_backends_transform [system] { textual header "__algorithm/pstl_backends/cpu_backends/transform.h" }
module std_private_algorithm_pstl_backends_cpu_backends_transform_reduce [system] { textual header "__algorithm/pstl_backends/cpu_backends/transform_reduce.h" }
module std_private_algorithm_pstl_copy [system] { header "__algorithm/pstl_copy.h" }
module std_private_algorithm_pstl_count [system] { header "__algorithm/pstl_count.h" }
module std_private_algorithm_pstl_equal [system] { header "__algorithm/pstl_equal.h" }
Expand Down Expand Up @@ -1595,15 +1587,23 @@ module std_private_numeric_transform_exclusive_scan [system] { header "__numeric
module std_private_numeric_transform_inclusive_scan [system] { header "__numeric/transform_inclusive_scan.h" }
module std_private_numeric_transform_reduce [system] { header "__numeric/transform_reduce.h" }

module std_private_pstl_backends_libdispatch [system] { header "__pstl/backends/libdispatch.h" }
module std_private_pstl_backends_serial [system] { header "__pstl/backends/serial.h" }
module std_private_pstl_backends_std_thread [system] { header "__pstl/backends/std_thread.h" }
module std_private_pstl_cpu_algos_cpu_traits [system] { header "__pstl/cpu_algos/cpu_traits.h" }
module std_private_pstl_configuration_fwd [system] {
module std_private_pstl_backends_libdispatch [system] { header "__pstl/backends/libdispatch.h" }
module std_private_pstl_backends_serial [system] { header "__pstl/backends/serial.h" }
module std_private_pstl_backends_std_thread [system] { header "__pstl/backends/std_thread.h" }
module std_private_pstl_cpu_algos_any_of [system] { textual header "__pstl/cpu_algos/any_of.h" }
module std_private_pstl_cpu_algos_cpu_traits [system] { header "__pstl/cpu_algos/cpu_traits.h" }
module std_private_pstl_cpu_algos_fill [system] { textual header "__pstl/cpu_algos/fill.h" }
module std_private_pstl_cpu_algos_find_if [system] { textual header "__pstl/cpu_algos/find_if.h" }
module std_private_pstl_cpu_algos_for_each [system] { textual header "__pstl/cpu_algos/for_each.h" }
module std_private_pstl_cpu_algos_merge [system] { textual header "__pstl/cpu_algos/merge.h" }
module std_private_pstl_cpu_algos_stable_sort [system] { textual header "__pstl/cpu_algos/stable_sort.h" }
module std_private_pstl_cpu_algos_transform [system] { textual header "__pstl/cpu_algos/transform.h" }
module std_private_pstl_cpu_algos_transform_reduce [system] { textual header "__pstl/cpu_algos/transform_reduce.h" }
module std_private_pstl_configuration_fwd [system] {
header "__pstl/configuration_fwd.h"
export *
}
module std_private_pstl_configuration [system] {
module std_private_pstl_configuration [system] {
header "__pstl/configuration.h"
export *
}
Expand Down

0 comments on commit 0e08bce

Please sign in to comment.