diff options
author | Louis Dionne <ldionne.2@gmail.com> | 2024-06-12 12:24:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-12 12:24:34 -0400 |
commit | 9540950a45eee79a3ae4e9e0fa92d72b703d14dd (patch) | |
tree | f63c704c50de9543c5d9fd17e2bf4c25d4b00556 /libcxx/include/CMakeLists.txt | |
parent | 11399028ba2d74de770f46e7044ee0f008b01778 (diff) | |
download | llvm-9540950a45eee79a3ae4e9e0fa92d72b703d14dd.zip llvm-9540950a45eee79a3ae4e9e0fa92d72b703d14dd.tar.gz llvm-9540950a45eee79a3ae4e9e0fa92d72b703d14dd.tar.bz2 |
[libc++] Overhaul the PSTL dispatching mechanism (#88131)
The experimental PSTL's current dispatching mechanism was designed with
flexibility in mind. However, while reviewing the in-progress OpenMP
backend, I realized that the dispatching mechanism based on ADL and
default definitions in the frontend had several downsides. To name a
few:
1. The dispatching of an algorithm to the back-end and its default
implementation is bundled together via `_LIBCPP_PSTL_CUSTOMIZATION_POINT`.
This makes the dispatching really confusing and leads to annoyances
such as variable shadowing and weird lambda captures in the front-end.
2. The distinction between back-end functions and front-end algorithms
is not as clear as it could be, which led us to call one where we meant
the other in a few cases. This is bad due to the exception requirements
of the PSTL: calling a front-end algorithm inside the implementation of
a back-end is incorrect for exception-safety.
3. There are two levels of back-end dispatching in the PSTL, which treat
CPU backends as a special case. This was confusing and not as flexible
as we'd like. For example, there was no straightforward way to dispatch
all uses of `unseq` to a specific back-end from the OpenMP backend,
or for CPU backends to fall back on each other.
This patch rewrites the backend dispatching mechanism to solve these
problems, but doesn't touch any of the actual implementation of
algorithms. Specifically, this rewrite has the following
characteristics:
- There is a single level of backend dispatching, however partial backends can
be stacked to provide a full implementation of the PSTL. The two-level dispatching
that was used for CPU-based backends is handled by providing CPU-based basis
operations as simple helpers that can easily be reused when defining any PSTL
backend.
- The default definitions for algorithms are separated from their dispatching logic.
- The front-end is thus simplified a whole lot and made very consistent
for all algorithms, which makes it easier to audit the front-end for
things like exception-correctness, appropriate forwarding, etc.
Fixes #70718
Diffstat (limited to 'libcxx/include/CMakeLists.txt')
-rw-r--r-- | libcxx/include/CMakeLists.txt | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index d65b7ce..8d0ffd6 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -73,7 +73,6 @@ set(files __algorithm/pop_heap.h __algorithm/prev_permutation.h __algorithm/pstl.h - __algorithm/pstl_frontend_dispatch.h __algorithm/push_heap.h __algorithm/ranges_adjacent_find.h __algorithm/ranges_all_of.h @@ -576,11 +575,12 @@ set(files __numeric/transform_reduce.h __ostream/basic_ostream.h __ostream/print.h + __pstl/backend.h + __pstl/backend_fwd.h + __pstl/backends/default.h __pstl/backends/libdispatch.h __pstl/backends/serial.h __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 @@ -590,6 +590,8 @@ set(files __pstl/cpu_algos/stable_sort.h __pstl/cpu_algos/transform.h __pstl/cpu_algos/transform_reduce.h + __pstl/dispatch.h + __pstl/handle_exception.h __random/bernoulli_distribution.h __random/binomial_distribution.h __random/cauchy_distribution.h |